はじめに
リアルタイムの物体検出アルゴリズムであるYOLOv3の顔検出版であるYOLOFaceをやってみました。CPUでも動くよ。
システム環境
- Windows10(RTX2080 Max-Q、i7-8750H、RAM16GB)
- Anaconda 2020.02
- Python 3.6
導入
yolofaceをクローンします。
yoloface環境を作ります。
$ cd yoloface-master
$ conda create -n yoloface python=3.6
$ conda activate yoloface
$ pip install -r requirements.txt
yolov3-wider_16000.weightsをダウンロードし、model-weightsフォルダに置きます。
下記のコマンドを実行し、顔検出できるか確認しましょう。samplesフォルダに顔検出したいファイルを入れておきます。
- 画像の場合
$ python yoloface.py --image samples/outside_000001.jpg --output-dir outputs/
かなり精度いいですね!
- 動画の場合
$ python yoloface.py --video samples/hoshino.mp4 --output-dir outputs/
- ウェブカメラの場合(数値を変えることでカメラデバイスを切り替えられます)
$ python yoloface.py --src 1 --output-dir outputs/
リアルタイムに顔検出できました。
お疲れ様でした。