1
3

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 5 years have passed since last update.

Training-Time-Friendly Network for Real-Time Object Detection の windows10 での実行

Last updated at Posted at 2019-10-06

はじめに

 BiSeNetとLEDNetもinferenceはできたのですが、Trainingがちょっとあって停滞していて、先にこの、"Training-Time-Friendly Network for Real-Time Object Detection"の記事を書こうと思います。CenterNetやCornerNet-LiteはInferenceは速いのですが、Trainingははっきり言ってしんどいので、よほど強力なGPUがないとやってられません。
 その点、これは非常に短い時間でそれなりのTrainingができるので、独自のデータを学習させたり、COCOのカテゴリを減らしたらmAPがどう変わるかなどといったTrainingにかかわるいろいろなことが個人所有のPCやGPUで出来そうなので、有意義だと思いました。
#0.注意
ディレクトリ名が途中でttfnet2,mmdetection2となったり、仮想環境がopen-mmlab2となるのは、いったん作った環境ではなく、再度この記事のために作ったためにこうなっています。皆さんは*2ではなく、2がついていないと思ってやってください。

#1.準備
 INSTALL.mdの通りなのですが、Windows10なので適当に躓きます。

(base) F:\Users\sounansu\Anaconda3>conda create -n open-mmlab python=3.7 -y
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: F:\Users\sounansu\Anaconda3\envs\open-mmlab

  added / updated specs:
    - python=3.7


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ca-certificates-2019.8.28  |                0         165 KB
    certifi-2019.9.11          |           py37_0         155 KB
    pip-19.2.2                 |           py37_0         1.7 MB
    python-3.7.4               |       h5263a28_0        14.7 MB
    setuptools-41.2.0          |           py37_0         665 KB
    sqlite-3.29.0              |       he774522_0         624 KB
    vc-14.1                    |       h0510ff6_4           6 KB
    wheel-0.33.6               |           py37_0          58 KB
    wincertstore-0.2           |           py37_0          14 KB
    ------------------------------------------------------------
                                           Total:        18.0 MB

The following NEW packages will be INSTALLED:

  ca-certificates    pkgs/main/win-64::ca-certificates-2019.8.28-0
  certifi            pkgs/main/win-64::certifi-2019.9.11-py37_0
  openssl            pkgs/main/win-64::openssl-1.1.1d-he774522_0
  pip                pkgs/main/win-64::pip-19.2.2-py37_0
  python             pkgs/main/win-64::python-3.7.4-h5263a28_0
  setuptools         pkgs/main/win-64::setuptools-41.2.0-py37_0
  sqlite             pkgs/main/win-64::sqlite-3.29.0-he774522_0
  vc                 pkgs/main/win-64::vc-14.1-h0510ff6_4
  vs2015_runtime     pkgs/main/win-64::vs2015_runtime-14.16.27012-hf0eaf9b_0
  wheel              pkgs/main/win-64::wheel-0.33.6-py37_0
  wincertstore       pkgs/main/win-64::wincertstore-0.2-py37_0



Downloading and Extracting Packages
python-3.7.4         | 14.7 MB   | ################################################################################################################## | 100%
certifi-2019.9.11    | 155 KB    | ################################################################################################################## | 100%
ca-certificates-2019 | 165 KB    | ################################################################################################################## | 100%
sqlite-3.29.0        | 624 KB    | ################################################################################################################## | 100%
wincertstore-0.2     | 14 KB     | ################################################################################################################## | 100%
setuptools-41.2.0    | 665 KB    | ################################################################################################################## | 100%
wheel-0.33.6         | 58 KB     | ################################################################################################################## | 100%
vc-14.1              | 6 KB      | ################################################################################################################## | 100%
pip-19.2.2           | 1.7 MB    | ################################################################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate open-mmlab
#
# To deactivate an active environment, use
#
#     $ conda deactivate

(base) F:\Users\sounansu\Anaconda3>conda activate open-mmlab

(open-mmlab) F:\Users\sounansu\Anaconda3>conda install cython
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: F:\Users\sounansu\Anaconda3\envs\open-mmlab

  added / updated specs:
    - cython


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    cython-0.29.13             |   py37ha925a31_0         1.8 MB
    ------------------------------------------------------------
                                           Total:         1.8 MB

The following NEW packages will be INSTALLED:

  cython             pkgs/main/win-64::cython-0.29.13-py37ha925a31_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
cython-0.29.13       | 1.8 MB    | ################################################################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(open-mmlab) F:\Users\sounansu\Anaconda3>conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: F:\Users\sounansu\Anaconda3\envs\open-mmlab

  added / updated specs:
    - cudatoolkit=10.0
    - pytorch
    - torchvision


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    blas-1.0                   |              mkl           6 KB
    mkl_fft-1.0.14             |   py37h14836fe_0         118 KB
    mkl_random-1.0.2           |   py37h343c172_0         272 KB
    ninja-1.9.0                |   py37h74a9793_0         238 KB
    numpy-1.16.5               |   py37h19fb1c0_0          50 KB
    olefile-0.46               |           py37_0          49 KB
    pillow-6.1.0               |   py37hdc69c19_0         636 KB
    pycparser-2.19             |           py37_0         170 KB
    pytorch-1.2.0              |py3.7_cuda100_cudnn7_1       479.3 MB  pytorch
    six-1.12.0                 |           py37_0          23 KB
    torchvision-0.4.0          |       py37_cu100         2.3 MB  pytorch
    ------------------------------------------------------------
                                           Total:       483.1 MB

