From 9a89a703cb8f3d7304ecb9947232b770420247c1 Mon Sep 17 00:00:00 2001 From: Jacob Sela Date: Fri, 1 Nov 2024 09:58:02 -0400 Subject: [PATCH] changed .to(torch.device(self.device)) to .to(self.device), object is already loaded not just string --- fiftyone/utils/clip/zoo.py | 2 +- fiftyone/utils/open_clip.py | 6 +++--- fiftyone/utils/super_gradients.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fiftyone/utils/clip/zoo.py b/fiftyone/utils/clip/zoo.py index 9f7f79d065..06303f097c 100644 --- a/fiftyone/utils/clip/zoo.py +++ b/fiftyone/utils/clip/zoo.py @@ -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) diff --git a/fiftyone/utils/open_clip.py b/fiftyone/utils/open_clip.py index 3db90deb1d..5b50d9f13b 100644 --- a/fiftyone/utils/open_clip.py +++ b/fiftyone/utils/open_clip.py @@ -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 @@ -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): @@ -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) diff --git a/fiftyone/utils/super_gradients.py b/fiftyone/utils/super_gradients.py index 5e86dd8568..bc8c2b2ada 100644 --- a/fiftyone/utils/super_gradients.py +++ b/fiftyone/utils/super_gradients.py @@ -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