Code Monkey home page Code Monkey logo

Comments (3)

ofrimasad avatar ofrimasad commented on July 19, 2024 1

I am unfamiliar with this function, but the answer is that the ONNX produced by YOLO-NAS is just a basic ONNX, so it could be used by any framework supporting the layers used in YOLO-NAS.
Please note that the quantized ONNX is specific for TensorRT, so you need to create a basic ONNX.

from super-gradients.

BloodAxe avatar BloodAxe commented on July 19, 2024 1

YOLONAS supports native export to ONNX format:

from super_gradients.training import models
pretrained_model = models.get("yolo_nas_s", pretrained_weights="coco").cuda().eval()

dummy_input = torch.randn(1, 3, 640, 640).cuda()

yolo_model.prep_model_for_conversion(input_size=(640, 640))
torch.onnx.export(yolo_model, dummy_input, "yolo_nas_s.onnx", verbose=False, opset_version=13, do_constant_folding=True)

You can use generated ONNX file to load into TRT or ONNXRuntime as is.

Regarding OpenCV - I'm afraid you cannot use it "as is", due to some error inside ONNX parser on OpenCV side:

torch.onnx.export(yolo_model, dummy_input, "yolo_nas_s.onnx", verbose=False, opset_version=13, do_constant_folding=True)
>onnx_model = cv2.dnn.readNet("yolo_nas_s.onnx")
E           cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_importer.cpp:1073: error: (-2:Unspecified error) in function 'cv::dnn::dnn4_v20221220::ONNXImporter::handleNode'
E           > Node [[email protected]]:(onnx_node!/heads/Constant_11) parse error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\onnx\onnx_graph_simplifier.cpp:848: error: (-215:Assertion failed) !field.empty() in function 'cv::dnn::dnn4_v20221220::getMatFromTensor'

In theory, running model through onnxsim or lowering opset version during export can help, but we haven't tested this and leave this to community to figure out since ONNX support in OpenCV is beyond our control.

I hope this answers your question.

from super-gradients.

dagshub avatar dagshub commented on July 19, 2024

Join the discussion on DagsHub!

from super-gradients.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.