Merge pull request #16358 from ashishkrshrivastava:opencv-2

pull/16408/head
Alexander Alekhin 5 years ago
commit 16d8e9e0c8
  1. 7
      modules/dnn/src/darknet/darknet_io.cpp
  2. 7
      modules/dnn/test/test_darknet_importer.cpp

@ -556,6 +556,7 @@ namespace cv {
{ {
int kernel_size = getParam<int>(layer_params, "size", -1); int kernel_size = getParam<int>(layer_params, "size", -1);
int pad = getParam<int>(layer_params, "pad", 0); int pad = getParam<int>(layer_params, "pad", 0);
int padding = getParam<int>(layer_params, "padding", 0);
int stride = getParam<int>(layer_params, "stride", 1); int stride = getParam<int>(layer_params, "stride", 1);
int filters = getParam<int>(layer_params, "filters", -1); int filters = getParam<int>(layer_params, "filters", -1);
bool batch_normalize = getParam<int>(layer_params, "batch_normalize", 0) == 1; bool batch_normalize = getParam<int>(layer_params, "batch_normalize", 0) == 1;
@ -563,13 +564,13 @@ namespace cv {
if (flipped == 1) if (flipped == 1)
CV_Error(cv::Error::StsNotImplemented, "Transpose the convolutional weights is not implemented"); CV_Error(cv::Error::StsNotImplemented, "Transpose the convolutional weights is not implemented");
// correct the strange value of pad=1 for kernel_size=1 in the Darknet cfg-file if (pad)
if (kernel_size < 3) pad = 0; padding = kernel_size / 2;
CV_Assert(kernel_size > 0 && filters > 0); CV_Assert(kernel_size > 0 && filters > 0);
CV_Assert(current_channels > 0); CV_Assert(current_channels > 0);
setParams.setConvolution(kernel_size, pad, stride, filters, current_channels, setParams.setConvolution(kernel_size, padding, stride, filters, current_channels,
batch_normalize); batch_normalize);
current_channels = filters; current_channels = filters;

@ -106,7 +106,7 @@ public:
std::string cfg = findDataFile("dnn/darknet/" + name + ".cfg"); std::string cfg = findDataFile("dnn/darknet/" + name + ".cfg");
std::string model = ""; std::string model = "";
if (hasWeights) if (hasWeights)
model = findDataFile("dnn/darknet/" + name + ".weights", false); model = findDataFile("dnn/darknet/" + name + ".weights");
checkBackend(&inp, &ref); checkBackend(&inp, &ref);
@ -528,6 +528,11 @@ TEST_P(Test_Darknet_layers, reorg)
testDarknetLayer("reorg"); testDarknetLayer("reorg");
} }
TEST_P(Test_Darknet_layers, convolutional )
{
testDarknetLayer("convolutional", true);
}
INSTANTIATE_TEST_CASE_P(/**/, Test_Darknet_layers, dnnBackendsAndTargets()); INSTANTIATE_TEST_CASE_P(/**/, Test_Darknet_layers, dnnBackendsAndTargets());
}} // namespace }} // namespace

Loading…
Cancel
Save