Code Monkey home page Code Monkey logo

onnx-inference-yolo's Introduction

onnx-inference-yolo

ONNX inference pipeline for YOLO Object Detection Model

Working with ML models there a lot of different frameworks to train and execute models, potential compilers to improve runtime of interences and the story goes on. When it comes to inference runtime optimization (including optimization of some potentially very costly pre-processing) the hardware architectures on which the models are deployed makes a significant difference.

Often there is need for interoperability between these different tools. E.g. when training a model with algorithm A in framework X you are often locked into the eco-system of that framework which might not have the best prediction accuracy, lowest execution runtime or better other “quality attributes” than when training a model with the same algorithm A but a different framework Y. Furthermore, it could be a completely different story for a different algorithm. The reason for this is that the low level implementation of the algorithms differ or that they use a slightly different set of operators. Additionally, the choice of framework could also be based on the development experience with framework Y which might be way better than the one provided by framework X!

ONNX to the rescue! This repository contains scripts to perform inference on a YOLO-v7 object detection model using just a .onnx file. It takes an object oriented approach (pun un-intended) to perform object detection on provided images. Any YOLO model in onnx format can be used for inference. A couple of them are provided below. Use the dynamic batch checkpoint for working with > 1 image per batch.

yolov7-tiny.onnx yolov7-tiny-dynamic-batch.onnx

TODOs

  • Upload a couple of onnx weights
  • Add annotation script
  • Fix input/output paths and model path using argparser
  • Add inference for segmentation
  • Improve docstrings

onnx-inference-yolo's People

Contributors

anweshcr7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ganbayard

onnx-inference-yolo's Issues

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Got this error:

Traceback (most recent call last):
  File "/Users/oleoyl/Dropbox/Development/Clients/K/Projects/classifier/yolov8/onnx-inference-yolo-main/inference_script.py", line 37, in <module>
    batch.init_detected_objects(raw_out)
  File "/Users/oleoyl/Dropbox/Development/Clients/K/Projects/classifier/yolov8/onnx-inference-yolo-main/data_models/images_input.py", line 175, in init_detected_objects
    predictions_for_batch_id = [i for i in predictions if i[0] == batch_id]
  File "/Users/oleoyl/Dropbox/Development/Clients/K/Projects/classifier/yolov8/onnx-inference-yolo-main/data_models/images_input.py", line 175, in <listcomp>
    predictions_for_batch_id = [i for i in predictions if i[0] == batch_id]
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

How can I fix it?

Pydantic Version?

I am having error in running" inference_script.py" code:

from data_models.onnx_object_detection import OnnxObjectDetection

from pydantic.class_validators import List
ImportError: cannot import name 'List' from 'pydantic.class_validators' 

I guess it is Pydantic version problem. My Pydantic is version 2.4.0. What version should I use?

I couldn't find solution in Google.

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.