Define fallback model.names from Predictor (#9439)

This commit is contained in:
Glenn Jocher 2024-03-31 06:33:43 +02:00 committed by GitHub
parent 7ea2007326
commit b530a3004e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -733,7 +733,10 @@ class Model(nn.Module):
"""
from ultralytics.nn.autobackend import check_class_names
return check_class_names(self.model.names) if hasattr(self.model, "names") else None
if hasattr(self.model, "names"):
return check_class_names(self.model.names)
elif self.predictor:
return self.predictor.model.names
@property
def device(self) -> torch.device: