Getting incorrect results for classification model

• Hardware Platform (Jetson / GPU) Jetson
• DeepStream Version 6.1
• JetPack Version (valid for Jetson only) 5.0.2
• TensorRT Version 8.4.1

I have trained a pytorch classification model. I have converted it into onnx. I’ve verified the onnx model, it is working fine. But in deepstream I’m getting incorrect results. Am I doing something wrong in preprocessing?

I want to use this model as the primary model.

I am attaching the model and the config file for reference.

efficientnet-model-v2.onnx (15.5 MB)

efficientnet_config.txt (534 Bytes)

The preprocessing is decided by how you trained the model. It is no use to send the model to us. Please consult the guy who trained the model.

@Fiona.Chen Dude read the question first. I already told you I trained the model and I’ve done the conversion. I want to know if I’m doing something wrong in the configuration part.
Is there any example code you can provide me for running classification model as the primary model. I’m using a pytorch classification model which use image resize and standard pytorch normalization and no other preprocessing.

We don’t know without knowing how you trained the model.

Please check all parameters listed in DeepStream SDK FAQ - Intelligent Video Analytics / DeepStream SDK - NVIDIA Developer Forums by yourself since you trained the model.

@Fiona.Chen If you want some additional information just let me know I’ll give you.
Please don’t say you don’t know something before asking about that.

@vino_mm We have listed all necessary parameters in DeepStream SDK FAQ - Intelligent Video Analytics / DeepStream SDK - NVIDIA Developer Forums, please check them one by one.

If there is any parameter you need us to explain, we can explain it.

@Fiona.Chen If you have an example for using a classification model as a primary model please share that.

How can I calculate the net-scale-factor and offsets if I’am using standard pytorch normalization?

Also is there a way to disable preprocessing steps in nvinfer plugin if I want to do the necessary things inside the model itself?

The classifier as primary model sample is NVIDIA-AI-IOT/deepstream_tao_apps: Sample apps to demonstrate how to deploy models trained with TAO on DeepStream (

Take our YoloV7 sample as the example, yolo_deepstream/deepstream_yolo at main · NVIDIA-AI-IOT/yolo_deepstream · GitHub
The YoloV7 model is from WongKinYiu/yolov7: Implementation of paper - YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors ( In the YoloV7 model sample code yolov7/ at main · WongKinYiu/yolov7 ( or yolov7/ at main · WongKinYiu/yolov7 (, we can get the normalization “net-scale-factor” is “1/255”, “offsets” are zeros.

If you are using torch.nn.functional.normalize — PyTorch 2.0 documentation, the formula has been listed in the page. The DeepStream normalization formula is in Gst-nvinfer — DeepStream 6.3 Release documentation, you can calculate by yourself.

What do you mean by the “the necessary things”? The preprocessing including scaling, format conversion and normalization, do you mean you want to do all these things in model? As far as I know, at least the input layer size is fixed( the “w” and “h”) while the input images can be any resolutions. How can the model accept the images of different resolutions and formats?

@Fiona.Chen By necessary things I meant input format conversion and normalization. Resizing/scaling I can set the required input size in nvstreammux only.

You can only disable normalization by setting offsets as zeros and setting “net-scale-factor” as 1.

@Fiona.Chen Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.