LoginSignup
2
3

More than 3 years have passed since last update.

windowsのGPUでYOLOv3(TensorFlow 2.1)で物体検出をやってみた!

Last updated at Posted at 2020-05-06

環境

windows7 64bit
Gefore GTX 680MX GPU
anaconda

1.CUDAインストール

下記サイトからCUDA Toolkit 10.1 update2バージョンをダウンロードする
(TensorFlow2.1.0対応しているのはCUDA Toolkit 10.1のため)
https://developer.nvidia.com/cuda-toolkit-archive

インストール場合、Visual Studio Intergrationを選択しないでください

インストール成功の場合、nvcc -V実行すると、下記結果が表示される

C:\Windows\System32>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:12:52_Pacific_Daylight_Time_2019
Cuda compilation tools, release 10.1, V10.1.243

2.cuDNNインストール

下記サイトからcuDNN for CUDA 10.1を選択してダウンロードする
(NVIDIA account必要)
https://developer.nvidia.com/cudnn

zipファイルを解凍し、
cudaフォルダをcuda765にrenameし、
「C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1」のパスにコピーする

コピー後
1.JPG

3. 環境変数設定

PATHに下記cuDNNパス追加

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\cuda765\bin

4. condaでkeras_work作成

conda create -n keras_work
activate keras_work

5. tensoflowのインストール

conda install tensorflow

6.確認

(base) C:\Users\mac>activate keras_work

(keras_work) C:\Users\mac>python
Python 3.7.7 (default, Apr 15 2020, 05:09:04) [MSC v.1916 64 bit (AMD64)] :: Ana
conda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-05-06 19:46:04.480481: I tensorflow/stream_executor/platform/default/dso_lo
ader.cc:44] Successfully opened dynamic library cudart64_101.dll
>>> print(tf.__version__)
2.1.0
>>> print(tf.test.is_gpu_available())
・・・
physical GPU (device: 0, name: GeForce GTX 680MX, pci bus id: 0000:01:00.0, compute capability: 3.0)
True

7.YOLOV3資材準備

Githubからソース取得

cd c:\temp
git clone https://github.com/zzh8829/yolov3-tf2.git
cd yolov3-tf2

pjreddie.comからyolo3.weightをダウンロード
※2時間かかる

wget https://pjreddie.com/media/files/yolov3.weights --no-check-certificate

上記pjreddie.comからyolov3.weights取得のは遅いのため、下記URLもダウンロードできる
https://pan.baidu.com/s/1G2Qh-V8kyLOq4oDbTwK6HQ
提取码(パスワード):vogw
ファイルは「yolo_tf2.1\data\yolov3.weights」

yolo3.weightファイルをyolov3-tf2パスに移動
ファイル移動したことを確認

(keras_work) C:\temp\yolov3-tf2>dir /B *.weights
yolov3.weights

8.変換(事前トレーニング済みのdarknet weightを変換する)

python convert.py --weights ./yolov3.weights --output ./checkpoints/yolov3.tf

9.確認(detection)

python detect.py --image ./data/street.jpg

output.jpg

2
3
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
2
3