The following NEW packages will be INSTALLED:

  blas               pkgs/main/win-64::blas-1.0-mkl
  cffi               pkgs/main/win-64::cffi-1.12.3-py37h7a1dbc1_0
  cudatoolkit        pkgs/main/win-64::cudatoolkit-10.0.130-0
  freetype           pkgs/main/win-64::freetype-2.9.1-ha9979f8_1
  icc_rt             pkgs/main/win-64::icc_rt-2019.0.0-h0cc432a_1
  intel-openmp       pkgs/main/win-64::intel-openmp-2019.4-245
  jpeg               pkgs/main/win-64::jpeg-9b-hb83a4c4_2
  libpng             pkgs/main/win-64::libpng-1.6.37-h2a8f88b_0
  libtiff            pkgs/main/win-64::libtiff-4.0.10-hb898794_2
  mkl                pkgs/main/win-64::mkl-2019.4-245
  mkl-service        pkgs/main/win-64::mkl-service-2.3.0-py37hb782905_0
  mkl_fft            pkgs/main/win-64::mkl_fft-1.0.14-py37h14836fe_0
  mkl_random         pkgs/main/win-64::mkl_random-1.0.2-py37h343c172_0
  ninja              pkgs/main/win-64::ninja-1.9.0-py37h74a9793_0
  numpy              pkgs/main/win-64::numpy-1.16.5-py37h19fb1c0_0
  numpy-base         pkgs/main/win-64::numpy-base-1.16.5-py37hc3f5095_0
  olefile            pkgs/main/win-64::olefile-0.46-py37_0
  pillow             pkgs/main/win-64::pillow-6.1.0-py37hdc69c19_0
  pycparser          pkgs/main/win-64::pycparser-2.19-py37_0
  pytorch            pytorch/win-64::pytorch-1.2.0-py3.7_cuda100_cudnn7_1
  six                pkgs/main/win-64::six-1.12.0-py37_0
  tk                 pkgs/main/win-64::tk-8.6.8-hfa6e2cd_0
  torchvision        pytorch/win-64::torchvision-0.4.0-py37_cu100
  xz                 pkgs/main/win-64::xz-5.2.4-h2fa13f4_4
  zlib               pkgs/main/win-64::zlib-1.2.11-h62dcd97_3
  zstd               pkgs/main/win-64::zstd-1.3.7-h508b16e_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
mkl_fft-1.0.14       | 118 KB    | ################################################################################################################## | 100%
olefile-0.46         | 49 KB     | ################################################################################################################## | 100%
pycparser-2.19       | 170 KB    | ################################################################################################################## | 100%
mkl_random-1.0.2     | 272 KB    | ################################################################################################################## | 100%
six-1.12.0           | 23 KB     | ################################################################################################################## | 100%
ninja-1.9.0          | 238 KB    | ################################################################################################################## | 100%
numpy-1.16.5         | 50 KB     | ################################################################################################################## | 100%
torchvision-0.4.0    | 2.3 MB    | ################################################################################################################## | 100%
pillow-6.1.0         | 636 KB    | ################################################################################################################## | 100%
blas-1.0             | 6 KB      | ################################################################################################################## | 100%
pytorch-1.2.0        | 479.3 MB  | ################################################################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

次にリポジトリを取ってきましょう。

(open-mmlab) F:\Users\sounansu\Anaconda3>git clone https://github.com/ZJULearning/ttfnet.git
'git' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

(open-mmlab) F:\Users\sounansu\Anaconda3>

gitはデフォルトではないので先に入れて、

(open-mmlab) F:\Users\sounansu\Anaconda3>conda install git
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: F:\Users\sounansu\Anaconda3\envs\open-mmlab

  added / updated specs:
    - git


The following NEW packages will be INSTALLED:

  git                pkgs/main/win-64::git-2.20.1-h6bb4b03_0


Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(open-mmlab) F:\Users\sounansu\Anaconda3>git clone https://github.com/ZJULearning/ttfnet.git
Cloning into 'ttfnet'...
remote: Enumerating objects: 4913, done.
remote: Counting objects: 100% (4913/4913), done.
remote: Compressing objects: 100% (1647/1647), done.
remote: Total 4913 (delta 3279), reused 4873 (delta 3240), pack-reused 0
Receiving objects: 100% (4913/4913), 5.45 MiB | 1.59 MiB/s, done.
Resolving deltas: 100% (3279/3279), done.

下準備をするのですが、、、

(open-mmlab) F:\Users\sounansu\Anaconda3>cd ttfnet
(open-mmlab) F:\Users\sounansu\Anaconda3\ttfnet>python setup.py develop

ものすごく時間がかかって

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:F:\Users\sounansu\Anaconda3\envs\open-mmlab\lib\site-packages\torch\lib "/LIBPATH:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib/x64" /LIBPATH:F:\Users\sounansu\Anaconda3\envs\open-mmlab\libs /LIBPATH:F:\Users\sounansu\Anaconda3\envs\open-mmlab\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\lib\x64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17763.0\um\x64" cudart.lib c10.lib c10_cuda.lib torch.lib torch_python.lib _C.lib /EXPORT:PyInit_sigmoid_focal_loss_cuda build\temp.win-amd64-3.7\Release\mmdet\ops\sigmoid_focal_loss\src/sigmoid_focal_loss.obj build\temp.win-amd64-3.7\Release\mmdet\ops\sigmoid_focal_loss\src/sigmoid_focal_loss_cuda.obj /OUT:build\lib.win-amd64-3.7\mmdet\ops\sigmoid_focal_loss\sigmoid_focal_loss_cuda.cp37-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.7\Release\mmdet\ops\sigmoid_focal_loss\src\sigmoid_focal_loss_cuda.cp37-win_amd64.lib
   ライブラリ build\temp.win-amd64-3.7\Release\mmdet\ops\sigmoid_focal_loss\src\sigmoid_focal_loss_cuda.cp37-win_amd64.lib とオブジェクト build\temp.win-amd64-3.7\Release\mmdet\ops\sigmoid_focal_loss\src\sigmoid_focal_loss_cuda.cp37-win_amd64.exp を作成中
