forked from apache/mxnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaned up image classification cpp example (apache#9799)
* Cleaned up cpp image classification example * Added gpg key * Revert "Added gpg key" This reverts commit d5c29d7. * Adressed review comments, made other small improvements * Reverted default device type to cpu * Minor type change * Applied review comments * Brought back the static linking option
- Loading branch information
1 parent
8a05a46
commit d373070
Showing
3 changed files
with
261 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
if(USE_OPENCV) | ||
find_package(OpenCV QUIET COMPONENTS core highgui imgproc imgcodecs) | ||
if(NOT OpenCV_FOUND) # if not OpenCV 3.x, then imgcodecs are not found | ||
find_package(OpenCV REQUIRED COMPONENTS core highgui imgproc) | ||
endif() | ||
# Check OpenCV | ||
if(NOT USE_OPENCV OR NOT OpenCV_FOUND) | ||
message(WARNING "\ | ||
OpenCV should be enabled and found to build image classification example, skipping...") | ||
return() | ||
endif() | ||
|
||
if(NOT MSVC) | ||
set(UNITTEST_STATIC_LINK ON) | ||
endif() | ||
if(NOT MSVC) | ||
set(IMG_CLASSIFICATION_EXAMPLE_STATIC_LINK ON CACHE BOOL "\ | ||
Link mxnet library statically in the c++ image classification example") | ||
else() | ||
# disable static linking on Windows | ||
set(IMG_CLASSIFICATION_EXAMPLE_STATIC_LINK OFF) | ||
endif() | ||
|
||
add_executable(image-classification-predict image-classification-predict.cc) | ||
include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS}) | ||
add_executable(image-classification-predict image-classification-predict.cc) | ||
include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS}) | ||
|
||
if(UNITTEST_STATIC_LINK) | ||
target_link_libraries(image-classification-predict | ||
${BEGIN_WHOLE_ARCHIVE} mxnet_static ${END_WHOLE_ARCHIVE} | ||
dmlc | ||
${mxnet_LINKER_LIBS} | ||
) | ||
else() | ||
target_link_libraries(image-classification-predict | ||
dmlc | ||
${nnvm_LINKER_LIBS} | ||
${mxnet_LINKER_LIBS} | ||
mxnet | ||
) | ||
endif() | ||
target_link_libraries(image-classification-predict ${OpenCV_LIBS}) | ||
if(UNIX) | ||
target_link_libraries(image-classification-predict rt) | ||
endif() | ||
list(APPEND mxnet_LINKER_LIBS ${OpenCV_LIBS}) | ||
if(IMG_CLASSIFICATION_EXAMPLE_STATIC_LINK) | ||
target_link_libraries(image-classification-predict | ||
${BEGIN_WHOLE_ARCHIVE} mxnet_static ${END_WHOLE_ARCHIVE} | ||
dmlc | ||
${mxnet_LINKER_LIBS} | ||
) | ||
add_dependencies(image-classification-predict mxnet_static) | ||
else() | ||
target_link_libraries(image-classification-predict | ||
dmlc | ||
${nnvm_LINKER_LIBS} | ||
${mxnet_LINKER_LIBS} | ||
mxnet | ||
) | ||
add_dependencies(image-classification-predict mxnet) | ||
endif() | ||
|
||
|
Oops, something went wrong.