Here is just do some note for how to setup and install the object detection by
Tensorflow
on Raspberry Pi 3B+
.
The original article here
Ok, let’s go my practise.
1. Update the Raspberry Pi
sudo apt update
sudo apt upgrade
sudo apt autoremove
2. Install Tensorflow, OpenCV and related Python modules
Refer to here
You should install this tool as well.
You should install this tool as well.
sudo apt install protobuf-compiler
3. Setup the Tensorflow models
mkdir tf_objectdetect
cd tf_objectdetect/
git clone https://github.com/tensorflow/models
Download/unzip the pre-trained model in this folder
wget http://download.tensorflow.org/models/object_detection/ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz
tar -xzvf ssdlite_mobilenet_v2_coco_2018_05_09.tar.gz
Copy this file
models\research\object_detection\data\mscoco_label_map.pbtxt
to data
folder.mkdir data
cp models/research/object_detection/data/mscoco_label_map.pbtxt data/.
compile the protos database
cd models/research/
protoc object_detection/protos/*.proto --python_out=.
cd models/research/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
It will be better that add this line to
.bashrc
# for tensorflow object detection
export PYTHONPATH=$PYTHONPATH:/home/pi/tf_objectdetect/models/research:/home/pi/tf_objectdetect/models/research/slim
4. Do the Object detection
Download the code, and test
cd ~/tf_objectdetect
wget https://raw.githubusercontent.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi/master/Object_detection_picamera.py
python3 Object_detection_picamera.py
You may got problems just like me, do some modify would be solved as below process.
nano Object_detection_picamera.py
nano Object_detection_picamera.py
Line 52
from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as vis_util
Line 66
PATH_TO_LABELS = os.path.join(CWD_PATH,'models/research/object_detection/data','mscoco_label_map.pbtxt')
沒有留言:
張貼留言