Skip to content

Python API可视化增加标签展示 #643

@JackonLiu

Description

@JackonLiu

platform:windows10
python3.8
onnx==1.12.0
安装方式
pip install fastdeploy-python -f https://www.paddlepaddle.org.cn/whl/fastdeploy.html
yolov5-5.0
导出方式
python export.py --weights runs/train/exp33/weights/best.pt --include onnx

   result = model.predict(im.copy())
    print(result)
    print(frame_index)
    t3 = time.time()
    print('detect frames: %.4f frames/s' % (1 / (t3 - t2)))
    # 预测结果可视化
    label_ids = result.label_ids
    if label_ids:
        for i in range(len(label_ids)):
            if label_ids[i] == 0:
                label_ids[i] = 'hat'
            else:
                label_ids[i] = 'person'
    result.label_ids = label_ids
    if result.boxes:
        vis_im = fd.vision.vis_detection(im, result,score_threshold=0.7)

[FastDeploy][INFO]: Successfully found CUDA ToolKit from system PATH env -> C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\bin
[INFO] fastdeploy/runtime.cc(528)::fastdeploy::Runtime::Init Runtime initialized with Backend::OPENVINO in Device::CPU.
(1440, 2560, 3)
DetectionResult: [xmin, ymin, xmax, ymax, score, label_id]
219.655457,190.753174, 591.998047, 611.119873, 0.911301, 0

0
detect frames: 2.4705 frames/s
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py", line 1438, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/Administrator/projects/FastDeploy-develop/examples/vision/detection/yolov5/python/infer_video.py", line 68, in
result.label_ids = label_ids
TypeError: (): incompatible function arguments. The following argument types are supported:
1. (self: fastdeploy.libs.fastdeploy_main.vision.DetectionResult, arg0: List[int]) -> None

Invoked with: DetectionResult: [xmin, ymin, xmax, ymax, score, label_id]
219.655457,190.753174, 591.998047, 611.119873, 0.911301, 0
, ['hat']

我知道错误的原因是不能直接换成字符串,但是希望之后能增加字符串的方式,不然很多场景检测出来的图片不能用!!!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions