Skip to content

Add ReLU Activation to DarkNet Importer#18017

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
danielenricocahall:add-relu-to-darknet
Aug 4, 2020
Merged

Add ReLU Activation to DarkNet Importer#18017
opencv-pushbot merged 1 commit intoopencv:3.4from
danielenricocahall:add-relu-to-darknet

Conversation

@danielenricocahall
Copy link
Copy Markdown
Contributor

@danielenricocahall danielenricocahall commented Aug 2, 2020

Addressing the issue described in #17778 to enable using both leaky ReLU and ReLU. This PR should be merged in conjunction with opencv/opencv_extra#784, which adds the test data for the new activation function.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under OpenCV (BSD) License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • [] The feature is well documented and sample code can be built with the project CMake
opencv_extra=add-relu-to-darknet
force_builders=Custom,Custom Win,Custom Mac
build_image:Custom=ubuntu-openvino-2020.4.0:16.04
build_image:Custom Win=openvino-2020.4.0
build_image:Custom Mac=openvino-2020.4.0

test_modules:Custom=dnn,python2,python3,java
test_modules:Custom Win=dnn,python2,python3,java
test_modules:Custom Mac=dnn,python2,python3,java

buildworker:Custom=linux-1
# disabled due high memory usage: test_opencl:Custom=ON
test_opencl:Custom=OFF
test_bigdata:Custom=1
test_filter:Custom=*

@danielenricocahall danielenricocahall changed the title add relu as activation option in darknet Add ReLU Activation to DarkNet Importer Aug 2, 2020
}
else if (activation == "relu")
{
setParams.setActivation("relu");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace to

if (activation != "linear")
    setParams.setActivation(activation);

because there is already "Unsupported activation" check inside setActivation`.

@dkurt
Copy link
Copy Markdown
Member

dkurt commented Aug 3, 2020

Please take a loo at failed tests: https://pullrequest.opencv.org/buildbot/builders/precommit_linux64/builds/27147

add relu option

add relu as activation option in darknet

simplify the setParams if-else ladder

add relu as activation option in darknet

correct activation_param type

format

format

add relu as activation option in darknet

spacing

spacing

add relu as activation option in darknet
Copy link
Copy Markdown
Member

@dkurt dkurt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Well done! Thanks.

@dkurt dkurt self-assigned this Aug 4, 2020
@opencv-pushbot opencv-pushbot merged commit 161890d into opencv:3.4 Aug 4, 2020
@alalek alalek mentioned this pull request Aug 5, 2020
@zhuqiang00099
Copy link
Copy Markdown
Contributor

it exists a bug, in darknet_io.cpp line 987, miss 'relu' in 'if'.
if(activation == "leaky" || activation == "swish" || activation == "mish" || activation == "logistic") ++cv_layers_counter; // For ReLU, Swish, Mish, Sigmoid
the 'if' may fix as:
if(activation == "relu" || activation == "leaky" || activation == "swish" || activation == "mish" || activation == "logistic") ++cv_layers_counter; // For ReLU, Swish, Mish, Sigmoid

@dkurt
Copy link
Copy Markdown
Member

dkurt commented Sep 25, 2020

@zhuqiang00099 , can you please open a pull request?

                    if (activation != "linear")
                        ++cv_layers_counter;  // For ReLU, Swish, Mish, Sigmoid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dnn: darknet importer has no "relu" activation

5 participants