yolo nas 抛出错误“ImageDetectionPrediction”对象不可迭代

问题描述 投票:0回答:1

我在 yolo nas 检测代码上绑定了运行预测,但它抛出了错误。在 Colab 之前,它工作正常,没有给出错误,但第二天它给出了一个错误,我不明白我运行此代码的任何内容,与每个 yolo nas github 文档相同。不知道什么

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
prediction yolonas
1个回答
0
投票

之前工作时您可能使用的是 3.5 版本,因为从 3.6 版本开始,如果输入是单个图像,预测结果不再是可迭代对象。

另请参阅 GitHub 问题那里

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.