jkjung-avt / tensorrt_demos

TensorRT MODNet, YOLOv4, YOLOv3, SSD, MTCNN, and GoogLeNet
https://jkjung-avt.github.io/
MIT License
1.74k stars 545 forks source link

Run trt_yolo on batch of image #577

Closed remiruzn closed 2 years ago

remiruzn commented 2 years ago

How i can run trt_yolo.detect(frame, conf_th) on multiple image like a batch. Need something like

frames=[frame_1, frame_2, frame_3]
trt_yolo.detect(frames, conf_th)

I have problem with optimal inference trt_yolo on 3 cameras in real time, can some one help me, any advice appreciated.

In general i have something like this:


while True:
        ret1, frame1 = cap1.read()
        ret2, frame2 = cap2.read()
        ret3, frame3 = cap3.read()
        if frame1 is None:  break
        if frame2 is None:  break
        if frame3 is None:  break

        boxes1, confs1, clss1 = trt_yolo.detect(frame1, conf_th)
        boxes2, confs2, clss2 = trt_yolo.detect(frame2, conf_th)
        boxes2, confs2, clss2 = trt_yolo.detect(frame3, conf_th)

        # Some logic with boxes
jkjung-avt commented 2 years ago

Please refer to: https://github.com/jkjung-avt/tensorrt_demos/issues/306.

remiruzn commented 2 years ago

Is this best practice for work with several cameras?

jkjung-avt commented 2 years ago

Is this best practice for work with several cameras?

That depends on your application. But you might want to look into NVIDIA DeepStream SDK.

remiruzn commented 2 years ago

Ok. Thanks for help!