Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the videoclip features? #1

Open
ziweiji opened this issue Mar 1, 2025 · 1 comment
Open

How to get the videoclip features? #1

ziweiji opened this issue Mar 1, 2025 · 1 comment

Comments

@ziweiji
Copy link

ziweiji commented Mar 1, 2025

Could you please guide me on how to extract text and video features from VideoClip? I'm using the checkpoint from fairseq/examples/MMPT/, but I'm unable to obtain the same features as you. Could you provide the code for this process?

@FOXamber
Copy link
Owner

FOXamber commented Mar 3, 2025

#old_feat is MIL-NCE feature
inter_old_feat = images[start+i]
inter_old_feat = inter_old_feat.unsqueeze(0).unsqueeze(0)
bsz = inter_old_feat.size(0)
seq_len = inter_old_feat.size(1)
max_video_len = config.dataset.max_video_len
padding = torch.zeros(
bsz, max_video_len - seq_len, inter_old_feat.size(-1))
vfeats = torch.cat([inter_old_feat, padding], dim=1)
vmasks = torch.cat([
torch.ones((bsz, seq_len), dtype=torch.bool),
torch.zeros((bsz, max_video_len - seq_len), dtype=torch.bool)
],
dim=1
)
output = model(caps, cmasks, vfeats, vmasks)
inter_new_feat = output["pooled_video"].squeeze()
new_feat[start+i] = inter_new_feat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants