Skip to content

Python scripts for performing object detection with the 1000 labels of the ImageNet dataset in ONNX. The repository combines a class agnostic object localizer to first detect the objects in the image, and next a ResNet50 model trained on ImageNet is used to label each box.

License

ibaiGorordo/ONNX-ImageNet-1K-Object-Detector

Repository files navigation

ONNX-ImageNet-1K-Object-Detector

Python scripts for performing object detection with the 1000 labels of the ImageNet dataset in ONNX. The repository combines a class agnostic object localizer to first detect the objects in the image, and next a ResNet50 model trained on ImageNet is used to label each box.

Imagenet 1K Object Detection Original image: https://commons.wikimedia.org/wiki/File:Il_cuore_di_Como.jpg

Why

There are a lot of object detection models, but since most of them are trained in the COCO dataset, most of them can only detect a maximum of 80 classes. This repository proposes a "quick and dirty" solution to be able to detect the 1000 objects available in the ImageNet dataset.

❗Important❗

  • This model uses a lightweight class agnostic object localizer to first detect the objects. Therefore, this repository is not going to behave as well as other object detection models in complex scenes. In those cases, the object localizer will fail quickly and therefore no objects will be detected.
  • The ResNet50 clasifier is fast in a desktop GPU, however, since it needs to run for each of the detected boxes, the performance might be affected for images with many objects.

Requirements

  • Check the requirements.txt file.

Installation

pip install -r requirements.txt

ONNX model

  • Class Agnostic Object Localizer: The original model from TensorflowHub (link at the bottom) was converted to different formats (including .onnx) by PINTO0309, the models can be found in his repository. This repository will automatically download the model if the model is not found in the models folder.

  • ResNet50 Classifier: The original model from PaddleClas (link at the bottom) was converted to ONNX format using a similar procedure as the one described in this article by PINTO0309. This repository will automatically download the model.

How to use

  • Image inference:
python image_object_detection.py
  • Video inference:
python video_object_detection.py
  • Webcam inference:
python webcam_object_detection.py

Examples

Macaque Detection

Macaque Detection Original image: https://commons.wikimedia.org/wiki/File:Onsen_Monkey.JPG

Christmas Stocking Detection

Christmas Stocking Detection Original image: https://unsplash.com/photos/paSqTlm3DsA

Burrito Detection

Burrito Detection Original image: https://commons.wikimedia.org/wiki/File:Breakfast_burrito_(cropped).jpg

Bridge Detection

Bridge Detection Original image: https://commons.wikimedia.org/wiki/File:Bayonne_Bridge_Collins_Pk_jeh-2.JPG

[Inference video Example]

1k.detector.output_Trim.mp4

Original video: https://www.pexels.com/video/a-medusa-jellyfish-swimming-gracefully-underwater-2731905/ (by Vova Krasilnikov)

References

About

Python scripts for performing object detection with the 1000 labels of the ImageNet dataset in ONNX. The repository combines a class agnostic object localizer to first detect the objects in the image, and next a ResNet50 model trained on ImageNet is used to label each box.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages