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

No negative word importance #40

Open
Faiail opened this issue Apr 3, 2024 · 0 comments
Open

No negative word importance #40

Faiail opened this issue Apr 3, 2024 · 0 comments

Comments

@Faiail
Copy link

Faiail commented Apr 3, 2024

Hello, I have tried to use the clip notebook, but concering the word importance, no configuration has never output some negative importance.

I attach a sample code snipped:

img_path = "CLIP/glasses.png"
img = preprocess(Image.open(img_path)).unsqueeze(0).to(device)
texts = ["a bear"]
text = clip.tokenize(texts).to(device)

R_text, R_image = interpret(model=model, image=img, texts=text, device=device)
batch_size = text.shape[0]
for i in range(batch_size):
  show_heatmap_on_text(texts[i], text[i], R_text[i])
  show_image_relevance(R_image[i], img, orig_image=Image.open(img_path))
  plt.show()

The output is the following:
image

Thanks for the help :)

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

1 participant