Skip to content

Instantly share code, notes, and snippets.

@MaartenGr
Last active October 31, 2021 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaartenGr/c826102b602090b9a7db011b09c4645d to your computer and use it in GitHub Desktop.
Save MaartenGr/c826102b602090b9a7db011b09c4645d to your computer and use it in GitHub Desktop.
import pickle
from sentence_transformers import util
# Load pre-trained image embeddings
emb_filename = 'unsplash-25k-photos-embeddings.pkl'
if not os.path.exists(emb_filename): #Download dataset if does not exist
util.http_get('http://sbert.net/datasets/'+emb_filename, emb_filename)
with open(emb_filename, 'rb') as fIn:
img_names, image_embeddings = pickle.load(fIn)
img_names = [f"photos/{path}" for path in img_names]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment