Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 9 commits into
base: 5.x
Choose a base branch
from

Conversation

WanliZhong
Copy link
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 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
Member Author

If I missed some models. Please remind me.

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
Member Author

Choose a reason for hiding this comment

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

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: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

1 participant