LoginSignup
5
2

More than 3 years have passed since last update.

Jetson nanoでyolov3,yolov3-tinyを動かすメモ

Last updated at Posted at 2019-08-18

kerasのインストール

sudo apt install libatlas-base-dev gfortran
sudo pip3 install scipy
sudo pip3 keras

keras-yolo3リポジトリ

git clone https://github.com/qqwweee/keras-yolo3

weights

YOLOv3

wget https://pjreddie.com/media/files/yolov3.weights

YOLOv3-tiny

wget https://pjreddie.com/media/files/yolov3-tiny.weights

weightsのコンバート

YOLOv3

python3 convert.py yolov3.cfg yolov3.weights model_data/yolo.h5

YOLOv3-tiny

python3 convert.py yolov3-tiny.cfg yolov3-tiny.weights model_data/yolo-tiny.h5

カメラ入力部分の修正※Raspberry Pi Camera Moduleの場合

yolo.py
def detect_video(yolo, video_path, output_path=""):
    import cv2
    GST_STR = 'nvarguscamerasrc \
    ! video/x-raw(memory:NVMM), width=3280, height=2464, format=(string)NV12, framerate=(fraction)30/1 \
    ! nvvidconv ! video/x-raw, width=(int)416, height=(int)416, format=(string)BGRx \
    ! videoconvert \
    ! appsink'
    WINDOW_NAME = 'Camera Test'
    vid = cv2.VideoCapture(GST_STR, cv2.CAP_GSTREAMER)
#    if video_path.isdigit():
#        video_path = int(video_path)
#    vid = cv2.VideoCapture(video_path)
    if not vid.isOpened():

※USBカメラの場合はvid = cv2.VideoCapture(0)

parser文字列の修正(3ヶ所)

yolo_video.py
#    '--model', type=str,
    '--model_path', type=str,

#    '--anchors', type=str,
    '--anchors_path', type=str,

#    '--classes', type=str,
    '--classes_path', type=str,

実行 ※GUI環境

YOLOv3 FPS=1 ※重くてvideo出力がハングアップ状態になることがある

python3 yolo_video.py

YOLOv3-tiny FPS=4

python3 yolo_video.py --model_path model_data/yolo-tiny.h5 --anchors_path model_data/tiny_yolo_anchors.txt

その他

「importerror: The _imagingft C module is no installed」の対処

sudo apt-get install libfreetype6
sudo apt-get install libfreetype6-dev
sudo pip3 uninstall Pillow
sudo pip3 install Pillow
5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2