Home ONNX Object Localization Network
Post
Cancel

Open In GithubOpen In Github

Python scripts performing class agnostic object localization using the Object Localization Network model in ONNX.

!Object-Localization-Network Original image: https://en.wikipedia.org/wiki/File:Interior_design_865875.jpg

Important

  • I added a bit of logic to the box color selection to make it look nicer. Since it performs K-Means for each box, it might be slow. If you only care about speed, you can either set all the boxes to the same color or use random colors.

Requirements

  • Check the requirements.txt file.
  • For ONNX, if you have a NVIDIA GPU, then install the onnxruntime-gpu, otherwise use the onnxruntime library.
  • Additionally, pafy and youtube-dl are required for youtube video inference.

Installation

1
2
3
git clone https://github.com/ibaiGorordo/ONNX-Object-Localization-Network.git
cd ONNX-Object-Localization-Network
pip install -r requirements.txt

ONNX Runtime

For Nvidia GPU computers: pip install onnxruntime-gpu

Otherwise: pip install onnxruntime

For youtube video inference

1
2
pip install youtube_dl
pip install git+[https://github.com/zizo-pro/pafy@b8976f22c19e4ab5515cacbfae0a3970370c102b](https://github.com/zizo-pro/pafy@b8976f22c19e4ab5515cacbfae0a3970370c102b)

ONNX model

The original model was converted to ONNX by PINTO0309, download the models from the download script in his repository and save them into the models folder.

Pytorch model

The original Pytorch model can be found in this repository: https://github.com/mcahny/object_localization_network

Examples

  • Image inference:
    1
    
     python image_object_localization.py
    
  • Webcam inference:
    1
    
     python webcam_object_localization.py
    
  • Video inference: https://youtu.be/n9qhQJXYUWo
    1
    
     python video_object_localization.py
    

    !Object-Localization-Network video

Original video: https://youtu.be/vgJUXvkdS78

References:

This post is licensed under CC BY 4.0 by the author.