sigmoid_focal_loss_cuda.obj : error LNK2001: 外部シンボル ""public: long * __cdecl at::Tensor::data<long>(void)const " (??$data@J@Tensor@at@@QEBAPEAJXZ)" は未解決です。
build\lib.win-amd64-3.7\mmdet\ops\sigmoid_focal_loss\sigmoid_focal_loss_cuda.cp37-win_amd64.pyd : fatal error LNK1120: 1 件の未解決の外部参照
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\link.exe' failed with exit status 1120

(open-mmlab) F:\Users\sounansu\Anaconda3\ttfnet>

あらあらまあまあエラーが出てしまっています。ttfnetのissueをみてもそれらしいのがないので、ttfnetがつかっている環境であるopen-mmlabの方にヒントがないか見に行きましょう。

#2.MMDetection open-mmlab
open-mmlabは、MMDetection: Open MMLab Detection Toolbox and Benchmarkであるように、COCOのチャレンジの際にMMDetチームが使ったコードをもとに整備されているもので、open-mmlabにはmmcv, mmskelton, mmsr, mmaction, mmstyle等のコードが入っています。
 MMDetectionには、RPN, Fast R-CNN, Faster R-CNN, Mask R-CNN, Cascade R-CNN, Cascade Mask R-CNN, SSD, RetinaNet, GHM, Mask Scoring R-CNN, FCOS, Double-Head R-CNN, Grid R-CNN (Plus), Hybrid Task Cascade, Libra R-CNN, Guided Anchoringのベンチマークとモデルズ―があり、ほぼ同じ環境での構造の比較や、すでにトレーニングされたウエイトデータもあるので、インファレンスをお試し等もできます。
 よくある、githubだと、トレーニングしかできなかったり、インファレンスしかできなかったり、トレーニングデータがこっちはCOCO、こっちはCityScape等で比較できないのですが、そこも含めて比べられるので、一度覗いてみてはいかがでしょうか?
 と、今回はTTFNetを実行するために、mmdetectionをまずは動かすということで。

##2.1 Install
Install mmdetectionの初めの方はTTFNetと同じなので、mmdetectionのgitを取ってくるところから、

(open-mmlab2) F:\Users\sounansu\Anaconda3>git clone https://github.com/open-mmlab/mmdetection.git mmdetection2
Cloning into 'mmdetection2'...
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5254 (delta 0), reused 0 (delta 0), pack-reused 5249
Receiving objects: 100% (5254/5254), 5.01 MiB | 1.25 MiB/s, done.
Resolving deltas: 100% (3528/3528), done.

(open-mmlab2) F:\Users\sounansu\Anaconda3>cd mmdetection2

(open-mmlab2) F:\Users\sounansu\Anaconda3\mmdetection2>set PYTHONPATH=f:\Users\sounansu\Anaconda3\mmdetection2

(open-mmlab2) F:\Users\sounansu\Anaconda3\mmdetection2>python setup.py develop
いろいろあって
cl : コマンド ライン error D8021 : 数値型引数 '/Wno-cpp' は無効です。
error: Setup script exited with error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

issueをみると
issue1088
1.Install community version of pycocotools for windows (official repository does not support windows)
とあるのでそれを入れてみると、

(open-mmlab2) F:\Users\sounansu\Anaconda3\mmdetection2> pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Collecting git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
  Cloning https://github.com/philferriere/cocoapi.git to e:\temp\pip-req-build-n5g737fa
  Running command git clone -q https://github.com/philferriere/cocoapi.git 'E:\TEMP\pip-req-build-n5g737fa'
Building wheels for collected packages: pycocotools
  Building wheel for pycocotools (setup.py) ... done
  Created wheel for pycocotools: filename=pycocotools-2.0-cp37-cp37m-win_amd64.whl size=82677 sha256=16c7e7544004c242838d2be3c711f3c2a8a12c7f235bcf342401aad4275812f1
  Stored in directory: E:\TEMP\pip-ephem-wheel-cache-i9qk_qxe\wheels\69\2b\12\2fa959e49f73d26cff202c2f4e5079096c9c57c8a8509fd75c
Successfully built pycocotools
ERROR: mmdet 1.0rc0+d88ad8f requires matplotlib, which is not installed.
ERROR: mmdet 1.0rc0+d88ad8f requires mmcv>=0.2.10, which is not installed.
ERROR: mmdet 1.0rc0+d88ad8f requires terminaltables, which is not installed.
Installing collected packages: pycocotools
Successfully installed pycocotools-2.0

と文句を言われるので、この3つを入れましょう。
まず、matplotlibはcondaで

(open-mmlab2) F:\Users\sounansu\Anaconda3\mmdetection2>conda install matplotlib
(ログが消えちゃうんですよね。。)

mmcvはInstallにあるように

