Skip to content
🐍 Run Object Detection Inferences in Python
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

Object Detection Python Examples

Run your models trained using Cloud Annotations with python.

Tflite Object Detection

Currently, supports using Mobilenet-V1 SSD models trained using Cloud Annotations.


Summary Information

Image 7 of 9.
Inference time: 0.15027356147766113
Inference Summary:
Highest Score: 0.9407029747962952
Highest Scoring Box: [0.60926155 0.47011317 0.67576766 0.56898813]
Image shape: (563, 1000, 3)
Boxes shape: (1917, 4)
Classes shape: (1917,)
Scores shape: (1917,)
['plate: 94%']
Image Saved

Saved Image:

alt text

Perform object detection with your model

Note: to find a list of all models trained do:

cacli list

To use a custom model, perform

cacli download <model_name>

For example, if the downloaded files were saved to /path/to/<model_name> :

  • Our tflite model is stored in <model_name>/model_android/model.tflite
  • Our tflite anchors file is stored in <model_name>/model_android/anchors.json
  • Our tflite labels file is stored in <model_name>/model_android/labels.json
cd examples/tflite_interpreter/basic/
python --MODEL_DIR /path/to/<model_name>/model_android

This script calls the tflite model interpreter for inference on all .jpg files inside the directory PATH_TO_TEST_IMAGES_DIR.

Similary the output .jpg files are storesd in PATH_TO_OUTPUT_DIR.

We can also specify the minimum confidence (score) for a given detection box to be displayed with MINIMUM_CONFIDENCE.


python \
--MODEL_DIR /path/to/<model_name>/model_android \
--PATH_TO_TEST_IMAGES_DIR /path/to/test/images \
--PATH_TO_OUTPUT_DIR /path/to/output/images \

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites and installing

Install the required packages in requirement.txt

Creating a new virtual environement is recommended.

conda create -n object_detection python=3.7
conda activate object_detection

Git clone the repo and change directory into it. Then pip install the packages in requirement.txt.

cd directory/you/want/to/clone/into
git clone
cd object-detection-python
pip install -r requirement.txt

Test if everything is working

I have supplied a test model and some test images. This should output the images with detection boxes and labels in jpg format in 'examples/tflite_interpreter/basic/model/output'

cd examples/tflite_interpreter/basic/


This project is licensed under the MIT License - see the file for details.

You can’t perform that action at this time.