LoginSignup
0
0

More than 5 years have passed since last update.

doppiaモデルをインストールする

Last updated at Posted at 2016-11-20

はじめに

GitHub上のDeepCascadeモデルをinstallしようとして挫折した。
DeepCascadeモデルをインストールする(1)
http://qiita.com/masataka46/items/61032ba4470e35557389
DeepCascadeモデルをインストールする(2)
http://qiita.com/masataka46/items/df3b9aba6fa7dc6bbff5

問題点の多くは、元々のコードに対して付加した部分

src/objects_detection/GpuVeryFastIntegralChannelsDetector.cpp

などだと思われる。よって、方針を変えて、元々のコードdoppiaをインストールする。
doppiaのコードはこちら
https://bitbucket.org/rodrigob/doppia

環境

Ubuntu14.04
GitHub上のDeepCascadeモデルのdependenciesはインストール済み

step 1

以下、OverViewに従って進める。

まずcommon_settings.cmakeの338行あたりのコンピュータ名を変更する。

common_settings.cmake
elseif(${HOSTNAME} STREQUAL  "the_name_of_your_machine")
  # change the_name_of_your_machine to what /bin/hostname returns

  message(STATUS "Using ohmasa-com compilation options")

the_name_of_your_machineを自分のコンピュータ名に変更。次に

./generate_protocol_buffer_files.sh

を実行し、問題ないか確認する。

step 2

step 2ではCPUのみでのコンパイルを行う。

cd doppia/src/applications/ground_estimation
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo . && make -j4
cmake . && make -j4 && ./ground_estimation -c test.config.ini
cd doppia/src/applications/stixel_world
cmake . && make -j2 && OMP_NUM_THREADS=4 ./stixel_world -c fast.config.ini --gui.disable false
cmake . && make -j2 && OMP_NUM_THREADS=4 ./stixel_world -c fast_uv.config.ini --gui.disable false

と、ここまで問題なくでも画面などが表示される。次が問題のstep 3。

step 3

まずは指示通り進めてみる。

cd doppia/src/applications/objects_detection
cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo . && make -j4
.....
.....
/../../../libs/cudatemplates/include/cudatemplates/error.hpp:44:26: fatal error: cuda_runtime.h: そのようなファイルやディレクトリはありません
 #include <cuda_runtime.h>
                          ^

と出た。このエラーはGitHubヴァージョンでは出てこなかったものだ。cuda_runtime.hを検索したところ、/usr/local/cuda-8.0/includeにあった。一方で

echo $CPLUS_INCLUDE_PATH

としたところ、/usr/local/cuda-8.0/includeはなかったので、.bashrcに追加。

export CPLUS_INCLUDE_PATH=/usr/local/cuda-8.0/include:$CPLUS_INCLUDE_PATH

bashして再度makeする。

bash
make clean
make -j4
.....
.....
Linking CXX executable objects_detection
[100%] Built target objects_detection

と、初めて成功した。次に

make clean
cmake .
make -j2 && OMP_NUM_THREADS=4 ./objects_detection -c cvpr2012_very_fast_over_bahnhof.config.ini --gui.disable false

としたところ、

.....
.....
Linking CXX executable objects_detection
[100%] Built target objects_detection
.....
.....
Reading files:
../../../data/sample_test_images/bahnhof/image_00000000_0.png
../../../data/sample_test_images/bahnhof/image_00000000_1.png
[libprotobuf ERROR google/protobuf/message_lite.cc:123] Can't parse message of type "doppia_protobuf.DetectorModel" because it is missing required fields: detector_type
.....
.....
2016-11-20 19:10:16 {7fa4a802e840} [ SoftCascadeOverIntegralChannelsModel ] : Warning: No semantic category found in model, assuming a pedestrian detector
2016-11-20 19:10:16 {7fa4a802e840} [ check_stages_and_range_visitor ] : Warning: Scale -1 is almost fine, min (x, y) == (0, 0), max (x,y) == (7, 15), width, height == (8, 16), (only touches left, top, border(s))
2016-11-20 19:10:16 {7fa4a802e840} [ check_stages_and_range_visitor ] : Warning: Not touching the borders indicates that the model is suboptimal regarding detection quality (was trained with doppia v1, instead of v2)
.....
.....
A std::exception was raised: This executable was compiled without support for GpuVeryFastIntegralChannelsDetector
terminate called after throwing an instance of 'std::runtime_error'
  what():  This executable was compiled without support for GpuVeryFastIntegralChannelsDetector
中止 (コアダンプ)

などとエラーになった。この中で

[libprotobuf ERROR google/protobuf/message_lite.cc:123] Can't parse message of type "doppia_protobuf.DetectorModel" because it is missing required fields: detector_type

という部分が怪しい。調べてみると、コードのissue内に同様のエラーが出ていた。
https://bitbucket.org/rodrigob/doppia/issues/80/gpuveryfastintegralchannelsdetector
ここの解決法に従って以下のようにCMakeLists.txtの冒頭に追加。

CMakeLists.txt
set(USE_GPU ON CACHE BOOL "Should the GPU be used ?" )

再度makeすると、デモが立ち上がり、成功した。他のmakeも確かめる。まずこれ。

cmake . && make -j2 && OMP_NUM_THREADS=4 ./objects_detection -c cvpr2012_inria_pedestrians.config.ini --gui.disable false

screenshot_frame_4.png
これもちゃんとデモが立ち上がった。次は路上で人をdetectionするこれ。

cmake . && make -j2 && OMP_NUM_THREADS=4 ./objects_detection -c cvpr2012_chnftrs_over_bahnhof.config.ini --gui.disable false

screenshot_frame_5.png
これもちゃんと稼働した。最後はfacedetectionのこれ。

cmake . && make -j2 && ./objects_detection -c eccv2014_face_detection_pascal.config.ini --gui.disable false

screenshot_frame_3.png
これもうまくいった。

step 4

ここではobjects_detection_libディレクトリでcmake、makeを行う。

cd doppia/src/applications/objects_detection_lib
cmake.
make -j4

問題なく成功したようだ。

step 5

次にstep 5へ進む。ここではいよいよ学習を行った。

cd doppia/src/applications/boosted_learning
./run_speedy_training.sh
.....
.....
Error rate stable at zero until 100
Average speed in the last 100 iterations is 23.199 [Hz]
Error rate stable at zero until 600
Average speed in the last 600 iterations is 23.558 [Hz]
Error rate stable at zero until 1100
Average speed in the last 1100 iterations is 23.553 [Hz]
Error rate stable at zero until 1600
Average speed in the last 1600 iterations is 23.547 [Hz]
Error rate stable at zero until 2047
Total time for the 2048 iterations is 86.950 [seconds]
Time elapsed in seconds: 86
Time elapsed while producing strong classifier for training round 2: 00:01:26
Finished the 3 bootstrapping stages. Model was trained over 11468 samples (2468 positives, 9000 negatives).
Final model saved at 2016_11_21_2811_fast_training
Time elapsed in seconds: 4681
Time elapsed for all training and boostrapping rounds: 01:18:01
End of game. Have a nice day !
End of game, have a nice day.
+ echo Training finished.
Training finished.

1時間18分で学習が終了した。Training stageが50以降はErrorがほぼ0。過適合してないか?

0
0
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
0
0