(open-mmlab2) F:\Users\sounansu\Anaconda3>git clone https://github.com/open-mmlab/mmcv.git
(open-mmlab2) F:\Users\sounansu\Anaconda3>cd mmcv
(open-mmlab2) F:\Users\sounansu\Anaconda3\mmcv>pip install -e .
Obtaining file:///F:/Users/sounansu/Anaconda3/mmcv
Requirement already satisfied: numpy>=1.11.1 in f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages (from mmcv==0.2.13) (1.16.5)
Requirement already satisfied: pyyaml in f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages (from mmcv==0.2.13) (5.1.2)
Requirement already satisfied: six in f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages (from mmcv==0.2.13) (1.12.0)
Requirement already satisfied: addict in f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages (from mmcv==0.2.13) (2.2.1)
Requirement already satisfied: requests in f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages (from mmcv==0.2.13) (2.22.0)
Requirement already satisfied: opencv-python in f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages (from mmcv==0.2.13) (4.1.1.26)
Requirement already satisfied: Cython in f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages (from mmcv==0.2.13) (0.29.13)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages (from requests->mmcv==0.2.13) (1.25.6)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages (from requests->mmcv==0.2.13) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages (from requests->mmcv==0.2.13) (2019.9.11)
Requirement already satisfied: idna<2.9,>=2.5 in f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages (from requests->mmcv==0.2.13) (2.8)
ERROR: mmdet 1.0rc0+d88ad8f requires terminaltables, which is not installed.
Installing collected packages: mmcv
  Found existing installation: mmcv 0.2.13
    Uninstalling mmcv-0.2.13:
      Successfully uninstalled mmcv-0.2.13
  Running setup.py develop for mmcv
Successfully installed mmcv

(open-mmlab2) F:\Users\sounansu\Anaconda3\mmcv>

あれ?すでに入れていたようですね。(なぜさっきは、入ってないと表示された?)
最後に、terminaltablesは

(open-mmlab2) F:\Users\sounansu\Anaconda3\mmdetection>pip install terminaltables
Collecting terminaltables
Installing collected packages: terminaltables
Successfully installed terminaltables-3.1.0

としていれて、改めてpython setup.py developをすると

(open-mmlab2) F:\Users\sounansu\Anaconda3\mmdetection2>python setup.py develop
F:\Users\sounansu\Anaconda3\envs\open-mmlab2\lib\site-packages\setuptools\dist.py:474: UserWarning: Normalizing '1.0.rc0+d88ad8f' to '1.0rc0+d88ad8f'
  normalized_version,
running develop
running egg_info
writing mmdet.egg-info\PKG-INFO
writing dependency_links to mmdet.egg-info\dependency_links.txt
writing requirements to mmdet.egg-info\requires.txt
writing top-level names to mmdet.egg-info\top_level.txt
reading manifest file 'mmdet.egg-info\SOURCES.txt'
writing manifest file 'mmdet.egg-info\SOURCES.txt'
running build_ext
F:\Users\sounansu\Anaconda3\envs\open-mmlab2\lib\site-packages\torch\utils\cpp_extension.py:189: UserWarning: Error checking compiler version for cl: 'utf-8' codec can't decode byte 0x8e in position 132: invalid start byte
  warnings.warn('Error checking compiler version for {}: {}'.format(compiler, error))
copying build\lib.win-amd64-3.7\mmdet\ops\nms\soft_nms_cpu.cp37-win_amd64.pyd -> mmdet\ops\nms
copying build\lib.win-amd64-3.7\mmdet\ops\nms\nms_cpu.cp37-win_amd64.pyd -> mmdet\ops\nms
copying build\lib.win-amd64-3.7\mmdet\ops\nms\nms_cuda.cp37-win_amd64.pyd -> mmdet\ops\nms
copying build\lib.win-amd64-3.7\mmdet\ops\roi_align\roi_align_cuda.cp37-win_amd64.pyd -> mmdet\ops\roi_align
copying build\lib.win-amd64-3.7\mmdet\ops\roi_pool\roi_pool_cuda.cp37-win_amd64.pyd -> mmdet\ops\roi_pool
copying build\lib.win-amd64-3.7\mmdet\ops\dcn\deform_conv_cuda.cp37-win_amd64.pyd -> mmdet\ops\dcn
copying build\lib.win-amd64-3.7\mmdet\ops\dcn\deform_pool_cuda.cp37-win_amd64.pyd -> mmdet\ops\dcn
copying build\lib.win-amd64-3.7\mmdet\ops\sigmoid_focal_loss\sigmoid_focal_loss_cuda.cp37-win_amd64.pyd -> mmdet\ops\sigmoid_focal_loss
copying build\lib.win-amd64-3.7\mmdet\ops\masked_conv\masked_conv2d_cuda.cp37-win_amd64.pyd -> mmdet\ops\masked_conv
Creating f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\mmdet.egg-link (link to .)
Adding mmdet 1.0rc0+d88ad8f to easy-install.pth file

Installed f:\users\sounansu\anaconda3\mmdetection2
Processing dependencies for mmdet==1.0rc0+d88ad8f
Searching for opencv-python-headless>=4.1.1
Reading https://pypi.org/simple/opencv-python-headless/
Downloading https://files.pythonhosted.org/packages/9a/a2/1a7feb6565cd932d9c9d06c9bde22fe9345a348ee3ed4f55f2457e95b111/opencv_python_headless-4.1.1.26-cp37-cp37m-win_amd64.whl#sha256=a6e9114c1e57280f47c796d87ffaea49aa3e3bcb4ed1ccde18c500b8cd143c73
Best match: opencv-python-headless 4.1.1.26
Processing opencv_python_headless-4.1.1.26-cp37-cp37m-win_amd64.whl
Installing opencv_python_headless-4.1.1.26-cp37-cp37m-win_amd64.whl to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
writing requirements to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\opencv_python_headless-4.1.1.26-py3.7-win-amd64.egg\EGG-INFO\requires.txt
Adding opencv-python-headless 4.1.1.26 to easy-install.pth file

