Skip to content

Change classic caffe models related tests and samples to onnx format#25548

Closed
WanliZhong wants to merge 9 commits intoopencv:5.xfrom
WanliZhong:simpleCaffeModel2onnx
Closed

Change classic caffe models related tests and samples to onnx format#25548
WanliZhong wants to merge 9 commits intoopencv:5.xfrom
WanliZhong:simpleCaffeModel2onnx

Conversation

@WanliZhong
Copy link
Copy Markdown
Member

@WanliZhong WanliZhong commented May 6, 2024

Merge with: opencv/opencv_extra#1175
Part of #25314

This PR aims to change the tests and samples related to alexnet, densenet, googlenet, squeezenet, resnet-50 models from caffe framework to onnx. Tests in test_int8_layer.cpp and test_caffe_importer.cpp will be removed in #25323

NOTE:

  • Removing the VGG sample in HTML because the model is too large to load in the browser. It's meaningless to add this.
    Error: RuntimeError: Out of bounds memory
  • SqueezeNet onnx from opencv_extra is V1 not V1.1, so I change the testname from V1_1to V1
  • May conflict with Improved classification sample #25519

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • 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

@WanliZhong WanliZhong added test category: samples category: dnn cleanup Code cleanup (e.g, drop legacy C-API, legacy unmaintained code) OpenCV5 labels May 6, 2024
@WanliZhong WanliZhong added this to the 5.0 milestone May 6, 2024
@WanliZhong WanliZhong requested review from asmorkalov and dkurt May 6, 2024 14:53
@WanliZhong WanliZhong changed the title Change simple caffe models related tests and samples to onnx format Change classic caffe models related tests and samples to onnx format May 6, 2024
@WanliZhong
Copy link
Copy Markdown
Member Author

If I missed some models. Please remind me.

@WanliZhong WanliZhong force-pushed the simpleCaffeModel2onnx branch from 1fc0bba to cfc083d Compare May 17, 2024 08:13
Comment on lines +158 to +171
class DNNOnnxModel(Framework):
net = object

def __init__(self, onnx_file, in_blob_name, out_blob_name):
self.net = cv.dnn.readNetFromONNX(onnx_file)
self.in_blob_name = in_blob_name
self.out_blob_name = out_blob_name

def get_name(self):
return 'DNN (ONNX)'

def get_output(self, input_blob):
self.net.setInput(input_blob, self.in_blob_name)
return self.net.forward(self.out_blob_name)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asmorkalov asmorkalov modified the milestones: 5.0, 5.0-release Sep 28, 2024
@asmorkalov asmorkalov closed this Mar 31, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in OpenCV 5.0 Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: dnn category: samples cleanup Code cleanup (e.g, drop legacy C-API, legacy unmaintained code) OpenCV5 test

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants