[GH-ISSUE #60] pip installable package #54

Closed
opened 2026-10-31 21:10:17 +00:00 by bsakaguchi · 4 comments
Owner

Originally created by @lucidrains on GitHub (Mar 11, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/60

Hi and thanks for the great model :)

I was wondering if you would be open to publishing this to PyPI, as you have done for gym and dall_e. It would be convenient to be able to include this as a dependency in setup.py and for others to be able to use right away without an extra pip install git+{repo}

Originally created by @lucidrains on GitHub (Mar 11, 2021). Original GitHub issue: https://github.com/openai/CLIP/issues/60 Hi and thanks for the great model :) I was wondering if you would be open to publishing this to PyPI, as you have done for gym and dall_e. It would be convenient to be able to include this as a dependency in `setup.py` and for others to be able to use right away without an extra `pip install git+{repo}`
Author
Owner

@nreimers commented on GitHub (Mar 19, 2021):

Yes, a pip install would be nice.

As a work-around you can use SentenceTransformers, where CLIP is integrated:

pip install sentence-transformers

Then you can use CLIP like this:

from sentence_transformers import SentenceTransformer, util
from PIL import Image

#Load CLIP model
model = SentenceTransformer('clip-ViT-B-32')

#Encode an image:
img_emb = model.encode(Image.open('two_dogs_in_snow.jpg'))

#Encode text descriptions
text_emb = model.encode(['Two dogs in the snow', 'A cat on a table', 'A picture of London at night'])

#Compute cosine similarities 
cos_scores = util.cos_sim(img_emb, text_emb)
print(cos_scores)

More details
https://www.sbert.net/examples/applications/image-search/README.html#usage

<!-- gh-comment-id:803096974 --> @nreimers commented on GitHub (Mar 19, 2021): Yes, a pip install would be nice. As a work-around you can use SentenceTransformers, where CLIP is integrated: ``` pip install sentence-transformers ``` Then you can use CLIP like this: ```python from sentence_transformers import SentenceTransformer, util from PIL import Image #Load CLIP model model = SentenceTransformer('clip-ViT-B-32') #Encode an image: img_emb = model.encode(Image.open('two_dogs_in_snow.jpg')) #Encode text descriptions text_emb = model.encode(['Two dogs in the snow', 'A cat on a table', 'A picture of London at night']) #Compute cosine similarities cos_scores = util.cos_sim(img_emb, text_emb) print(cos_scores) ``` More details https://www.sbert.net/examples/applications/image-search/README.html#usage
Author
Owner

@lucidrains commented on GitHub (Mar 20, 2021):

@nreimers thanks for cuing me in Nils! unfortunately I need to be able to pass in an image tensor, so it is conductive to gradients to the origin

<!-- gh-comment-id:803209370 --> @lucidrains commented on GitHub (Mar 20, 2021): @nreimers thanks for cuing me in Nils! unfortunately I need to be able to pass in an image tensor, so it is conductive to gradients to the origin
Author
Owner

@jongwook commented on GitHub (Mar 22, 2021):

Hi @lucidrains, while we may add some code/model updates or compatibility fixes going forward in this repo, we'd like to not make an additional commitment to provide semantic versioning / maintenance by pushing the packages to PyPI.

Meanwhile, the repo is MIT-licensed, and you're welcome to package the code yourself or include in your libraries. I see some users already did so.

<!-- gh-comment-id:804046122 --> @jongwook commented on GitHub (Mar 22, 2021): Hi @lucidrains, while we may add some code/model updates or compatibility fixes going forward in this repo, we'd like to not make an additional commitment to provide semantic versioning / maintenance by pushing the packages to PyPI. Meanwhile, the repo is MIT-licensed, and you're welcome to package the code yourself or include in your libraries. I see [some](https://www.reddit.com/r/Python/comments/l64709/open_source_library_for_openais_clip_to_create/) [users](https://pypi.org/project/clip-by-openai/) already did so.
Author
Owner

@lucidrains commented on GitHub (Mar 22, 2021):

Hi Jong! Yup, anything would be better than nothing :)

<!-- gh-comment-id:804474846 --> @lucidrains commented on GitHub (Mar 22, 2021): Hi Jong! Yup, anything would be better than nothing :)
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openai/CLIP#54
No description provided.