Deci-AI / super-gradients

Easily train or fine-tune SOTA computer vision models with one open source training library. The home of Yolo-NAS.
https://www.supergradients.com
Apache License 2.0
4.59k stars 510 forks source link

Get class names after loading YOLO-NAS model, NOT after prediction #1032

Closed naseemap47 closed 1 year ago

naseemap47 commented 1 year ago

Its better to take class name after loading the model like YOLOv7 and YOLOv8. Rather than while predicting

In YOLOv7 and YOLOv8 we can take class names:

model = YOLO(model_path)
class_names = model.names

But in YOLO-NAS we can only take after predicting

model = models.get(Models.YOLO_NAS_L, pretrained_weights="coco")
model = model.to("cuda" if torch.cuda.is_available() else "cpu")
preds = next(model.predict('dog.jpeg')._images_prediction_lst)
class_names = preds.class_names
print('Class Names: ', class_names)

If any know how to take class names after model loading rather than after passing image!! @shaydeci @ofrimasad @shairoz-deci @NatanBagrov @ranrubin @lotem-deci @lkdci @yurkovak @BloodAxe @oferbaratz @Louis-Dupont

dagshub[bot] commented 1 year ago

Join the discussion on DagsHub!

NatanBagrov commented 1 year ago

Hello, you can find class names here. Please, stop tagging every person here, and do some in-code investigation prior to opening issues that can be solved independently.

naseemap47 commented 1 year ago

Sorry for tagging everyone. I think you didn't understand my problem. I am getting class names by

model = models.get(Models.YOLO_NAS_L, pretrained_weights="coco")
model = model.to("cuda" if torch.cuda.is_available() else "cpu")
preds = next(model.predict('dog.jpeg')._images_prediction_lst)
class_names = preds.class_names
print('Class Names: ', class_names)

I need to know about, there is any way to get the class names before prediction like yolov8 and yolov7 example:

model = YOLO(model_path)
class_names = model.names
NatanBagrov commented 1 year ago

You can reference this list and use it anytime.

print(COCO_DETECTION_CLASSES_LIST)
naseemap47 commented 1 year ago

This is I understood, I need to get class names from model file. What if we have custom classes rather than COCO.