Installed f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\opencv_python_headless-4.1.1.26-py3.7-win-amd64.egg
Searching for imgaug<0.2.7,>=0.2.5
Reading https://pypi.org/simple/imgaug/
Downloading https://files.pythonhosted.org/packages/ad/2e/748dbb7bb52ec8667098bae9b585f448569ae520031932687761165419a2/imgaug-0.2.6.tar.gz#sha256=82a5052d2daabc1b8de04b5fade44d59f3376c429880dd78e759028c67f3c8f3
Best match: imgaug 0.2.6
Processing imgaug-0.2.6.tar.gz
Writing E:\TEMP\easy_install-9y1j8wcb\imgaug-0.2.6\setup.cfg
Running imgaug-0.2.6\setup.py -q bdist_egg --dist-dir E:\TEMP\easy_install-9y1j8wcb\imgaug-0.2.6\egg-dist-tmp-ln0f2ba0
  File "build\bdist.win-amd64\egg\imgaug\bak\affine.py", line 108
    return shear = shear
                 ^
SyntaxError: invalid syntax

Sorry: IndentationError: unexpected indent (parameters-testcode.py, line 2)
zip_safe flag not set; analyzing archive contents...
imgaug.__pycache__.imgaug.cpython-37: module references __file__
creating f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\imgaug-0.2.6-py3.7.egg
Extracting imgaug-0.2.6-py3.7.egg to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Sorry: IndentationError: unexpected indent (parameters-testcode.py, line 2)
  File "f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\imgaug-0.2.6-py3.7.egg\imgaug\bak\affine.py", line 108
    return shear = shear
                 ^
SyntaxError: invalid syntax

Adding imgaug 0.2.6 to easy-install.pth file

Installed f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\imgaug-0.2.6-py3.7.egg
Searching for scipy
Reading https://pypi.org/simple/scipy/
Downloading https://files.pythonhosted.org/packages/50/eb/defa40367863304e1ef01c6572584c411446a5f29bdd9dc90f91509e9144/scipy-1.3.1-cp37-cp37m-win_amd64.whl#sha256=a9d606d11eb2eec7ef893eb825017fbb6eef1e1d0b98a5b7fc11446ebeb2b9b1
Best match: scipy 1.3.1
Processing scipy-1.3.1-cp37-cp37m-win_amd64.whl
Installing scipy-1.3.1-cp37-cp37m-win_amd64.whl to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
writing requirements to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\scipy-1.3.1-py3.7-win-amd64.egg\EGG-INFO\requires.txt
Adding scipy 1.3.1 to easy-install.pth file

Installed f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\scipy-1.3.1-py3.7-win-amd64.egg
Searching for scikit-image>=0.15
Reading https://pypi.org/simple/scikit-image/
Downloading https://files.pythonhosted.org/packages/79/16/c5a36a03f90d4a246791d4ff1879f1868e1c5db58fac9f03427395c5e2d6/scikit_image-0.15.0-cp37-none-win_amd64.whl#sha256=f0491621a6b1d2828d47acaf41d3167a647eaae44ef8fcf83b72eb3e1cc7ac51
Best match: scikit-image 0.15.0
Processing scikit_image-0.15.0-cp37-none-win_amd64.whl
Installing scikit_image-0.15.0-cp37-none-win_amd64.whl to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
writing requirements to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\scikit_image-0.15.0-py3.7-win-amd64.egg\EGG-INFO\requires.txt
Adding scikit-image 0.15.0 to easy-install.pth file
Installing skivi-script.py script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing skivi.exe script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts

Installed f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\scikit_image-0.15.0-py3.7-win-amd64.egg
Searching for networkx>=2.0
Reading https://pypi.org/simple/networkx/
Downloading https://files.pythonhosted.org/packages/85/08/f20aef11d4c343b557e5de6b9548761811eb16e438cee3d32b1c66c8566b/networkx-2.3.zip#sha256=8311ddef63cf5c5c5e7c1d0212dd141d9a1fe3f474915281b73597ed5f1d4e3d
Best match: networkx 2.3
Processing networkx-2.3.zip
Writing E:\TEMP\easy_install-0_rr4pbl\networkx-2.3\setup.cfg
Running networkx-2.3\setup.py -q bdist_egg --dist-dir E:\TEMP\easy_install-0_rr4pbl\networkx-2.3\egg-dist-tmp-8bjpvqs3
warning: no files found matching '*.html' under directory 'doc'
warning: no files found matching '*.css' under directory 'doc'
warning: no previously-included files matching '*~' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '.svn' found anywhere in distribution
no previously-included directories found matching 'doc\build'
no previously-included directories found matching 'doc\auto_examples'
no previously-included directories found matching 'doc\modules'
no previously-included directories found matching 'doc\reference\generated'
no previously-included directories found matching 'doc\reference\algorithms\generated'
no previously-included directories found matching 'doc\reference\classes\generated'
no previously-included directories found matching 'doc\reference\readwrite\generated'
creating f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\networkx-2.3-py3.7.egg
Extracting networkx-2.3-py3.7.egg to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Adding networkx 2.3 to easy-install.pth file

