jayleicn / moment_detr

[NeurIPS 2021] Moment-DETR code and QVHighlights dataset
https://arxiv.org/abs/2107.09609
MIT License
259 stars 44 forks source link

Text feature extraction #15

Open Yangaiei opened 2 years ago

Yangaiei commented 2 years ago

Hi, Congrats on the amazing work. How to use CLIP to extract QVHIGHLIGHTS text features ? Can you provide the specific code?

jayleicn commented 2 years ago

Hi @angaiei007, please follow https://github.com/openai/CLIP#usage to extract the text features, this specific line below deals with text feature extraction:

text_features = model.encode_text(text)
Yangaiei commented 2 years ago

Hello, 1、I found that you have modified the CLIP.

2、I used your clip file. The data dimensions are the sam, but the value in the data has a little error. Such as: {"qid": 8056, "query": "Chef makes pizza and cuts it up."}

code:

print("========  my   ===")
text_features = np.load('after_feature.npz')
print(text_features.files)
print(text_features)
print(text_features['last_hidden_state'].shape,text_features['pooler_output'].shape)
print(text_features['last_hidden_state'])

print("========you   qid8056.npz   ===")
text_features = np.load('u_clip/qid8056.npz')
print(text_features.files)
print(text_features)
print(text_features['last_hidden_state'].shape,text_features['pooler_output'].shape)
print(text_features['last_hidden_state'])

result: 1655998605852

XiaohuJoshua commented 1 month ago

Excuse me, have you solved the problem? I also find that the value in the npz file has a little difference with feature I extracted.