From e95c0055af7458fcf76561e74c629912df9baaa9 Mon Sep 17 00:00:00 2001 From: richard28039 <89371302+richard28039@users.noreply.github.com> Date: Fri, 3 Nov 2023 20:42:43 +0800 Subject: [PATCH] Merge pull request #24397 from richard28039:add_fcnresnet101_to_dnn_sample Added PyTorch fcnresnet101 segmentation conversion cases #24397 We write a sample code about transforming Pytorch fcnresnet101 to ONNX running on OpenCV. The input source image was shooted by ourself. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [X] I agree to contribute to the project under Apache 2 License. - [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake --- samples/dnn/models.yml | 12 ++++++++++++ samples/dnn/segmentation.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/samples/dnn/models.yml b/samples/dnn/models.yml index e645279605..c780bcb139 100644 --- a/samples/dnn/models.yml +++ b/samples/dnn/models.yml @@ -178,3 +178,15 @@ fcn8s: height: 500 rgb: false sample: "segmentation" + +fcnresnet101: + load_info: + url: "https://github.com/onnx/models/raw/fb8271d5d5d9b90dbb1eb5e8e40f8f580fb248b3/vision/object_detection_segmentation/fcn/model/fcn-resnet101-11.onnx" + sha1: "e7e76474bf6b73334ab32c4be1374c9e605f5aed" + model: "fcn-resnet101-11.onnx" + mean: [103.5, 116.2, 123.6] + scale: 0.019 + width: 500 + height: 500 + rgb: false + sample: "segmentation" diff --git a/samples/dnn/segmentation.py b/samples/dnn/segmentation.py index 09f3f8dd11..8e4e435225 100644 --- a/samples/dnn/segmentation.py +++ b/samples/dnn/segmentation.py @@ -14,7 +14,7 @@ parser = argparse.ArgumentParser(add_help=False) parser.add_argument('--zoo', default=os.path.join(os.path.dirname(os.path.abspath(__file__)), 'models.yml'), help='An optional path to file with preprocessing parameters.') parser.add_argument('--input', help='Path to input image or video file. Skip this argument to capture frames from a camera.') -parser.add_argument('--framework', choices=['caffe', 'tensorflow', 'torch', 'darknet'], +parser.add_argument('--framework', choices=['caffe', 'tensorflow', 'torch', 'darknet', 'onnx'], help='Optional name of an origin framework of the model. ' 'Detect it automatically if it does not set.') parser.add_argument('--colors', help='Optional path to a text file with colors for an every class. '