From cc3ec5d45351576eddbd5fe90877a42adc730f15 Mon Sep 17 00:00:00 2001 From: Adam Radomski Date: Mon, 8 Oct 2018 17:09:14 +0200 Subject: [PATCH] Fix dnn caffe importer extract blobs from reused layers --- modules/dnn/src/caffe/caffe_importer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/dnn/src/caffe/caffe_importer.cpp b/modules/dnn/src/caffe/caffe_importer.cpp index 24e918d7dc..f31966022e 100644 --- a/modules/dnn/src/caffe/caffe_importer.cpp +++ b/modules/dnn/src/caffe/caffe_importer.cpp @@ -278,11 +278,13 @@ public: int li; for (li = 0; li != netBinary.layer_size(); li++) { - if (netBinary.layer(li).name() == name) + const caffe::LayerParameter& binLayer = netBinary.layer(li); + // Break if the layer name is the same and the blobs are not cleared + if (binLayer.name() == name && binLayer.blobs_size() != 0) break; } - if (li == netBinary.layer_size() || netBinary.layer(li).blobs_size() == 0) + if (li == netBinary.layer_size()) return; caffe::LayerParameter* binLayer = netBinary.mutable_layer(li);