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

Text feature extraction #15

Open
Yangaiei opened this issue Jun 18, 2022 · 2 comments
Open

Text feature extraction #15

Yangaiei opened this issue Jun 18, 2022 · 2 comments

Comments

@Yangaiei
Copy link

Yangaiei commented Jun 18, 2022

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

@jayleicn
Copy link
Owner

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
Copy link
Author

Yangaiei commented Jun 23, 2022

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

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