首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >yolov5输出的解释

yolov5输出的解释
EN

Stack Overflow用户
提问于 2021-03-12 12:03:55
回答 1查看 1.3K关注 0票数 3

我正在做一个面罩检测项目,我用超级解析学/yolov5训练了我的模型。我把经过训练的模型保存为onnx文件,您可以在这里找到模型文件model.onnx。现在,我希望您使用这个model.onnx与opencv来检测实时面罩。训练期间输入的图像大小为320*320。您可以使用netron来可视化这个模型。我编写了这段代码,用摄像头捕捉图像,并将其传递给model.onnx,以预测我的边界框。守则如下:

代码语言:javascript
复制
def predict(img):
    session = onnxruntime.InferenceSession(model_path)
    input_name = session.get_inputs()[0].name
    output_name = session.get_outputs()[0].name
    img = img.reshape((1,3,320,320))
    data = json.dumps({'data':img.tolist()})
    data = np.array(json.loads(data)['data']).astype('float32')
    result = session.run([output_name],{input_name:data})
    result = np.array(result)
    print(result.shape)

result.shape的输出是(1,1,3,40,40,85),谁能帮我解释这个形状,我如何使用这个结果数组来预测我的类,边界框和信心。

EN

回答 1

Stack Overflow用户

发布于 2022-05-17 17:13:18

我从未使用过纯yolov5模型,但这是yolov5s的输出格式。看起来应该是相似的。

代码语言:javascript
复制
ouput tensor structure (yolov5s):
output_tensor[a, b, c, d]
    a -> image index (If you're input is a batch of images, this tells you which image's output you're looking at. If your input is just one image, leave this as 0.)
    b -> index of image in batch
    c -> information about bounding box
        0, 1 -> x and y coordinate of bounding box center
        2, 3 -> width and height of bounding box
        4 -> bounding box confidence
        5 - 85 -> single class confidences
    d -> index of proposed bounding boxes
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66599581

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档