Hi,
From the code, it is not clear what your source is(Bayer sensor camera, USB camera, or IP camera). There should have one cv2.VideoCapture() and one cv2.VideoWriter() like this sample:
Displaying to the screen with OpenCV and GStreamer - #9 by DaneLLL
Please share information about the input source so that we can suggest next.
And we have demonstration of Yolo models in DeepStream SDK. You may also take a look and give it a try.