1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2019-07-18 19:15:14 +00:00
15 changed files with 437 additions and 394 deletions
@@ -366,6 +366,7 @@ CV__DNN_INLINE_NS_BEGIN
*/
std::vector<std::vector<Range> > sliceRanges;
int axis;
int num_split;
static Ptr<SliceLayer> create(const LayerParams &params);
};
+1 -1
View File
@@ -383,7 +383,7 @@ CV__DNN_INLINE_NS_BEGIN
/** @brief Dump net to String
* @returns String with structure, hyperparameters, backend, target and fusion
* To see correct backend, target and fusion run after forward().
* Call method after setInput(). To see correct backend, target and fusion run after forward().
*/
CV_WRAP String dump();
/** @brief Dump net structure, hyperparameters, backend, target and fusion to dot file
+7
View File
@@ -2979,6 +2979,13 @@ String parseLayerParams(const String& name, const LayerParams& lp) {
String Net::dump()
{
CV_Assert(!empty());
if (impl->netInputLayer->inputsData.empty())
CV_Error(Error::StsError, "Requested set input");
if (!impl->netWasAllocated)
impl->setUpNet();
std::ostringstream out;
std::map<int, LayerData>& map = impl->layers;
int prefBackend = impl->preferableBackend;
+5 -3
View File
@@ -61,6 +61,7 @@ public:
{
setParamsFrom(params);
axis = params.get<int>("axis", 1);
num_split = params.get<int>("num_split", 0);
if (params.has("slice_point"))
{
CV_Assert(!params.has("begin") && !params.has("size") && !params.has("end"));
@@ -141,9 +142,10 @@ public:
else // Divide input blob on equal parts by axis.
{
CV_Assert(0 <= axis && axis < inpShape.size());
CV_Assert(requiredOutputs > 0 && inpShape[axis] % requiredOutputs == 0);
inpShape[axis] /= requiredOutputs;
outputs.resize(requiredOutputs, inpShape);
int splits = num_split ? num_split : requiredOutputs;
CV_Assert(splits > 0 && inpShape[axis] % splits == 0);
inpShape[axis] /= splits;
outputs.resize(splits, inpShape);
}
return false;
}
@@ -1410,6 +1410,9 @@ void TFImporter::populateNet(Net dstNet)
axis = toNCHW(axis);
layerParams.set("axis", axis);
if (hasLayerAttr(layer, "num_split"))
layerParams.set("num_split", getLayerAttr(layer, "num_split").i());
int id = dstNet.addLayer(name, "Slice", layerParams);
layer_id[name] = id;
+20
View File
@@ -78,6 +78,26 @@ TEST(readNet, Regression)
EXPECT_FALSE(net.empty());
}
typedef testing::TestWithParam<tuple<Backend, Target> > dump;
TEST_P(dump, Regression)
{
const int backend = get<0>(GetParam());
const int target = get<1>(GetParam());
Net net = readNet(findDataFile("dnn/squeezenet_v1.1.prototxt"),
findDataFile("dnn/squeezenet_v1.1.caffemodel", false));
int size[] = {1, 3, 227, 227};
Mat input = cv::Mat::ones(4, size, CV_32F);
net.setInput(input);
net.setPreferableBackend(backend);
net.setPreferableTarget(target);
EXPECT_FALSE(net.dump().empty());
net.forward();
EXPECT_FALSE(net.dump().empty());
}
INSTANTIATE_TEST_CASE_P(/**/, dump, dnnBackendsAndTargets());
class FirstCustomLayer CV_FINAL : public Layer
{
public:
+1 -1
View File
@@ -605,7 +605,7 @@ TEST_P(Test_ONNX_nets, Resnet34_kinetics)
if (target != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported");
String onnxmodel = findDataFile("dnn/resnet-34_kinetics.onnx");
String onnxmodel = findDataFile("dnn/resnet-34_kinetics.onnx", false);
Mat image0 = imread(findDataFile("dnn/dog416.png"));
Mat image1 = imread(findDataFile("dnn/street.png"));
+5
View File
@@ -350,6 +350,11 @@ TEST_P(Test_TensorFlow_layers, l2_normalize_3d)
runTensorFlowNet("l2_normalize_3d");
}
TEST_P(Test_TensorFlow_layers, Split)
{
runTensorFlowNet("split");
}
class Test_TensorFlow_nets : public DNNTestLayer {};
TEST_P(Test_TensorFlow_nets, MobileNet_SSD)