Code Monkey home page Code Monkey logo

object-detection-raspberry-pi's Introduction

Object-detection-raspberry-pi

install tensorflow and Object detection on raspberry pi

install tensorflow

TensorFlow:1.9
Python:3.5.3
Hardware: Raspberry 3B
install ibatlas-base-dev

sudo apt-get install libatlas-base-dev
Do you want to continue? [Y/n] input:Y

install tensorflow

sudo pip3 install  tensorflow

install other Dependent tools :numpy,tensorboard,markdown .....
in my case is tensorflow 1.9 so numpy version is 1.13.0,if numpy 1.16 or higher is not work

install Object detetion model

see https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

install opencv

see https://www.learnopencv.com/install-opencv-4-on-raspberry-pi/

Ubuntu VNC

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install tightvncserver
vncserver -geometry 800×800 :1

open Remote Desktop Viewer and Connect with you IP

Collecting Datasets via Raspberry Pi Camera

if use raspberrt pi camera: Because my video is reddish, so i change the white balance

from picamera import PiCamera
camera = PiCamera()
camera.awb_mode='off'
#change white balance 
camera.awb_gains=(1.0,1.2)
camera.resolution =(640 ,480)

if use usb camera:

import cv2
video = cv2.VideoCapture(0)

Use opencv Saving Video Frames

cap = cv2.VideoCapture("your video name")

Lable the ground truth

see https://github.com/tzutalin/labelImg save as xml file

XML file to CSV

see file XML file to CSV

CSV to TFCODE

see file CSV to TFCODE

Create a .pbtxt file/label map file

Create a train.pbtxt file in object_detection/data

item {
 id: 1
 name: 'car'
}

Change .configfile

Download model https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md
in my case ssd_mobilenet_v1_coco.config Items to modify in the .config:

  • model.ssd.num_classes
  • train_config.fine_tune_checkpoint
  • train_input_reader.label_map_path
  • train_input_reader.tf_record_input_reader
  • eval_input_reader.label_map_path
  • eval_input_reader.tf_record_input_reader

start to Train

cd research/object_detection

python3 model_main.py \
--pipeline_config_path=data/ssd_mobilenet_v1_coco.config \
--model_dir=data/training \
--num_train_steps=60000 \
--num_eval_steps=20 \
--alsologtostderr

Monitoring training

tensorboard --logdir=object_detection/data/training

Convert the checkpoint to frozen graph (.pb file)

cd research/object_detection

python3 export_inference_graph.py \
--input_type=image_tensor \
--pipeline_config_path=data/ssd_mobilenet_v1_coco.config \
--trained_checkpoint_prefix=data/training/model.ckpt-60000 \
--output_directory=data/training

Evaluation

see https://www.youtube.com/watch?v=rprKW1_TYhw&feature=youtu.be

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.