I recently installed supergradients to use YOLO_NAS, the example is very easy to make predictions, does anyone know how to get the bounding boxes of the objects? or the model’s predictions like another models yolo.
Example:
from super_gradients.training import models
yolo_nas_l = models.get("yolo_nas_l", pretrained_weights="coco")
url = "https://previews.123rf.com/images/freeograph/freeograph2011/freeograph201100150/158301822-group-of-friends-gathering-around-table-at-home.jpg"
yolo_nas_l.predict(url, conf=0.25).show()
RESULT: an image drawn with the predictions
thanks
I was expecting the model to give me the predictions in an array with their bounding boxes and classes.
You can get predicted bounding boxes and classes in YOLO-NAS like this:
predictions = model.predict(url, conf=0.25)
prediction_objects = list(predictions._images_prediction_lst)[0]
bboxes = prediction_objects.prediction.bboxes_xyxy
int_labels = prediction_objects.prediction.labels.astype(int)
class_names = prediction_objects.class_names
pred_classes = [class_names[i] for i in int_labels]
The predictions
object provides a generator when you call predictions._images_prediction_lst
. With this approach, the actual detection doesn't take place until you call list()
on the generator which then provides a list of "prediction/detection related objects". One of these objects is the 'prediction'. We can use this to get an array of predicted bounding boxes. Likewise we can also obtain a list of corresponding class labels.
This may not be explicitly in the documentation, (I couldn't find it). Instead, I would encourage you to explore with the dir() function to find out more about the outputs. e.g. see what this returns dir(prediction_objects)
.
There are also more ways to perform inference using super-gradients, see this notebook. For other examples see this