-
Notifications
You must be signed in to change notification settings - Fork 5.8k
GSOC'16 - DNN modern #720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GSOC'16 - DNN modern #720
Conversation
1d8219c
to
971f2a7
Compare
28c53bf
to
bcfb93e
Compare
modules/dnn_modern/CMakeLists.txt
Outdated
# MODULE REQUIREMENTS | ||
# ---------------------------------------------------------------------------- | ||
|
||
find_package(TinyDNN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use QUIET
mode
@@ -0,0 +1,283 @@ | |||
# Locate Intel Threading Building Blocks include paths and libraries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OpenCV has TBB support: https://github.com/opencv/opencv/blob/master/cmake/OpenCVDetectTBB.cmake
What kind of problems do you have with reusing of mentioned code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the motivation for this is that I want the user to choose if he want to build the module with TBB totally independent of the rest of the opencv modules. So, if opencv was built with TBB support maybe for X reason I don't want to use TBB with this module. /cc @bhack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to avoid potential conflicts, which are hard to debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my solution or your solution?
@@ -0,0 +1,46 @@ | |||
# Locate the tiny-cnn library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace everywhere:
tiny-cnn -> tiny-dnn
FindTinyCNN -> FindTinyDNN
TinyCNN -> TinyDNN
etc
modules/dnn_modern/README.md
Outdated
Download tiny-cnn project somewhere in your system | ||
|
||
cd /opt | ||
git clone https://github.com/nyanp/tiny-cnn.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Project has new link:
https://github.com/tiny-dnn/tiny-dnn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem is still here.
@vpisarev @garybradski Are we going to merge this module as it is or do we wait for a clear roadmap for the dnn module? /cc @bhack |
@edgarriba We are on this topic. I hope that we can have news soon |
@edgarriba this PR will be merged but first you need to resolve infrastructure problems mentioned by @alalek |
bcfb93e
to
66bd965
Compare
# ---------------------------------------------------------------------------- | ||
# MODULE REQUIREMENTS | ||
# ---------------------------------------------------------------------------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add cmake_policy(SET CMP0028 OLD)
to avoid warning caused by :: in TinyDNN::tiny_dnn target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
modules/dnn_modern/CMakeLists.txt
Outdated
endif() | ||
|
||
find_package(Protobuf) | ||
find_package(Caffe) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Caffe required by this module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me check
modules/dnn_modern/CMakeLists.txt
Outdated
# ---------------------------------------------------------------------------- | ||
|
||
ocv_define_module(dnn_modern opencv_core opencv_imgproc opencv_imgcodecs WRAP python) | ||
ocv_target_link_libraries(${the_module} TinyDNN::tiny_dnn ${REQUIRED_LIBRARIES}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed the instructions form README, but tiny-dnn headers are missing during compilation,
so it's needed to add implicit include of sources.
Also in case if headers are included compilation fails due to -Werror=non-virtual-dtor flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you download the last version and installed via cmake commands?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Install target in tiny-dnn's CMake is broken at the moment (headers of 3rd party libs are not installed), so I'm just using instructions from readme. CMake command is cmake . -DTINYDNN_ROOT=~/repositories/tiny-dnn/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's what I suspected. The idea for third-party libraries is that you don't need them to run the internal algorithms. However, it's clear that something is not doing the job. We need to checkout this issue and update the upstream since I don't have a quick answer for this now. /cc @nyanp
results->clear(); | ||
results->reserve(result.size()); | ||
|
||
for (cnn_size_t i = 0; i < result.size(); i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cnn_size_t
doesn't exist anymore and should be replaced with size_t
.
@@ -0,0 +1,114 @@ | |||
set(the_description "Modern Deep Learning module") | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add CMake version check here:
if(${CMAKE_VERSION} VERSION_LESS 3.2)
message(STATUS "Module opencv_dnn_modern disabled beacuse CMake version is less than 3.2")
ocv_module_disable(dnn_modern)
return()
endif()
# ---------------------------------------------------------------------------- | ||
|
||
ocv_define_module(dnn_modern opencv_core opencv_imgproc opencv_imgcodecs WRAP python) | ||
ocv_target_link_libraries(${the_module} ${REQUIRED_LIBRARIES}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it doesn't work unless I add the below two lines:
ocv_target_include_directories(${the_module} ${TINYDNN_INCLUDE_DIRS})
target_compile_options(${the_module} PRIVATE "-Wno-error=non-virtual-dtor")
|
||
#define CNN_USE_CAFFE_CONVERTER | ||
#include <tiny_dnn/tiny_dnn.h> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build fails with tons of linker errors related to caffe, but it can be fixed by adding here
#include <tiny_dnn/io/caffe/caffe.pb.cc>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sovrasov ok. However, not sure what's the proper way to handle this since in the library those proto files are generated during the cmake configuration
https://github.com/tiny-dnn/tiny-dnn/blob/master/examples/caffe_converter/CMakeLists.txt
Should we include this piece of code here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to handle this in CMake and just didn't know how it done in tiny-dnn.
In case if tiny-dnn was configured with it's own CMake the most part of dnn_modern CMake becomes useless and can be removed, but current implementation can work with raw unconfigured sources. Why did you choose this way instead of relying on CMake from tiny-dnn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well the point is that tiny-dnn is header-only and very configurable so you have to setup the configuration at the moment you "link" it to the target project. However, if you have any better idea it will be welcomed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point, just interested why tinydnn-config.cmake is not used.
Devs of tiny-dnn recommend it as far as I can see:
# Example to find TinyDNN headers only::
#
# find_package(TinyDNN 0.1.0)
# if(TinyDNN_FOUND)
# add_executable(foo foo.cc)
# target_link_libraries(foo TinyDNN::tiny_cnn)
# endif()
#
# Example to find TinyDNN headers and some *static* libraries::
#
# set(TinyDNN_USE_TBB ON) # only find static libs
# set(TInyCNN_USE_AVX2 ON)
# find_package(TinyDNN 0.1.0)
# if(TinyDNN_FOUND)
# add_executable(foo foo.cc)
# target_link_libraries(foo TinyDNN::tiny_cnn ${TinyDNN_LIBRARIES})
# endif()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well yes, I'm the one who wrote those codes. But to use you need to install tiny-dnn headers via cmake in order to create all the targets. I didn't test at all the config file, so this can be a good starting point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave all as is, because now rewriting dnn_modern CMake and testing tiny-dnn config will take too much effort.
add FindTinyCNN.cmake and setup CMakeLists.txt add find TBB and NNPACK to CMakeLists.txt add caffe converter skeleton add simple sample eval method return scores Update README.md Update README.md Update README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
add_definitions(-DCNN_USE_OMP) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OpenCV already defines TBB and OpenMP dependencies.
@alalek ping |
@edgarriba |
@alalek now should be fine |
Thanks! |
This pull request creates a new module for deep learning.