Skip to content

Commit

Permalink
Define fallback model.names from Predictor (ultralytics#9439)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher authored and hmurari committed Apr 17, 2024
1 parent 8d61dc9 commit 37fbb06
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ultralytics/engine/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,10 @@ def names(self) -> list:
"""
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:
Expand Down

0 comments on commit 37fbb06

Please sign in to comment.