ultralytics 8.1.32 fix CLIP backwards compatibility (#9253)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-03-23 18:39:22 +01:00 committed by GitHub
parent 7d2e94bbe2
commit 6de99a29e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 3 deletions

View file

@ -572,7 +572,7 @@ class WorldModel(DetectionModel):
check_requirements("git+https://github.com/openai/CLIP.git")
import clip
if not self.clip_model:
if not getattr(self, "clip_model", None): # for backwards compatibility of models lacking clip_model attribute
self.clip_model = clip.load("ViT-B/32")[0]
device = next(self.clip_model.parameters()).device
text_token = clip.tokenize(text).to(device)