Skip to content

Instantly share code, notes, and snippets.

@thigm85
Created November 12, 2021 15:52
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 thigm85/8640456aaf3245e9c3d14934a869ea9b to your computer and use it in GitHub Desktop.
Save thigm85/8640456aaf3245e9c3d14934a869ea9b to your computer and use it in GitHub Desktop.
def from_image_to_vector(x, process_fn):
with torch.no_grad():
image_features = model.encode_image(process_fn(x).unsqueeze(0))
return image_features
image_dataset = ImageDataset(
img_dir=os.environ["IMG_DIR"],
transform=lambda x: from_image_to_vector(x, process_fn=preprocess)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment