1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

YOLOv5をJetson Nano2G(4G)で動かして、物体を検知するから応用まで その4

Last updated at Posted at 2021-10-10

[YOLOv5をJetson Nano2G(4G)で動かして、物体を検知するから応用まで その3]
(https://qiita.com/ShimoyamaAi/items/7e44d07bc4b98d7ee055)
の続きです

今回、いよいよYOLOv5に取り掛かり導入から実行を行います

###更新履歴
2021年10月 初版

##5.YOLOv5導入
まずはcloneします

git clone https://github.com/ultralytics/yolov5
cd yolov5

YOLOV5フォルダ内の
requirements.txt を編集します

# pip install -r requirements.txt

# Base ----------------------------------------
#matplotlib>=3.2.2
#numpy>=1.18.5
#opencv-python>=4.1.2
Pillow>=7.1.2
#PyYAML>=5.3.1
requests>=2.23.0
scipy>=1.4.1
#torch>=1.7.0
#torchvision>=0.8.1
#tqdm>=4.41.0

# Logging -------------------------------------
#tensorboard>=2.4.1
# wandb

# Plotting ------------------------------------
#pandas>=1.1.4
#seaborn>=0.11.0

# Export --------------------------------------
# coremltools>=4.1  # CoreML export
# onnx>=1.9.0  # ONNX export
# onnx-simplifier>=0.3.6  # ONNX simplifier
# scikit-learn==0.19.2  # CoreML quantization
# tensorflow>=2.4.1  # TFLite export
# tensorflowjs>=3.9.0  # TF.js export

# Extras --------------------------------------
# albumentations>=1.0.3
# Cython  # for pycocotools https://github.com/cocodataset/cocoapi/issues/172
# pycocotools>=2.0  # COCO mAP
# roboflow
#thop  # FLOPs computation

matplotlibをapt-getします

sudo apt-get install python3-matplotlib

ライブラリをインストールします

pip install -r requirements.txt

##6.YOLOv5実行

--source の後に対象を指定します

python detect.py --source 0  # webcam
                            file.jpg  # image 
                            file.mp4  # video
                            path/  # directory
                            path/*.jpg  # glob
                            'https://youtu.be/NUsoVlDFqZg'  # YouTube
                            'rtsp://example.com/media.mp4'  # RTSP, RTMP, HTTP stream

###参考 主な引数の詳細

    parser.add_argument('--weights', nargs='+', type=str, default=ROOT / 'yolov5s.pt', help='model path(s)')
    parser.add_argument('--source', type=str, default=ROOT / 'data/images', help='file/dir/URL/glob, 0 for webcam')
    parser.add_argument('--imgsz', '--img', '--img-size', nargs='+', type=int, default=[640], help='inference size h,w')
    parser.add_argument('--conf-thres', type=float, default=0.25, help='confidence threshold')
    parser.add_argument('--iou-thres', type=float, default=0.45, help='NMS IoU threshold')
    parser.add_argument('--view-img', action='store_true', help='show results')
    parser.add_argument('--save-txt', action='store_true', help='save results to *.txt')
    parser.add_argument('--save-conf', action='store_true', help='save confidences in --save-txt labels')
    parser.add_argument('--save-crop', action='store_true', help='save cropped prediction boxes')
    parser.add_argument('--nosave', action='store_true', help='do not save images/videos')
    parser.add_argument('--classes', nargs='+', type=int, help='filter by class: --classes 0, or --classes 0 2 3')
    parser.add_argument('--agnostic-nms', action='store_true', help='class-agnostic NMS')
    parser.add_argument('--augment', action='store_true', help='augmented inference')
    parser.add_argument('--visualize', action='store_true', help='visualize features')
    parser.add_argument('--update', action='store_true', help='update all models')
    parser.add_argument('--project', default=ROOT / 'runs/detect', help='save results to project/name')
    parser.add_argument('--name', default='exp', help='save results to project/name')
    parser.add_argument('--exist-ok', action='store_true', help='existing project/name ok, do not increment')

どうでしょうか?
実際に動くところは確認できましたか?

[次は、人物トラッキングをJetson Nanoで行います]
(https://qiita.com/ShimoyamaAi/items/e4f90d58da7fea3cd43e)

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?