Installed f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\networkx-2.3-py3.7.egg
Searching for imageio>=2.0.1
Reading https://pypi.org/simple/imageio/
Downloading https://files.pythonhosted.org/packages/af/0a/943c965d372dae0b1f1482677d29030ab834351a61a9a632fd62f27f1523/imageio-2.5.0-py3-none-any.whl#sha256=1a2bbbb7cd38161340fa3b14d806dfbf914abf3ee6fd4592af2afb87d049f209
Best match: imageio 2.5.0
Processing imageio-2.5.0-py3-none-any.whl
Installing imageio-2.5.0-py3-none-any.whl to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
writing requirements to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\imageio-2.5.0-py3.7.egg\EGG-INFO\requires.txt
Adding imageio 2.5.0 to easy-install.pth file
Installing imageio_download_bin-script.py script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing imageio_download_bin.exe script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing imageio_remove_bin-script.py script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing imageio_remove_bin.exe script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts

Installed f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\imageio-2.5.0-py3.7.egg
Searching for PyWavelets>=0.4.0
Reading https://pypi.org/simple/PyWavelets/
Downloading https://files.pythonhosted.org/packages/71/57/1b6c06f2b681975e5b43ff13ba127031f668d65b592cc56fae6445b675c7/PyWavelets-1.0.3-cp37-none-win_amd64.whl#sha256=ab02363467ee3cb222c5b425bc53453270ddae72bce313e72fd14616692d725a
Best match: PyWavelets 1.0.3
Processing PyWavelets-1.0.3-cp37-none-win_amd64.whl
Installing PyWavelets-1.0.3-cp37-none-win_amd64.whl to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
writing requirements to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\PyWavelets-1.0.3-py3.7-win-amd64.egg\EGG-INFO\requires.txt
Adding PyWavelets 1.0.3 to easy-install.pth file

Installed f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\pywavelets-1.0.3-py3.7-win-amd64.egg
Searching for decorator>=4.3.0
Reading https://pypi.org/simple/decorator/
Downloading https://files.pythonhosted.org/packages/5f/88/0075e461560a1e750a0dcbf77f1d9de775028c37a19a346a6c565a257399/decorator-4.4.0-py2.py3-none-any.whl#sha256=f069f3a01830ca754ba5258fde2278454a0b5b79e0d7f5c13b3b97e57d4acff6
Best match: decorator 4.4.0
Processing decorator-4.4.0-py2.py3-none-any.whl
Installing decorator-4.4.0-py2.py3-none-any.whl to f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Adding decorator 4.4.0 to easy-install.pth file

Installed f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\decorator-4.4.0-py3.7.egg
Searching for albumentations==0.3.3
Best match: albumentations 0.3.3
Processing albumentations-0.3.3-py3.7.egg
albumentations 0.3.3 is already the active version in easy-install.pth

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\albumentations-0.3.3-py3.7.egg
Searching for imagecorruptions==1.0.0
Best match: imagecorruptions 1.0.0
Processing imagecorruptions-1.0.0-py3.7.egg
imagecorruptions 1.0.0 is already the active version in easy-install.pth

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\imagecorruptions-1.0.0-py3.7.egg
Searching for torchvision==0.4.0
Best match: torchvision 0.4.0
Adding torchvision 0.4.0 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for torch==1.2.0
Best match: torch 1.2.0
Adding torch 1.2.0 to easy-install.pth file
Installing convert-caffe2-to-onnx-script.py script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing convert-caffe2-to-onnx.exe script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing convert-onnx-to-caffe2-script.py script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing convert-onnx-to-caffe2.exe script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for pycocotools==2.0
Best match: pycocotools 2.0
Adding pycocotools 2.0 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for terminaltables==3.1.0
Best match: terminaltables 3.1.0
Adding terminaltables 3.1.0 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for six==1.12.0
Best match: six 1.12.0
Adding six 1.12.0 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for matplotlib==3.1.1
Best match: matplotlib 3.1.1
Adding matplotlib 3.1.1 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for numpy==1.16.5
Best match: numpy 1.16.5
Adding numpy 1.16.5 to easy-install.pth file
Installing f2py-script.py script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing f2py.exe script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for mmcv==0.2.13
Best match: mmcv 0.2.13
mmcv 0.2.13 is already the active version in easy-install.pth

Using f:\users\sounansu\anaconda3\mmcv
Searching for PyYAML==5.1.2
Best match: PyYAML 5.1.2
Adding PyYAML 5.1.2 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for opencv-python==4.1.1.26
Best match: opencv-python 4.1.1.26
Adding opencv-python 4.1.1.26 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for Pillow==6.1.0
Best match: Pillow 6.1.0
Adding Pillow 6.1.0 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for python-dateutil==2.8.0
Best match: python-dateutil 2.8.0
Adding python-dateutil 2.8.0 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for pyparsing==2.4.2
Best match: pyparsing 2.4.2
Adding pyparsing 2.4.2 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for kiwisolver==1.1.0
Best match: kiwisolver 1.1.0
Adding kiwisolver 1.1.0 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for cycler==0.10.0
Best match: cycler 0.10.0
Adding cycler 0.10.0 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for Cython==0.29.13
Best match: Cython 0.29.13
Adding Cython 0.29.13 to easy-install.pth file
Installing cygdb-script.py script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing cygdb.exe script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing cython-script.py script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing cython.exe script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing cythonize-script.py script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing cythonize.exe script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for requests==2.22.0
Best match: requests 2.22.0
Adding requests 2.22.0 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for addict==2.2.1
Best match: addict 2.2.1
Adding addict 2.2.1 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for setuptools==41.2.0
Best match: setuptools 41.2.0
Adding setuptools 41.2.0 to easy-install.pth file
Installing easy_install-script.py script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing easy_install.exe script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for idna==2.8
Best match: idna 2.8
Adding idna 2.8 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for certifi==2019.9.11
Best match: certifi 2019.9.11
Adding certifi 2019.9.11 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for urllib3==1.25.6
Best match: urllib3 1.25.6
Adding urllib3 1.25.6 to easy-install.pth file

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Searching for chardet==3.0.4
Best match: chardet 3.0.4
Adding chardet 3.0.4 to easy-install.pth file
Installing chardetect-script.py script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts
Installing chardetect.exe script to F:\Users\sounansu\Anaconda3\envs\open-mmlab2\Scripts

Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages
Finished processing dependencies for mmdet==1.0rc0+d88ad8f

