mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
Merge pull request #15057 from l-bat:fix_vizualizer
* Fix dumpToFile * Add test * Fix test
This commit is contained in:
parent
c12e26ff28
commit
12fdaf895e
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user