-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Cleaned up image classification cpp example #9799
Conversation
} | ||
|
||
~BufferFile() { | ||
if (buffer_) { |
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 check is not needed
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.
Better a smart pointer in any case?
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.
Done
} | ||
|
||
// LoadSynsets | ||
// Code from : https://github.com/pertusa/mxnet_predict_cc/blob/master/mxnet_predict.cc | ||
std::vector<std::string> LoadSynset(std::string synset_file) { | ||
std::ifstream fi(synset_file.c_str()); | ||
std::vector <std::string> LoadSynset(std::string synset_file) { |
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.
why space before template arg?
|
||
std::vector<std::string> output; | ||
std::vector <std::string> output; |
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 this your IDE settings?
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.
Thanks, this was a weird default setting on a new machine
Those keys are release signing keys. If you are not going to drive a release you don't need it |
@@ -671,8 +672,7 @@ if(USE_CPP_PACKAGE) | |||
add_subdirectory(cpp-package) | |||
endif() | |||
|
|||
# Problems on Mac OS X: 1. librt not available 2. mxnet built as MODULE library, which can't be linked. |
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.
Has this been resolved?
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.
Yes
KEYS
Outdated
@@ -480,3 +480,40 @@ IxR3jVTKye+UerEtN8yATW8CRIKO3IobUfLMDdPCLO7uzoW95cI35Y0l8JgK2NeU | |||
=E4W5 | |||
-----END PGP PUBLIC KEY BLOCK----- | |||
|
|||
pub rsa2048 2018-02-07 [SC] [expires: 2020-02-07] |
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.
Since you're not going to make a release, I don't think that your key should be in here.
Could you please add on which platforms you have tested your modifications? Since we're not testing examples on CI, we'll have to test them ourselves. |
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.
Alright, thanks for letting me know
@@ -671,8 +672,7 @@ if(USE_CPP_PACKAGE) | |||
add_subdirectory(cpp-package) | |||
endif() | |||
|
|||
# Problems on Mac OS X: 1. librt not available 2. mxnet built as MODULE library, which can't be linked. |
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.
Yes
Listed tested platforms in the description |
Could you please also test Windows? |
Added windows to tested platforms |
# ---[ OpenCV | ||
if(NOT USE_OPENCV OR NOT OpenCV_FOUND) | ||
message(WARNING "\ | ||
OpenCV should be enabled and found to build image classification example, skipping...") |
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 a critical error, right?
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 example will just not be build and it will not break the whole project configuration.
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 certainly is chopping out a lot of stuff. WHat's the net change in static linking logic?
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 is not about static, it's an early return from this cmake file. The example can not be built if there is no OpenCV and will not be added to the main project. That's it.
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.
isn’t the unittest static link flag removed?
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.
UNITTEST_STATIC_LINK is descriptive and editable. Changing the check to MSVC at the actual interpretation point makes it difficult to see what's being done.
Also, I think MSVC has to build static because of dllimport issues
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 can leave the variable itself but would rename it, because it's an example, not a unit test.
@marcoabreu @piiswrong @cjolivier01 @szha do you want to take another look and merge if possible? |
I can't really help here, sorry. |
CMakeLists.txt
Outdated
@@ -32,6 +32,7 @@ mxnet_option(USE_GPROF "Compile with gprof (profiling) flag" OFF) | |||
mxnet_option(USE_CXX14_IF_AVAILABLE "Build with C++14 if the compiler supports it" OFF) | |||
mxnet_option(USE_VTUNE "Enable use of Intel Amplifier XE (VTune)" OFF) # one could set VTUNE_ROOT for search path | |||
mxnet_option(ENABLE_CUDA_RTC "Build with CUDA runtime compilation support" ON) | |||
mxnet_option(BUILD_CPP_EXAMPLES "Build cpp examples" OFF) |
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.
default to on, please. Otherwise, people may check in/merge broken 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.
Ok
# ---[ OpenCV | ||
if(NOT USE_OPENCV OR NOT OpenCV_FOUND) | ||
message(WARNING "\ | ||
OpenCV should be enabled and found to build image classification example, skipping...") |
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 certainly is chopping out a lot of stuff. WHat's the net change in static linking logic?
/*! | ||
* Copyright (c) 2015 by Xiao Liu, pertusa, caprice-j |
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 don't think you can do this, can you? I was under the impression that license text could never be removed.
@smarthi , this this ok?
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.
Technically I'm not removing contributors, just naming them as a group. I followed the pattern in the rest of the project, but will be happy to change it back.
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 the guy’s name still there?
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.
Yes, brought it back
|
||
const mx_float DEFAULT_MEAN = 117.0; | ||
|
||
std::string trim(const std::string& input) { |
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.
make static, please
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.
Ok
Can you please summarize the "cleaning up" items in the description? It's a little hard to follow what the added value is from the diff, since it's a bit scattered. |
@cjolivier01 The changes are already listed: Changes
|
@cjolivier01 please take another look, thanks! |
Can you please summarize the "cleaning up" items in the description? It's a little hard to follow what the added value is from the diff, since it's a bit scattered. |
Also, is this used in any of the unit tests or nightly tests? If not, probably we should be running at least one test with it. |
# ---[ OpenCV | ||
if(NOT USE_OPENCV OR NOT OpenCV_FOUND) | ||
message(WARNING "\ | ||
OpenCV should be enabled and found to build image classification example, skipping...") |
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.
UNITTEST_STATIC_LINK is descriptive and editable. Changing the check to MSVC at the actual interpretation point makes it difficult to see what's being done.
Also, I think MSVC has to build static because of dllimport issues
@cjolivier01 for now this is not tested on ci, but I will ingerate this as the base for valgrind memcheck tests |
Added 'Code improvements' section for detailisation |
* 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
* 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
* 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
Description
Cleaned up image classification cpp example.
Checklist
Essentials
make lint
)Changes
Code improvements
Tested