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
see https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md
see https://www.learnopencv.com/install-opencv-4-on-raspberry-pi/
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
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)
cap = cv2.VideoCapture("your video name")
see https://github.com/tzutalin/labelImg
save as xml file
see file XML file to CSV
see file CSV to TFCODE
Create a train.pbtxt
file in object_detection/data
item {
id: 1
name: 'car'
}
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
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
tensorboard --logdir=object_detection/data/training
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
see https://www.youtube.com/watch?v=rprKW1_TYhw&feature=youtu.be