提交 12fdaf89 编写于 作者: L Lubov Batanina 提交者: Alexander Alekhin

Merge pull request #15057 from l-bat:fix_vizualizer

* Fix dumpToFile

* Add test

* Fix test
上级 c12e26ff
......@@ -387,7 +387,7 @@ CV__DNN_EXPERIMENTAL_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
......
......@@ -2903,6 +2903,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;
......
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册