Giter Club home page Giter Club logo

yolo-nas-onnx's Introduction

YOLO-NAS ONNX

sample

Image Source: https://www.pinterest.com/pin/784752303797219490/


love onnxruntime-web opencv python c++ javascript

Run YOLO-NAS models with ONNX without using Pytorch. Inferencing YOLO-NAS ONNX models with ONNXRUNTIME or OpenCV DNN.

Generate ONNX Model

Generate YOLO-NAS ONNX model without preprocessing and postprocessing within the model. You can convert the model using the following code after installing super_gradients library.

Example: Exporting YOLO-NAS S

from super_gradients.training import models
from super_gradients.common.object_names import Models

model = models.get(Models.YOLO_NAS_S, pretrained_weights="coco")

model.eval()
model.prep_model_for_conversion(input_size=[1, 3, 640, 640])
model.export("yolo_nas_s.onnx", postprocessing=None, preprocessing=None)

Custom Model

To run custom trained YOLO-NAS model in this project you need to generate custom model metadata. Custom model metadata generated from custom-nas-model-metadata.py to provide additional information from torch model.

Usage

python custom-nas-model-metadata.py -m <CHECKPOINT-PATH> \ # Custom trained YOLO-NAS checkpoint path
                                        -t <MODEL-TYPE> \ # Custom trained YOLO-NAS model type
                                        -n <NUM-CLASSES> # Number of classes

After running that it'll generate metadata (json formated) for you

References

yolo-nas-onnx's People

Contributors

hyuto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

yolo-nas-onnx's Issues

custom-dataset onnx

when i use default coco dataset and convert it into ONNX, after inference i will get true detect result
but when i use custom dataset , convert yolo-nas train weight "pth" into ONNX, after inference i can't get true detect result
so have u tried custom dataset ONNX on your code and the results?
thanks for answering!!!

License

Can you add a license to this repo?

Great work, BTW. I learnt a lot from this repo.

Feature: import int8 model

There is an option to use converted via tensorRt to int8 model?
Or there is other option to quantization to int8?

BTW: grate job and thank for sharing this code :)

YoloNAS with dynamic input shape

I'm not able to convert the model to onnx with dynamic input shape.

from super_gradients.training import models
net = models.get("yolo_nas_s", pretrained_weights="coco")
models.convert_to_onnx(model=net, input_shape=(3,640,640), out_path="yolo_nas_s.onnx")

Is there any flag I can put in the above code?

I tried to convert using the ultralytics package, but without success. Only works with yolov8.

yolo task=detect mode=export model=yolo_nas_s.pt format=onnx dynamic=True

The console stream is logged into /root/sg_logs/console.log
[2023-09-08 04:54:41] INFO - crash_tips_setup.py - Crash tips is enabled. You can set your environment variable to CRASH_HANDLER=FALSE to disable it
Traceback (most recent call last):
  File "/usr/local/bin/yolo", line 8, in <module>
    sys.exit(entrypoint())
  File "/usr/local/lib/python3.8/dist-packages/ultralytics/cfg/__init__.py", line 420, in entrypoint
    model = YOLO(model, task=task)
  File "/usr/local/lib/python3.8/dist-packages/ultralytics/engine/model.py", line 92, in __init__
    self._load(model, task)
  File "/usr/local/lib/python3.8/dist-packages/ultralytics/engine/model.py", line 138, in _load
    self.model, self.ckpt = attempt_load_one_weight(weights)
  File "/usr/local/lib/python3.8/dist-packages/ultralytics/nn/tasks.py", line 589, in attempt_load_one_weight
    args = {**DEFAULT_CFG_DICT, **(ckpt.get('train_args', {}))}  # combine model and default args, preferring model args
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1614, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'YoloNAS_S' object has no attribute 'get'

Regards,
Kevin

v8 vs nas

When performing inference on the web using onnx runtime, do you recommend yolov8 or yolo nas? In your experience, which is faster? Which is more accurate? Also, are you using int8 quantization for yolo nas?

C++ Version crash

Hi!, Thanks for your help, I have a problem using custom model, on python version all works, but on c++ version i get

handleNode DNN/ONNX: ERROR during processing node with 2 inputs and 1 outputs: [Squeeze]:(/model/heads/Squeeze_output_0)

I already get metadata, but i cant fix this

Batch mode

Hello!

Is it possible to easily adapt the code to work in batch mode (one input with multiple images)? Perhaps we also need to modify the process of generating the ONNX model?

Thank you!

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.