(open-mmlab2) F:\Users\sounansu\Anaconda3\mmdetection2>

なんかエラーっぽいものが出ていますが、Finishしていますね。問題が出たらその時対応するということで。

##2.2 モデルズーでテスト
 いきなり、TTFNetは上手くいかないかもしれないので(うまくいきませんでした。)まずはmmdetectionのご本尊のMODEL ZOOでテストしましょう。
 MODEL ZOOmodelをブラウザでクリックするかして、ウエイトデータをダウンロードしてください。
 ダウンロードしたssd300_coco_vgg16_caffe_120e_20181221-84d7110b.pthmmdetectionのフォルダにおいて、GETTING_STARTEDpython tools/test.py configs/faster_rcnn_r50_fpn_1x.py checkpoints/faster_rcnn_r50_fpn_1x_20181010-3d1b3351.pth --showを参考にSSDを実行してみましょう。

(open-mmlab2) F:\Users\sounansu\Anaconda3\mmdetection2>python tools\test.py configs\ssd300_coco.py ssd300_coco_vgg16_caffe_120e_20181221-84d7110b.pth --show
loading annotations into memory...
Traceback (most recent call last):
  File "tools\test.py", line 224, in <module>
    main()
  File "tools\test.py", line 161, in main
    dataset = build_dataset(cfg.data.test)
  File "f:\Users\sounansu\Anaconda3\mmdetection2\mmdet\datasets\builder.py", line 39, in build_dataset
    dataset = build_from_cfg(cfg, DATASETS, default_args)
  File "f:\Users\sounansu\Anaconda3\mmdetection2\mmdet\utils\registry.py", line 76, in build_from_cfg
    return obj_cls(**args)
  File "f:\Users\sounansu\Anaconda3\mmdetection2\mmdet\datasets\custom.py", line 64, in __init__
    self.img_infos = self.load_annotations(self.ann_file)
  File "f:\Users\sounansu\Anaconda3\mmdetection2\mmdet\datasets\coco.py", line 27, in load_annotations
    self.coco = COCO(ann_file)
  File "F:\Users\sounansu\Anaconda3\envs\open-mmlab2\lib\site-packages\pycocotools\coco.py", line 85, in __init__
    dataset = json.load(open(annotation_file, 'r'))
FileNotFoundError: [Errno 2] No such file or directory: 'data/coco/annotations/instances_val2017.json'

data/coco/annotations以下がないといわれていますが、そもそもmmdetectionの下にdata自体がありません。INSTALLprepare datasetsを参考にCOCOの部分を作ってください。VOCやCityScapeも、私は作りましたが。

(open-mmlab2) F:\Users\sounansu\Anaconda3\mmdetection2>python tools\test.py configs\ssd300_coco.py ssd300_coco_vgg16_caffe_120e_20181221-84d7110b.pth --show
loading annotations into memory...
Done (t=0.94s)
creating index...
index created!
[                                                  ] 0/5000, elapsed: 0s, ETA:

これがプロンプロに出て、
SSD300.PNG
このような絵が出れば正解です。
お疲れさまでした。(TTFNetにはまだまだ。。。。)

#3 TTFNetの続き
 せっかくmmdetectionができたので、TTFNetのconfigとウエイトデータを持って行って実行したのですが、TTFNetで使っている一部のネットがmmdetectionの本体には入っていないようなので、TTFNetのpython setup.py developから続きをやってみました。

##3.1TTFNetのインストール
python setup.py developから再開すると、

(open-mmlab2) F:\Users\sounansu\Anaconda3\ttfnet2>python setup.py develop
.....
sigmoid_focal_loss_cuda.obj : error LNK2001: 外部シンボル ""public: long * __cdecl at::Tensor::data<long>(void)const " (??$data@J@Tensor@at@@QEBAPEAJXZ)" は未解決です。
build\lib.win-amd64-3.7\mmdet\ops\sigmoid_focal_loss\sigmoid_focal_loss_cuda.cp37-win_amd64.pyd : fatal error LNK1120: 1 件の未解決の外部参照
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\link.exe' failed with exit status 1120

