|
|
@ -1119,21 +1119,21 @@ void TFImporter::populateNet(Net dstNet) |
|
|
|
// input: "Slice/begin"
|
|
|
|
// input: "Slice/begin"
|
|
|
|
// input: "Slice/size"
|
|
|
|
// input: "Slice/size"
|
|
|
|
CV_Assert(layer.input_size() == 3); |
|
|
|
CV_Assert(layer.input_size() == 3); |
|
|
|
|
|
|
|
Mat begins = getTensorContent(getConstBlob(layer, value_id, 1)); |
|
|
|
|
|
|
|
Mat sizes = getTensorContent(getConstBlob(layer, value_id, 2)); |
|
|
|
|
|
|
|
CV_Assert(!begins.empty(), !sizes.empty(), begins.type() == CV_32SC1, |
|
|
|
|
|
|
|
sizes.type() == CV_32SC1); |
|
|
|
|
|
|
|
|
|
|
|
const tensorflow::TensorProto begins = getConstBlob(layer, value_id, 1); |
|
|
|
if (begins.total() == 4) |
|
|
|
const tensorflow::TensorProto sizes = getConstBlob(layer, value_id, 2); |
|
|
|
{ |
|
|
|
std::string beginsData = begins.tensor_content(); |
|
|
|
// Perhabs, we have an NHWC order. Swap it to NCHW.
|
|
|
|
std::string sizesData = sizes.tensor_content(); |
|
|
|
std::swap(*begins.ptr<int32_t>(0, 2), *begins.ptr<int32_t>(0, 3)); |
|
|
|
CV_Assert(begins.dtype() == tensorflow::DT_INT32); |
|
|
|
std::swap(*begins.ptr<int32_t>(0, 1), *begins.ptr<int32_t>(0, 2)); |
|
|
|
CV_Assert(sizes.dtype() == tensorflow::DT_INT32); |
|
|
|
std::swap(*sizes.ptr<int32_t>(0, 2), *sizes.ptr<int32_t>(0, 3)); |
|
|
|
CV_Assert(!beginsData.empty()); |
|
|
|
std::swap(*sizes.ptr<int32_t>(0, 1), *sizes.ptr<int32_t>(0, 2)); |
|
|
|
CV_Assert(!sizesData.empty()); |
|
|
|
} |
|
|
|
CV_Assert(beginsData.size() == sizesData.size()); |
|
|
|
layerParams.set("begin", DictValue::arrayInt((int*)begins.data, begins.total())); |
|
|
|
|
|
|
|
layerParams.set("size", DictValue::arrayInt((int*)sizes.data, sizes.total())); |
|
|
|
layerParams.set("begin", DictValue::arrayInt((int*)beginsData.c_str(), |
|
|
|
|
|
|
|
beginsData.size() / 4)); |
|
|
|
|
|
|
|
layerParams.set("size", DictValue::arrayInt((int*)sizesData.c_str(), |
|
|
|
|
|
|
|
sizesData.size() / 4)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int id = dstNet.addLayer(name, "Slice", layerParams); |
|
|
|
int id = dstNet.addLayer(name, "Slice", layerParams); |
|
|
|
layer_id[name] = id; |
|
|
|
layer_id[name] = id; |
|
|
|