物体検出Yolov3を動かす♬～ハマった編～

最近、性能良いとうわさのYolov3が出てきたので、ちょっと試したいと思って試してみた。

ちょっと。。。以下のサイトにたくさん事例があり、ほとんど同じようなことが書いてあるので、簡単なんだろうと思っていた。
【参考】
[darknetでYOLOv3を動かしてみた。](https://qiita.com/nnn112358/items/746357a341ccf9ff6324)
[YOLOv2(Keras / TensorFlow)でディープラーニングによる画像の物体検出を行う](https://qiita.com/yampy/items/7a705acf4c6899bc11c7)
[【Darknet】リアルタイムオブジェクト認識 YOLOをTensorflowで試す](https://qiita.com/koji-t/items/a33bc8297c9a03b38c74)

###環境作成するよ。。。
[darknetでYOLOv3を動かしてみた。](https://qiita.com/nnn112358/items/746357a341ccf9ff6324)の記事のとおり、話を進める。
Ubuntuのようなので、以下を参考にWindows10（1060-3GB）にUbuntuを入れる。
[Ubuntu がマイクロソフト ストアにやってきた](http://www.vwnet.jp/Windows/w10/2017071402/UbuntuFromMSS.htm)
これはなんとなく再起動して動いた。
そして、「深層学習フレームワークdarknetをインストールする。」

```
git clone https://github.com/pjreddie/darknet.git
cd darknet
```
たぶん、ここはハマらずdarknetという一連のディレクトリができると思う。。。
※ウワンはここでも*ハマった様子①*のとおり、ハマりましたが。。。

そして、
「Makefileを修正し、GPUとOpenCVをOnにし、makeする。」
これは、viでMakefileを以下のように編集して、その後makeするという意味です。
※当たり前だけど、。。。少し、ハマりました

```
vi Makefile
```

viが無い。。。ということで、ここは単に編集すればいいので、jupyter notebookからMakefileを呼び出して以下の部分を編集しました。

```
変更前(Makefile)
GPU=0
CUDNN=0
OPENCV=0
OPENMP=0
DEBUG=0

変更後(Makefile)
GPU=1
CUDNN=0
OPENCV=1
OPENMP=0
DEBUG=0
```

そして、問題はmake。。。
※ここは*ハマった様子②*のようにすごくハマりました

```
make
```
無いです。。。

```
$ sudo apt install make
```
で入りましたが、gccが必要です。

```
$ sudo apt-get install gcc
```
そして、「YOLOv3の学習済みファイルをダウンロードする」

```
wget https://pjreddie.com/media/files/yolov3.weights
```
※ここでも実はハマってました。yolo.weightsというファイルもあって、こっちをダウンロードして以下実施するとweightsの読み込みエラーが出てthe endです

ということで、いよいよ「YOLOv3をテストする」

```
./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
```
※以下の*yolov3のネットワーク構造と実行結果*の通り、動きました

```
dog: 99%
truck: 92%
bicycle: 99%
```
![predictions.png](https://qiita-image-store.s3.amazonaws.com/0/233744/c8d5ee69-2af5-a047-fde0-f1482d10e535.png)

そして、以下yolov2の結果です。
yolov2.weightsをダウンロードして、

```
$ wget https://pjreddie.com/media/files/yolov2.weights
```
実行します。

```
$ ./darknet detect cfg/yolov2.cfg yolov2.weights data/dog.jpg
```

両者で精度はかなり異なりますね。。。

```
dog: 81%
truck: 74%
bicycle: 83%
```
![predictions.png](https://qiita-image-store.s3.amazonaws.com/0/233744/27211d12-0b7d-7645-0a91-9c729d1124f7.png)

めでたしめでたし。。。ですが、。。。
これは、C版です。。。ということで、python版動くかな？？

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet/python$ python3 darknet.py cfg/yolov3.cfg yolov3.weights data/dog.jpg
Traceback (most recent call last):
  File "darknet.py", line 48, in <module>
    lib = CDLL("libdarknet.so", RTLD_GLOBAL)
  File "/usr/lib/python3.5/ctypes/__init__.py", line 347, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libdarknet.so: cannot open shared object file: No such file or directory
```
"libdarknet.so"のファイルが見つかりません。。。
ここでも実はかなりハマりましたが、端折ります。。。

ということで、。。。以下の記事に乗り換えました。 
[【Darknet】リアルタイムオブジェクト認識 YOLOをTensorflowで試す](https://qiita.com/koji-t/items/a33bc8297c9a03b38c74)

これ。。。簡単に動くといいなぁ～
今日はここまでにいたしとうござります^^;

###まとめ
・今回は、噂のYolov3を動かしてみた
・環境構築にすごくハマった
・結果はYolov3はYolov2に比較するとネットワーク構造もディープになって、検出精度も格段に上がっていた
・Python版は動かなかった

以下種々ハマったところなど、参考です。
####ハマった様子①darknetの環境作るまで
前半、[YOLOv2(Keras / TensorFlow)でディープラーニングによる画像の物体検出を行う](https://qiita.com/yampy/items/7a705acf4c6899bc11c7)で環境構築を始めたので、その状況が入っています。。。

```
Microsoft Windows [Version 10.0.16299.371]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\user>sudo apt install git
'sudo' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\user>bash
Windows Subsystem for Linux には、インストールされたディストリビューションがありません。
ディストリビューションをインストールするには、次の Windows ストアを訪問してください:
https://aka.ms/wslstore
続行するには何かキーを押してください...

C:\Users\user>pip install numpy h5py pillow
Requirement already satisfied: numpy in c:\users\user\anaconda3\lib\site-packages
Requirement already satisfied: h5py in c:\users\user\anaconda3\lib\site-packages
Requirement already satisfied: pillow in c:\users\user\anaconda3\lib\site-packages
Requirement already satisfied: six in c:\users\user\anaconda3\lib\site-packages (from h5py)
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

C:\Users\user>bash
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ pip install numpy h5py pillow
The program 'pip' is currently not installed. You can install it by typing:
sudo apt install python-pip
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ sudo apt install python-pip
[sudo] password for MuAuan:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-pip
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ pip install numpy he5py pillow
The program 'pip' is currently not installed. You can install it by typing:
sudo apt install python-pip
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ sudo apt install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-pip
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ pip install keras
The program 'pip' is currently not installed. You can install it by typing:
sudo apt install python-pip
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ sudo apt install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-pip
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ wget http://pjreddie.com./media/files/yolo.weights
--2018-04-27 22:36:35--  http://pjreddie.com./media/files/yolo.weights
Resolving pjreddie.com. (pjreddie.com.)... 128.208.3.39
Connecting to pjreddie.com. (pjreddie.com.)|128.208.3.39|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://pjreddie.com/media/files/yolo.weights [following]
--2018-04-27 22:36:40--  https://pjreddie.com/media/files/yolo.weights
Resolving pjreddie.com (pjreddie.com)... 128.208.3.39
Connecting to pjreddie.com (pjreddie.com)|128.208.3.39|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 203934260 (194M) [application/octet-stream]
Saving to: ‘yolo.weights’

yolo.weights                  100%[=================================================>] 194.49M  5.22MB/s    in 43s

2018-04-27 22:37:24 (4.53 MB/s) - ‘yolo.weights’ saved [203934260/203934260]

MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ wget https://raw.githubusercontent.com/pjreddie/darknet/master/:cfg/yolo.cfg
--2018-04-27 22:38:20--  https://raw.githubusercontent.com/pjreddie/darknet/master/:cfg/yolo.cfg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.72.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.72.133|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-04-27 22:38:26 ERROR 404: Not Found.

MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ wget https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolo.cfg
--2018-04-27 22:38:41--  https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolo.cfg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.72.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.72.133|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-04-27 22:38:52 ERROR 404: Not Found.

MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ wget https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolo.cfg
--2018-04-27 22:40:38--  https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolo.cfg
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.72.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.72.133|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-04-27 22:40:43 ERROR 404: Not Found.

MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ ./yad2k.py yolo.cfg yolo.weights model_data/yolo.h5
-bash: ./yad2k.py: No such file or directory
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ logout

C:\Users\user>cd ./yad2k

C:\Users\user\yad2k>python keras_yolo.py
Using TensorFlow backend.
Traceback (most recent call last):
  File "keras_yolo.py", line 11, in <module>
    from ..utils import compose
SystemError: Parent module '' not loaded, cannot perform relative import

C:\Users\user\yad2k>python test_yolo.py
Using TensorFlow backend.
Traceback (most recent call last):
  File "test_yolo.py", line 14, in <module>
    from yad2k.models.keras_yolo import yolo_eval, yolo_head
  File "C:\Users\user\yad2k\yad2k.py", line 25, in <module>
    from yad2k.models.keras_yolo import (space_to_depth_x2,
ImportError: No module named 'yad2k.models'; 'yad2k' is not a package

C:\Users\user\yad2k>pip install yad2k.models
Collecting yad2k.models
  Could not find a version that satisfies the requirement yad2k.models (from versions: )
/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
    100% |################################| 1.3MB 1.1MB/s
Installing collected packages: pip
  Found existing installation: pip 9.0.3
    Uninstalling pip-9.0.3:
      Successfully uninstalled pip-9.0.3
Successfully installed pip-10.0.1

C:\Users\user\yad2k>pip install yad2k.models
Collecting yad2k.models
  Could not find a version that satisfies the requirement yad2k.models (from versions: )
No matching distribution found for yad2k.models

C:\Users\user\yad2k>cd ../

C:\Users\user>git clone https://github.com/pjreddie/darknet
'git' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\user>git clone https://github.com/pjreddie/darknet
'git' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\user>bash
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ git clone https://github.com/pjreddie/darknet
Cloning into 'darknet'...
remote: Counting objects: 5756, done.
remote: Total 5756 (delta 0), reused 0 (delta 0), pack-reused 5756
Receiving objects: 100% (5756/5756), 6.00 MiB | 2.62 MiB/s, done.
Resolving deltas: 100% (3854/3854), done.
Checking connectivity... done.
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user$ cd ./darknet
```
####ハマった様子②make編

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ make
The program 'make' can be found in the following packages:
 * make
 * make-guile
Try: sudo apt install <selected package>
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ sudo apt install make
[sudo] password for MuAuan:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'sudo apt autoremove' to remove it.
Suggested packages:
  make-doc
The following NEW packages will be installed:
  make
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 151 kB of archives.
After this operation, 365 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 make amd64 4.1-6 [151 kB]
Fetched 151 kB in 9s (15.8 kB/s)
Selecting previously unselected package make.
(Reading database ... 25532 files and directories currently installed.)
Preparing to unpack .../archives/make_4.1-6_amd64.deb ...
Unpacking make (4.1-6) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up make (4.1-6) ...
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ make
mkdir -p obj
mkdir -p results
gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/gemm.c -o obj/gemm.o
make: gcc: Command not found
Makefile:85: recipe for target 'obj/gemm.o' failed
make: *** [obj/gemm.o] Error 127
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$
```
なんとなく、makeがインストールできたみたいなので。。。

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ make Makefile
make: Nothing to be done for 'Makefile'.
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ make
gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/gemm.c -o obj/gemm.o
make: gcc: Command not found
Makefile:85: recipe for target 'obj/gemm.o' failed
make: *** [obj/gemm.o] Error 127
```
gccが無いと怒られました。。。

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ pip install gcc
The program 'pip' is currently not installed. You can install it by typing:
sudo apt install python-pip
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ sudo apt install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-pip
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ sudo apt install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-pip
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ sudo apt install gcc
```
あれ、gccが入りません。。。

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ sudo apt install gcc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  binutils cpp cpp-5 gcc-5 libasan2 libatomic1 libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libgcc-5-dev libgomp1
  libisl15 libitm1 liblsan0 libmpc3 libmpx0 libquadmath0 libtsan0 libubsan0 linux-libc-dev manpages-dev
Suggested packages:
。。。
```
入ったかな？？
でも、

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ make
gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/gemm.c -o obj/gemm.o
make: gcc: Command not found
Makefile:85: recipe for target 'obj/gemm.o' failed
make: *** [obj/gemm.o] Error 127
```
変わってないじゃない。。

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ pip install gcc
The program 'pip' is currently not installed. You can install it by typing:
sudo apt install python-pip
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ python
The program 'python' can be found in the following packages:
 * python-minimal
 * python3
Try: sudo apt install <selected package>
```
つまり、bash側にはpythonも入ってなかった？？

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ sudo apt install python
Reading package lists... Done
Building dependency tree
Reading state information... Done
。。。
minimal python2.7 python2.7-minimal
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,915 kB of archives.
After this operation, 16.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
```
python2.7が入りましたが、。。

```
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ run apt-get update
No command 'run' found, did you mean:
```
いや、入らなかったようです。

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ sudo apt-get update python
E: The update command takes no arguments
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ sudo apt-get update
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:4 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [481 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]
Get:6 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [7,532 kB]
。。。
```
なんとなく、ubuntuのアップデートできました。

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ make
gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/gemm.c -o obj/gemm.o
make: gcc: Command not found
Makefile:85: recipe for target 'obj/gemm.o' failed
make: *** [obj/gemm.o] Error 127
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ sudo apt-get install make
Reading package lists... Done
Building dependency tree
Reading state information... Done
make is already the newest version (4.1-6).
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 134 not upgraded.
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ sudo apt-get install python3
```
make入りません。。。いまどきpython3だよなぁ～

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ sudo apt-get install python3
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3 is already the newest version (3.5.1-3).
```
もうinstall済でした。

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ make
gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/gemm.c -o obj/gemm.o
make: gcc: Command not found
Makefile:85: recipe for target 'obj/gemm.o' failed
make: *** [obj/gemm.o] Error 127
```
makeは動きません。。。

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ sudo apt-get install gcc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
。。。
Setting up manpages-dev (4.04-2) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
```
なんとなく、gccが入りました。。。なんで入ったのかな？？

```
$ pip install gcc
$ sudo apt install gcc
$ sudo apt install gcc
$ sudo apt-get install gcc
```
つまり、コマンドが```$ sudo apt-get install gcc```でよかったんだろう
因みに、makeのインストールは以下のコマンドでやってました^^;

```
$ sudo apt install make
```

####yolov3のネットワーク構造と実行結果

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ ./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
layer     filters    size              input                output
    0 conv     32  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  32  0.299 BFLOPs
    1 conv     64  3 x 3 / 2   416 x 416 x  32   ->   208 x 208 x  64  1.595 BFLOPs
    2 conv     32  1 x 1 / 1   208 x 208 x  64   ->   208 x 208 x  32  0.177 BFLOPs
    3 conv     64  3 x 3 / 1   208 x 208 x  32   ->   208 x 208 x  64  1.595 BFLOPs
    4 res    1                 208 x 208 x  64   ->   208 x 208 x  64
    5 conv    128  3 x 3 / 2   208 x 208 x  64   ->   104 x 104 x 128  1.595 BFLOPs
    6 conv     64  1 x 1 / 1   104 x 104 x 128   ->   104 x 104 x  64  0.177 BFLOPs
    7 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128  1.595 BFLOPs
    8 res    5                 104 x 104 x 128   ->   104 x 104 x 128
    9 conv     64  1 x 1 / 1   104 x 104 x 128   ->   104 x 104 x  64  0.177 BFLOPs
   10 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128  1.595 BFLOPs
   11 res    8                 104 x 104 x 128   ->   104 x 104 x 128
   12 conv    256  3 x 3 / 2   104 x 104 x 128   ->    52 x  52 x 256  1.595 BFLOPs
   13 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128  0.177 BFLOPs
   14 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
   15 res   12                  52 x  52 x 256   ->    52 x  52 x 256
   16 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128  0.177 BFLOPs
   17 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
   18 res   15                  52 x  52 x 256   ->    52 x  52 x 256
   19 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128  0.177 BFLOPs
   20 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
   21 res   18                  52 x  52 x 256   ->    52 x  52 x 256
   22 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128  0.177 BFLOPs
   23 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
   24 res   21                  52 x  52 x 256   ->    52 x  52 x 256
   25 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128  0.177 BFLOPs
   26 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
   27 res   24                  52 x  52 x 256   ->    52 x  52 x 256
   28 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128  0.177 BFLOPs
   29 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
   30 res   27                  52 x  52 x 256   ->    52 x  52 x 256
   31 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128  0.177 BFLOPs
   32 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
   33 res   30                  52 x  52 x 256   ->    52 x  52 x 256
   34 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128  0.177 BFLOPs
   35 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
   36 res   33                  52 x  52 x 256   ->    52 x  52 x 256
   37 conv    512  3 x 3 / 2    52 x  52 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   38 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256  0.177 BFLOPs
   39 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   40 res   37                  26 x  26 x 512   ->    26 x  26 x 512
   41 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256  0.177 BFLOPs
   42 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   43 res   40                  26 x  26 x 512   ->    26 x  26 x 512
   44 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256  0.177 BFLOPs
   45 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   46 res   43                  26 x  26 x 512   ->    26 x  26 x 512
   47 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256  0.177 BFLOPs
   48 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   49 res   46                  26 x  26 x 512   ->    26 x  26 x 512
   50 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256  0.177 BFLOPs
   51 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   52 res   49                  26 x  26 x 512   ->    26 x  26 x 512
   53 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256  0.177 BFLOPs
   54 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   55 res   52                  26 x  26 x 512   ->    26 x  26 x 512
   56 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256  0.177 BFLOPs
   57 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   58 res   55                  26 x  26 x 512   ->    26 x  26 x 512
   59 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256  0.177 BFLOPs
   60 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   61 res   58                  26 x  26 x 512   ->    26 x  26 x 512
   62 conv   1024  3 x 3 / 2    26 x  26 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   63 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512  0.177 BFLOPs
   64 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   65 res   62                  13 x  13 x1024   ->    13 x  13 x1024
   66 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512  0.177 BFLOPs
   67 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   68 res   65                  13 x  13 x1024   ->    13 x  13 x1024
   69 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512  0.177 BFLOPs
   70 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   71 res   68                  13 x  13 x1024   ->    13 x  13 x1024
   72 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512  0.177 BFLOPs
   73 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   74 res   71                  13 x  13 x1024   ->    13 x  13 x1024
   75 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512  0.177 BFLOPs
   76 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   77 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512  0.177 BFLOPs
   78 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   79 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512  0.177 BFLOPs
   80 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   81 conv    255  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 255  0.088 BFLOPs
   82 detection
   83 route  79
   84 conv    256  1 x 1 / 1    13 x  13 x 512   ->    13 x  13 x 256  0.044 BFLOPs
   85 upsample            2x    13 x  13 x 256   ->    26 x  26 x 256
   86 route  85 61
   87 conv    256  1 x 1 / 1    26 x  26 x 768   ->    26 x  26 x 256  0.266 BFLOPs
   88 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   89 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256  0.177 BFLOPs
   90 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   91 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256  0.177 BFLOPs
   92 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   93 conv    255  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 255  0.177 BFLOPs
   94 detection
   95 route  91
   96 conv    128  1 x 1 / 1    26 x  26 x 256   ->    26 x  26 x 128  0.044 BFLOPs
   97 upsample            2x    26 x  26 x 128   ->    52 x  52 x 128
   98 route  97 36
   99 conv    128  1 x 1 / 1    52 x  52 x 384   ->    52 x  52 x 128  0.266 BFLOPs
  100 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
  101 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128  0.177 BFLOPs
  102 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
  103 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128  0.177 BFLOPs
  104 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
  105 conv    255  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 255  0.353 BFLOPs
  106 detection
Loading weights from yolov3.weights...Done!
data/dog.jpg: Predicted in 17.953083 seconds.
dog: 99%
truck: 92%
bicycle: 99%
```
Yolov2のネットワーク構造と実行結果です。

```
MuAuan@DESKTOP-S5LF5OV:/mnt/c/Users/user/darknet$ ./darknet detect cfg/yolov2.cfg yolov2.weights data/dog.jpg
layer     filters    size              input                output
    0 conv     32  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  32  0.299 BFLOPs
    1 max          2 x 2 / 2   416 x 416 x  32   ->   208 x 208 x  32
    2 conv     64  3 x 3 / 1   208 x 208 x  32   ->   208 x 208 x  64  1.595 BFLOPs
    3 max          2 x 2 / 2   208 x 208 x  64   ->   104 x 104 x  64
    4 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128  1.595 BFLOPs
    5 conv     64  1 x 1 / 1   104 x 104 x 128   ->   104 x 104 x  64  0.177 BFLOPs
    6 conv    128  3 x 3 / 1   104 x 104 x  64   ->   104 x 104 x 128  1.595 BFLOPs
    7 max          2 x 2 / 2   104 x 104 x 128   ->    52 x  52 x 128
    8 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
    9 conv    128  1 x 1 / 1    52 x  52 x 256   ->    52 x  52 x 128  0.177 BFLOPs
   10 conv    256  3 x 3 / 1    52 x  52 x 128   ->    52 x  52 x 256  1.595 BFLOPs
   11 max          2 x 2 / 2    52 x  52 x 256   ->    26 x  26 x 256
   12 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   13 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256  0.177 BFLOPs
   14 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   15 conv    256  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x 256  0.177 BFLOPs
   16 conv    512  3 x 3 / 1    26 x  26 x 256   ->    26 x  26 x 512  1.595 BFLOPs
   17 max          2 x 2 / 2    26 x  26 x 512   ->    13 x  13 x 512
   18 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   19 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512  0.177 BFLOPs
   20 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   21 conv    512  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 512  0.177 BFLOPs
   22 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
   23 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x1024  3.190 BFLOPs
   24 conv   1024  3 x 3 / 1    13 x  13 x1024   ->    13 x  13 x1024  3.190 BFLOPs
   25 route  16
   26 conv     64  1 x 1 / 1    26 x  26 x 512   ->    26 x  26 x  64  0.044 BFLOPs
   27 reorg              / 2    26 x  26 x  64   ->    13 x  13 x 256
   28 route  27 24
   29 conv   1024  3 x 3 / 1    13 x  13 x1280   ->    13 x  13 x1024  3.987 BFLOPs
   30 conv    425  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 425  0.147 BFLOPs
   31 detection
mask_scale: Using default '1.000000'
Loading weights from yolov2.weights...Done!
data/dog.jpg: Predicted in 8.946540 seconds.
dog: 81%
truck: 74%
bicycle: 83%
```