วันศุกร์ที่ 15 พฤษภาคม พ.ศ. 2563

Raspberry pi Pytorch Object Detection

Raspberry pi Pytorch Object Detection

Single Shot MultiBox Detector Implementation in Pytorch.

Software

  • Raspbien 10
  • Python 3.7.3
  • Torch 1.4.0
  • Torchvision 0.5

Pre-trained Model : MobileNetV2 SSD-Lite

Install on Raspberry pi


Dependency 
sudo apt install libopenblas-dev libblas-dev m4 cmake cython python3-dev python3-yaml python3-setuptools python3-wheel python3-pillow python3-numpy -y



git clone https://github.com/marcusvlc/pytorch-on-rpi.git

cd pytorch-on-rpi/

sudo pip3 install torch-1.4.0a0+7f73f1d-cp37-cp37m-linux_armv7l.whl

sudo pip3 install torchvision-0.5.0a0+85b8fbf-cp37-cp37m-linux_armv7l.whl


Change Filename
 Goto.  /usr/local/lib/python3.7/dist-packages/torch 

Change

_CXXXXXXXX.so   to  _C.so
_dlXXXXXXXX.so  to    _dl.so 


cd /usr/local/lib/python3.7/dist-packages/torch

sudo mv _C.cpython-37m-arm-linux-gnueabi.so _C.so

sudo mv _dl.cpython-37m-arm-linux-gnueabi.so _dl.so

Check Version.   Goto python3 shell

>>> import torch 
>>> torch.__version__

>>> import torchvision 
>>> torchvision.__version__
Source Code
git clone https://github.com/qfgaohao/pytorch-ssd.git


Pre-Trained Model  MobileNetV2 SSD-Lite )
cd pytorch-ssd/models

wget https://storage.googleapis.com/models-hao/mb2-ssd-lite-mp-0_686.pth

wget https://storage.googleapis.com/models-hao/voc-model-labels.txt


Run demo Code


For Image file 
python3 run_ssd_example.py mb2-ssd-lite models/mb2-ssd-lite-mp-0_686.pth models/voc-model-labels.txt your_image_file




Reference