How to transform two serial models to ONNX

I am in trouble. It around me two weeks. I have a project that uses Yolov4 in pytorch for the Deepstream. So the yolo model should transform to ONNX, then Engine file by TensorRT.

But I want add some preprocessing for yolov4 model, then transform the preprocessing and yolo model to ONNX together. I don’t know how to do that.

Actually, I try to modify the YoloV4 code and hope to add a preprocess before the yolov4 model. But I get the error

“torch.nn.modules.module.ModuleAttributeError: ‘Darknet’ object has no attribute ‘myPreProcessing’”

So I want to build the preprocess model and make the two model serially.

Please help me. Thank you very much.