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

Fixed CLIPScore import in docs #1943

Merged
merged 2 commits into from
Jul 27, 2023
Merged

Conversation

IanMaquignaz
Copy link
Contributor

@IanMaquignaz IanMaquignaz commented Jul 27, 2023

Fixes #1942
Updates CLIPScore docs as seen on this page: CLIPScore

Demo code incorrectly imports CLIPScore as:

from torchmetrics.multimodal import CLIPScore

This PR corrects the import to:

from torchmetrics.multimodal.clip_score import CLIPScore

📚 Documentation preview 📚: https://torchmetrics--1943.org.readthedocs.build/en/1943/

@Borda Borda enabled auto-merge (squash) July 27, 2023 00:23
@IanMaquignaz IanMaquignaz disabled auto-merge July 27, 2023 00:24
@codecov
Copy link

codecov bot commented Jul 27, 2023

Codecov Report

Merging #1943 (68d5acf) into master (fc344c4) will decrease coverage by 50%.
The diff coverage is n/a.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1943     +/-   ##
========================================
- Coverage      85%     35%    -50%     
========================================
  Files         263     263             
  Lines       15087   15087             
========================================
- Hits        12833    5216   -7617     
- Misses       2254    9871   +7617     

@IanMaquignaz
Copy link
Contributor Author

All demos were copied to a script and run with torchmetrics master branch. No further errors were found.

import torch
_ = torch.manual_seed(42)
from torchmetrics.multimodal.clip_score import CLIPScore
metric = CLIPScore(model_name_or_path="openai/clip-vit-base-patch16")
score = metric(torch.randint(255, (3, 224, 224)), "a photo of a cat")
print(score.detach())
        
import torch
from torchmetrics.multimodal.clip_score import CLIPScore
metric = CLIPScore(model_name_or_path="openai/clip-vit-base-patch16")
metric.update(torch.randint(255, (3, 224, 224)), "a photo of a cat")
fig_, ax_ = metric.plot()
fig_.savefig("my_awesome_plot.png")

import torch
from torchmetrics.multimodal.clip_score import CLIPScore
metric = CLIPScore(model_name_or_path="openai/clip-vit-base-patch16")
values = [ ]
for _ in range(10):
    values.append(metric(torch.randint(255, (3, 224, 224)), "a photo of a cat"))
fig_, ax_ = metric.plot(values)
fig_.savefig("my_awesome_plot2.png")

my_awesome_plot
my_awesome_plot2

@mergify mergify bot added the ready label Jul 27, 2023
@stancld stancld enabled auto-merge (squash) July 27, 2023 05:22
@stancld stancld merged commit dc25a6e into Lightning-AI:master Jul 27, 2023
Borda pushed a commit that referenced this pull request Aug 1, 2023
Borda pushed a commit that referenced this pull request Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLIPScore demo code is incorrect
3 participants