如何在 yolo-nas 模型中获取边界框坐标

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

我训练了我的自定义 yolo-nas 模型并尝试在我的图像上测试 t,它为我提供了带有边界框和标签的输出图像,但如何提取坐标和标签?

import super_gradients.training as sgt

best_model = sgt.models.get('yolo_nas_s', num_classes=1, checkpoint_path="C:/Users/Ritesh/Downloads/ckpt_best.pth")

img = "cube.jpeg"
prediction = best_model.predict(img)

我尝试了 stackoverflow 本身的解决方案,但没有成功

prediction_objects = list(prediction._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]

谢谢

label coordinates object-detection yolo bounding-box
1个回答
0
投票

这就是答案:

prediction_objects = list(prediction._images_prediction_lst)[0]

bboxes = prediction_objects.prediction.bboxes_xyxy

for i, box in enumerate(bboxes):

    x_min, y_min, x_max, y_max = box
© www.soinside.com 2019 - 2024. All rights reserved.