Skip to content

ONNX and Pytorch model don't make same mask weight in yolov5-seg #11144

Closed
@hsysfan

Description

@hsysfan

Search before asking

Question

Hi, i have some questions on yolov5-seg model

first, i coded the algorithm for segmentation inference on C# OnnxRuntime

i made the image to tensor and insert the tensor to loaded model in Pytorch(Python) and OnnxRuntime(C#) for proof

i know output[1] has [1,32,160,160] as 32 masks information. So i coded the algorithm is process_mask in yolov5 to C#

In the way, i found model throw different result. please watch the images

image

the left is onnxruntime mask after process_mask algorithm and the right one is pytorch result.

there are some differences pixel values. maybe 0% ~ 20% difference

i checked the masks_in [1,32] <- i think this is weight per mask

<style> </style>
PyTorch 0.14222 -0.64795 0.34971 0.37515 0.74815 -0.25121 -0.9901 -0.71582 -0.09188 -0.7556 0.17439 0.06452 -0.94477 0.09694 0.7804 0.21439 0.18145 -0.60947 -0.04956 0.15793 -0.17822 -0.78358 0.54038 -0.07782 -0.51345 0.35098 -0.32386 -0.12711 0.06213 0.15394 -0.60719 -1.26161
C# 0.1513574 -0.65539 0.355499 0.378068 0.756042 -0.23867 -0.96947 -0.71049 -0.07348 -0.7692 0.196966 0.087532 -0.94167 0.080687 0.766626 0.186181 0.161458 -0.59977 -0.05438 0.15459 -0.18784 -0.79042 0.561843 -0.05658 -0.52831 0.362876 -0.31567 -0.11423 0.080159 0.16219 -0.58261 -1.263
Difference Rate(%) 6.03696945 1.135081 1.628305 0.771766 1.04387 5.253587 2.127851 0.749605 25.03916 1.768211 11.46192 26.29017 0.329692 20.14317 1.796651 15.15169 12.38252 1.616948 8.869921 2.160884 5.123703 0.865902 3.820038 37.53892 2.812743 3.278175 2.593572 11.27559 22.49123 5.086393 4.219429 0.110055424

these are weights in mask information [1,32], upper is pytorch the below is onnxruntime.

i checked all my codes, but i cant find difference on algorithm.

could you explain why the results have difference weights?

thanks for reading

Additional

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions