BabitMF / bmf

Cross-platform, customizable multimedia/video processing framework. With strong GPU acceleration, heterogeneous design, multi-language support, easy to use, multi-framework compatible and high performance, the framework is ideal for transcoding, AI inference, algorithm integration, live video streaming, and more.
https://babitmf.github.io/
Apache License 2.0
730 stars 60 forks source link

请问如何在一个graph内设置两个输出? #115

Open QQiangren opened 1 month ago

QQiangren commented 1 month ago

运行人脸识别demo(trt_face_detect.py)把判断语句:if (output_queue_size >= 2):屏蔽掉,云溪谷会报错: [2024-05-11 04:09:39.784] [info] node:c_ffmpeg_encoder 3 scheduler 1 [2024-05-11 04:09:39.807] [error] node id:1 catch exception: KeyError: (1,) At: /root/bmf/lvyantest/tensorrt_post/trt_face_detect.py(226): process [2024-05-11 04:09:39.807] [error] node id:1 Process node failed, will exit. [2024-05-11 04:09:39.808] [info] node 1 got exception, close directly [2024-05-11 04:09:39.808] [info] schedule queue 0 start to join thread [2024-05-11 04:09:39.808] [error] node id:1 catch exception: KeyError: (1,)

At: /root/bmf/lvyantest/tensorrt_post/trt_face_detect_ok.py(226): process

[2024-05-11 04:09:39.808] [error] node id:1 Process node failed, will exit. Traceback (most recent call last): File "testtrt1.py", line 54, in main() File "testtrt1.py", line 50, in main video.run() File "/root/bmf/output/bmf/builder/bmfstream.py", line 82, in run return self.node.get_graph().run(self) File "/root/bmf/output/bmf/builder/bmf_graph.py", line 747, in run self.execgraph.close() File "/root/bmf/lvyantest/tensorrt_post/trt_face_detect_ok.py", line 226, in process output_queue_1 = task.get_outputs()[1] KeyError: 1 是否是graph内只设置了一个输出,但是trt_face_detect.py内逻辑输出了文本的输出。请问在graph内怎样设置才能正确输出两个结果。

我的graph代码如下: import time import tensorrt as trt import bmf.hml.hmp as mp from nms import NMS import PIL from PIL import Image

def main(): graph1 = graph({'dump_graph':1})

video = graph1.decode({
    "input_path": "./face.mp4",
    "video_params": {
       "hwaccel": "cuda",
    }
})["video"]

video = video.module("trt_face_detect", {
    "model_path": "./version-RFB-640.engine",
    "input_shapes": {
        "input": [1, 3, 480, 640]
    }}, entry="trt_face_detect_ok.trt_face_detect")

video = video.module("face_postprocess",
    entry="face_postprocess.face_postprocess")

video = video.encode(
    None, {
        "output_path": "./trt_out.mp4",
        "video_params": {
            "codec": "h264_nvenc",
            "bit_rate": 5000000,
            "max_fr": 30
        }
    }
    )

video.run()

if name == "main": main() 感谢!

sfeiwong commented 1 month ago

video = module("TWO_OUTPUT"...) stream1 = video.module(...) stream2 = video.module(...)