古人智慧

Just Do it!
上士聞道,勤而行之;中士聞道,若存若亡;下士聞道,大笑之。不笑,不足以爲道。
~ 道德經 41

「實現夢想不是追逐成功,而是在於賦予生命意義,人生中的每個決定與聲音都有其重要含義。」"The key to realizing a dream is to focus not on success but on significance — and then even the small steps and little victories along your path will take on greater meaning."
電視名人-歐普拉·溫芙蕾(OPRAH WINFREY)

搜尋此網誌

Translation

2019年8月15日 星期四

[Object Detection by Tensorflow] 物件辨識

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
Refer to here
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
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')

That is and you will be ok for this practise

沒有留言:

張貼留言