yolo nas throwing error 'ImageDetectionPrediction' object is not iterable

240 views Asked by At

I tied running predictions on my yolo nas detection code but it is throwing errors. Before in colab it was working fine without giving an error but the next day it is giving an error i don't understand anything i have run this code same to same as per yolo nas github docuamentation. Don't know what<s the problem before colab was running it without error but now it is producing error

img_url='/content/Retail-Store-1/valid/images/-10_jpg.rf.d5119996f5715cf1105b1e5bf01c0ced.jpg'
# best_model.predict(img_url).show()
# images_predictions.show(box_thickness=2, show_confidence=True)

images_predictions = best_model.predict(img_url)
for image_prediction in images_predictions:
    class_names = image_prediction.class_names
    labels = image_prediction.prediction.labels
    confidence = image_prediction.prediction.confidence
    bboxes = image_prediction.prediction.bboxes_xyxy

    for i, (label, conf, bbox) in enumerate(zip(labels, confidence, bboxes)):
        print("prediction: ", i)
        print("label_id: ", label)
        print("label_name: ", class_names[int(label)])
        print("confidence: ", conf)
        print("bbox: ", bbox)
        print("--" * 10)


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-24-7b64588141eb> in <cell line: 1>()
----> 1 for image_prediction in images_predictions:
      2     class_names = image_prediction.class_names
      3     labels = image_prediction.prediction.labels
      4     confidence = image_prediction.prediction.confidence
      5     bboxes = image_prediction.prediction.bboxes_xyxy

TypeError: 'ImageDetectionPrediction' object is not iterable
1

There are 1 answers

0
Michael Uray On

You probably used version 3.5 when it was working before, since version 3.6 the prediction result is not an iterable object anymore if the input is a single image.

Please see also the GitHub issue there.