Skip to content

Darknet io: Need parsing of "Connected" and "Dropout" layers and setting of MaxPool padding parameters correctly.  #16437

@ashishkrshrivastava

Description

@ashishkrshrivastava
System information (version)
  • OpenCV => 4.2.0
  • Operating System / Platform => Ubuntu 18.04
  • Compiler => g++ 7.4.0
Detailed description

1 Loading model using cv2.dnn.readNetFromDarknet(alexnet.cfg, alexnet.weights) gives error cv2.error: OpenCV(4.2.0-dev) /home/ashish/opencv/modules/dnn/src/darknet/darknet_io.cpp:800: error: (-212:Parsing error) Unknown layer type: in function 'ReadDarknetFromCfgStream'.

Getting this error because Parsing for "Connected" layer and "dropout" is not added.

2 Padding for Maxpool is incorrect. Darknet maxpool parser takes padding parameter for manual padding. if not mentioned, then take kernel_size - 1 as padding. Size after parsing becomes new size = original size + padding which is different from opencv. Hence padding needs attention.

https://github.com/pjreddie/darknet/blob/61c9d02ec461e30d55762ec7669d6a1d3c356fb2/src/parser.c#L487

Steps to reproduce

cv2.dnn.readNetFromDarknet(alexnet.cfg, alexnet.weights)

Alexnet.cfg - https://github.com/pjreddie/darknet/blob/master/cfg/alexnet.cfg
Alexnet.weights - https://pjreddie.com/media/files/alexnet.weights

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions