Skip to content

Commit

Permalink
Merge pull request #3986 from voxel51/open_clip_gpu_support
Browse files Browse the repository at this point in the history
Adding gpu support for openclip models
  • Loading branch information
brimoor authored Jan 12, 2024
2 parents 861913b + c7f1590 commit cf4659c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fiftyone/utils/open_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def _load_model(self, config):
_,
self.preprocess,
) = open_clip.create_model_and_transforms(
config.clip_model, pretrained=config.pretrained
config.clip_model,
pretrained=config.pretrained,
device=config.device,
)
self._tokenizer = open_clip.get_tokenizer(config.clip_model)
return self._model
Expand All @@ -102,6 +104,8 @@ def _get_text_features(self):
]
# Tokenize text
text = self._tokenizer(prompts)
if self._using_gpu:
text = text.cuda()
self._text_features = self._model.encode_text(text)

return self._text_features
Expand Down

0 comments on commit cf4659c

Please sign in to comment.