ここまでは、TTFNetのgithubがmmdetectionのと同じならば、本当ならば、うまくいくはずですが、TTFNetへfolkしたあと、mmdetectionの修正を追随していないようなので、mmdetection側のissueであるCompile successfully on Windows. #1088

  1. edit mmdetection/ops/masked_conv/src/masked_conv2d_kernel.cu`
    find and replace: long -> int64_t
  1. edit mmdetection/ops/sigmoid_focal_loss/src/sigmoid_focal_loss_cuda.cu
    find and replace: long -> int64_t
    in line 112, add type casting to values
    dim3 grid(std::min(THCCeilDiv((long)losses_size, 512L), 4096L))
    to
    dim3 grid(std::min(THCCeilDiv((int64_t)losses_size, (int64_t)512L), (int64_t)4096L));
    in line 150, add type casting to values
    dim3 grid(std::min(THCCeilDiv((long)d_logits_size, 512L), 4096L));
    to
    dim3 grid(std::min(THCCeilDiv((int64_t)d_logits_size, (int64_t)512L), (int64_t)4096L));

をコードに反映されればいいのです。
mmdetection側は、この2.,3.はgitに反映されているのですが、TTFNetのgitにはされていないので、この2つのファイルをmmdetectionからとってきてTTFNetのフォルダに入れちゃいましょう。

(open-mmlab2) F:\Users\sounansu\Anaconda3>copy mmdetection\mmdet\ops\masked_conv\src\masked_conv2d_kernel.cu ttfnet\mmdet\ops\masked_conv\src\masked_conv2d_kernel.cu
ttfnet\mmdet\ops\masked_conv\src\masked_conv2d_kernel.cu を上書きしますか? (Yes/No/All): Y
        1 個のファイルをコピーしました。

(open-mmlab2) F:\Users\sounansu\Anaconda3>copy mmdetection\mmdet\ops\sigmoid_focal_loss\src\sigmoid_focal_loss_cuda.cu ttfnet\mmdet\ops\sigmoid_focal_loss\src\sigmoid_focal_loss_cuda.cu
ttfnet\mmdet\ops\sigmoid_focal_loss\src\sigmoid_focal_loss_cuda.cu を上書きしますか? (Yes/No/All): y
        1 個のファイルをコピーしました。

ではもう一度、python setup.py developを実行しましょう。

(open-mmlab2) F:\Users\sounansu\Anaconda3\ttfnet2>python setup.py develop
...
Using f:\users\sounansu\anaconda3\envs\open-mmlab2\lib\site-packages\decorator-4.4.0-py3.7.egg
Finished processing dependencies for mmdet==1.0rc0+99e9a6e

上手くいったっぽい。というかmmdetectionで実行したのと同じメッセージのようです。

##3.2 TTFNetウエイトデータのダウンロード
TTFNetのREADME.mdのinferenceにあるLinkをクリックするとウエイトデータが得られるのでダウンロードしましょう。せっかくですので、全部取ってきましょう。とってきたデータはTTFnetのフォルダに入れておきましょう。また、mmdetectionに作ったcocoのデータが入っているdataフォルダと同じものをTTFnetのフォルダにも作っておきましょう。
#4.TTFNetのインファレンス
 早速インファレンスを実行してみましょう。

(open-mmlab2) F:\Users\sounansu\Anaconda3\ttfnet2>set PYTHONPATH=F:\Users\sounansu\Anaconda3\ttfnet2

(open-mmlab2) F:\Users\sounansu\Anaconda3\ttfnet2>python tools\test.py configs\ttfnet\ttfnet_d53_1x.py ttfnet53_1x-4811e4.pth --show
loading annotations into memory...
Done (t=0.79s)
creating index...
index created!
The model and loaded state dict do not match exactly

unexpected key in source state_dict: bbox_head.shortcut_layers.0.shortcut.weight, bbox_head.shortcut_layers.0.shortcut.bias, bbox_head.shortcut_layers.1.shortcut.weight, bbox_head.shortcut_layers.1.shortcut.bias, bbox_head.shortcut_layers.2.shortcut.weight, bbox_head.shortcut_layers.2.shortcut.bias

[                                                  ] 0/5000, elapsed: 0s, ETA:

ウインドウがでて
ttf_r18.PNG
のようなものが出れば正解です。set PYTHONPATHを忘れずに。
#5.トレーニング
 ここまできたら、勝ったも同然。トレーニングをしましょう。dataフォルダが正しければちゃんと動きます。もしうまくいかなかったらdataフォルダを見直してください。

(open-mmlab2) F:\Users\sounansu\Anaconda3\ttfnet2>python tools\train.py configs\ttfnet\ttfnet_r18_1x.py
2019-10-06 19:37:25,824 - INFO - Distributed training: False
2019-10-06 19:37:26,388 - INFO - load model from: modelzoo://resnet18
2019-10-06 19:37:26,704 - WARNING - The model and loaded state dict do not match exactly

unexpected key in source state_dict: fc.weight, fc.bias

loading annotations into memory...
Done (t=23.91s)
creating index...
index created!
2019-10-06 19:37:59,831 - INFO - Start running, host: sounansu@sounansu-PC, work_dir: F:\Users\sounansu\Anaconda3\ttfnet2\work_dirs\ttfnet18_1x
2019-10-06 19:37:59,831 - INFO - workflow: [('train', 1)], max: 12 epochs
2019-10-06 19:40:25,909 - INFO - Epoch [1][50/7330]     lr: 0.00445, eta: 2 days, 23:16:16, time: 2.919, data_time: 1.341, memory: 5856, losses/ttfnet_loss_heatmap: 4.4741, losses/ttfnet_loss_wh: 4.8743, loss: 9.3484

うごいたことには動いたのですが、
eta: 2 days, 23:16:16, time:
2日以上???。タスクマネージャを見ると16GBしかメモリがないのに、15GB以上使っていそうで、いわゆるスワップが発生しているようです。
 いよいよ、CPU+MB+メモリの載せ替え時期が来たようです。。。。

#終わりに
 TTFNetどうでしたでしょうか?たしかに、mAPの値とかはSOTAより劣っていますが、学習時間が短いというのは、比較的小さなGPUしかもっていない人には優しいといえなくもないです。PCのメインメモリが少ないため、私の環境では残念な結果になってしまいましたが、そもそも16GBは、前からしょぼすぎると思っていたので、これがいい機会かなと思います。(いまさらDDR3を32GBにはしたくないので、MB+CPU+MEM+SSDというフルセットでの変更になるでしょう。。。。
 では、またWindowsでInferenceやTrainingができるものがありましたら、紹介していきます。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?