LoginSignup
24
22

More than 3 years have passed since last update.

物体検出のYOLOv5やーる(Windows10、Python3.6、PyTorch1.5.1)

Last updated at Posted at 2020-08-06

はじめに

物体検出のYOLOv5をやってみます。

開発環境

  • Windows10
  • Anaconda
  • Python 3.6
  • PyTorch 1.5.1

導入

1.ここからクローンします。

2.YOLOv5環境を作成します。

conda create -n yolov5 python=3.6
conda activate yolov5
cd yolov5

3.各ライブラリをインストールします。

先にPyTorchをインストールします。

pip install torch===1.5.1 torchvision===0.6.1 -f https://download.pytorch.org/whl/torch_stable.html

次にrequirements.txtからライブラリをインストールします。

pip install -U -r requirements.txt

実行

下記コマンドを実行し、ウェブカメラの映像を入力します。

python detect.py --source 0

SnapCameraなどにウェブカメラを占有される場合は、utils/datasets.pyのLoadStreamsクラス237行目の

cap = cv2.VideoCapture(0 if s == '0' else s)

の0のところを1などに変えてみてください。

cap = cv2.VideoCapture(1 if s == '0' else s)

ここから他のモデルをダウンロードし、下記の--weightsオプションでパスを指定し実行することも可能です。

python detect.py --source 0 --weights yolov5x.pt

各モデルの比較はこちらの記事YOLO V5(V3との比較有)を簡単サクッと試す!が参考になります。

スノボーとスケボー、認識できていてすごい!!

お疲れ様でした。

24
22
1

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
24
22