opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
75.69k stars 55.61k forks source link

Can't get useful results with segmentation sample. #25434

Closed WanliZhong closed 2 weeks ago

WanliZhong commented 2 weeks ago

System Information

OpenCV version: 4.9.0.80 Operating System / Platform: MacOS 14.4.1

Detailed description

I got results:

src: 000000017968

BTW: the model file use different scale and rgb channel with the original document form onnx model zoo

The images must be loaded in RGB with a range of [0, 1] per channel, then normalized per-image using mean = [0.485, 0.456, 0.406] and std = [0.229, 0.224, 0.225].

https://github.com/opencv/opencv/blob/05a54b1405bdd7ef5d7cf3d3215332cac50f0416/samples/dnn/models.yml#L272-L282 relate PR: https://github.com/opencv/opencv/pull/24397

Steps to reproduce

Just use the sample in https://github.com/opencv/opencv/blob/4.x/samples/dnn/segmentation.py

python segmentation.py --model path/to./fcn-resnet101-11.onnx --input path/to/dog_orig_size.png

Issue submission checklist

WanliZhong commented 2 weeks ago

I should config the model, my mistake. But the preprocess parameters are still different from the official doc. Should it change?

The images must be loaded in RGB with a range of [0, 1] per channel, then normalized per-image using mean = [0.485, 0.456, 0.406] and std = [0.229, 0.224, 0.225].