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

Exposing OpenCLIP embeddings #3960

Merged
merged 2 commits into from
Jan 4, 2024
Merged

Exposing OpenCLIP embeddings #3960

merged 2 commits into from
Jan 4, 2024

Conversation

jacobmarks
Copy link
Contributor

@jacobmarks jacobmarks commented Jan 3, 2024

What changes are proposed in this pull request?

Exposing prompt embedding capabilities for OpenCLIP model recently added to zoo

  • Set can_embed_prompts to True
  • Added an embed_prompts() method

Test the embedding directly:

import fiftyone as fo
import fiftyone.zoo as foz

model = foz.load_zoo_model("open-clip-torch")
embeddings = model.embed_prompts(["dog", "cat"])

Now you can also do natural language image searches with OpenCLIP:

import fiftyone as fo
import fiftyone.brain as fob
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset("quickstart")

fob.compute_similarity(dataset, model="open-clip-torch", brain_key="oc_sim")
dataset.sort_by_similarity("cat")

Additional Notes

  • We may want to go through the docs and wherever CLIP is used, offer this as an alternative
  • Should add this to the model zoo listing
  • At present, this only allows for using the DEFAULT OpenCLIP weights/architecture, not EVA-CLIP, MetaCLIP etc, because the natural language image search only works when you pass the name of the model into compute_similarity, not the model object itself!

What areas of FiftyOne does this PR affect?

  • App: FiftyOne application changes
  • Build: Build and test infrastructure changes
  • Core: Core fiftyone Python library changes
  • Documentation: FiftyOne documentation changes
  • Other

Copy link

codecov bot commented Jan 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7eaeee9) 15.86% compared to head (12c3d32) 15.85%.
Report is 45 commits behind head on develop.

❗ Current head 12c3d32 differs from pull request most recent head 78a4463. Consider uploading reports for the commit 78a4463 to get more accurate results

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3960      +/-   ##
===========================================
- Coverage    15.86%   15.85%   -0.02%     
===========================================
  Files          731      731              
  Lines        81853    81878      +25     
  Branches      1093     1093              
===========================================
- Hits         12987    12979       -8     
- Misses       68866    68899      +33     
Flag Coverage Δ
app 15.85% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@brimoor brimoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🥇

@jacobmarks jacobmarks merged commit acf3a8f into develop Jan 4, 2024
9 checks passed
@jacobmarks jacobmarks deleted the openclip-embeddings branch January 4, 2024 02:18
@benjaminpkane benjaminpkane mentioned this pull request Jan 5, 2024
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

Successfully merging this pull request may close these issues.

3 participants