Web-cam Object detection with TensorFlow

DaurEd
2 min readFeb 10, 2021

This blog is intended to simply understand how to use a web cam and use pre-trained models on a video stream for the ‘out-of-box’ inference.

Installation list :

  1. Tensorflow Installation
  2. Tensorflow Object Detection API Installation
  3. Steps for organizing the data and download pre-trained models

The hyper-links has detailed instructions to installations. However I would just like to post some of the additional commands I had to run on windows10 while following the documentation. Hoping it would help when you go through the installations by yourself.

A. When in COCO API Installation section:

The command ‘pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI’ didn’t work as git was not installed. Simply, run ‘conda install git’. And re-try.

B. While installing Object Detection API:

Instead of ‘cp object_detection/packages/tf2/setup.py .’ as stated in the documentation, use the folllwing with two changes: copy instaed of cp & backslash instead of forward slash.

copy object_detection\packages\tf2\setup.py .

This command is simply meant to copy the setup.py file to the research folder.

C. I recommend downloading the Object_detection_camera.py file from here instead of running snippets of code from the page. Don’t worry, It won’t create the data folder multiple times.

The data folder is created when you run: python object_detection_camera.py
You can choose any model as instructed here.

Only two parameters are to be changed to test the different models in the above python file:

# Download and extract model
MODEL_DATE = ‘20200711’
MODEL_NAME = ‘efficientdet_d7_coco17_tpu-32’

Trust me, its my puppy & not a teddy bear.

Writer: Piyush Kulkarni (Data Scientist)

--

--

DaurEd

Our objective is to be valued leader in providing quality, affordable instruction in studies via practical training, workshops, & experimental learning.