Skip to content

Commit

Permalink
changed .to(torch.device(self.device)) to .to(self.device), object is…
Browse files Browse the repository at this point in the history
… already loaded not just string
  • Loading branch information
Jacob Sela committed Nov 1, 2024
1 parent a4fee85 commit 9a89a70
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fiftyone/utils/clip/zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _predict_all(self, imgs):
frame_size = (width, height)

if self._using_gpu:
imgs = imgs.to(torch.device(self.device))
imgs = imgs.to(self.device)

text_features = self._get_text_features()
image_features = self._model.encode_image(imgs)
Expand Down
6 changes: 3 additions & 3 deletions fiftyone/utils/open_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def _get_text_features(self):
# Tokenize text
text = self._tokenizer(prompts)
if self._using_gpu:
text = text.to(torch.device(self.device))
text = text.to(self.device)
self._text_features = self._model.encode_text(text)

return self._text_features
Expand All @@ -118,7 +118,7 @@ def _embed_prompts(self, prompts):
# Tokenize text
text = self._tokenizer(formatted_prompts)
if self._using_gpu:
text = text.to(torch.device(self.device))
text = text.to(self.device)
return self._model.encode_text(text)

def _get_class_logits(self, text_features, image_features):
Expand All @@ -143,7 +143,7 @@ def _predict_all(self, imgs):
frame_size = (width, height)

if self._using_gpu:
imgs = imgs.to(torch.device(self.device))
imgs = imgs.to(self.device)

with torch.no_grad(), torch.amp.autocast("cuda"):
image_features = self._model.encode_image(imgs)
Expand Down
2 changes: 1 addition & 1 deletion fiftyone/utils/super_gradients.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _load_model(self, config):
)

if self._using_gpu:
model = model.to(torch.device(self.device))
model = model.to(self.device)

return model

Expand Down

0 comments on commit 9a89a70

Please sign in to comment.