Skip to content

Commit 9ace633

Browse files
committed
Merge pull request #1182 from sovrasov:dnn_build_wo_torch
2 parents 503b00f + 50a5242 commit 9ace633

File tree

3 files changed

+20
-43
lines changed

3 files changed

+20
-43
lines changed

modules/dnn/src/caffe/caffe_importer.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,7 @@ Ptr<Importer> cv::dnn::createCaffeImporter(const String&, const String&)
374374

375375
Net cv::dnn::readNetFromCaffe(const String &prototxt, const String &caffeModel /*= String()*/)
376376
{
377-
Ptr<Importer> caffeImporter;
378-
try
379-
{
380-
caffeImporter = createCaffeImporter(prototxt, caffeModel);
381-
}
382-
catch(...)
383-
{
384-
}
385-
377+
Ptr<Importer> caffeImporter = createCaffeImporter(prototxt, caffeModel);
386378
Net net;
387379
if (caffeImporter)
388380
caffeImporter->populateNet(net);

modules/dnn/src/tensorflow/tf_importer.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -736,23 +736,6 @@ void TFImporter::populateNet(Net dstNet)
736736

737737
} // namespace
738738

739-
Net cv::dnn::readNetFromTensorflow(const String &model)
740-
{
741-
Ptr<Importer> importer;
742-
try
743-
{
744-
importer = createTensorflowImporter(model);
745-
}
746-
catch(...)
747-
{
748-
}
749-
750-
Net net;
751-
if (importer)
752-
importer->populateNet(net);
753-
return net;
754-
}
755-
756739
Ptr<Importer> cv::dnn::createTensorflowImporter(const String &model)
757740
{
758741
return Ptr<Importer>(new TFImporter(model.c_str()));
@@ -767,3 +750,12 @@ Ptr<Importer> cv::dnn::createTensorflowImporter(const String&)
767750
}
768751

769752
#endif //HAVE_PROTOBUF
753+
754+
Net cv::dnn::readNetFromTensorflow(const String &model)
755+
{
756+
Ptr<Importer> importer = createTensorflowImporter(model);
757+
Net net;
758+
if (importer)
759+
importer->populateNet(net);
760+
return net;
761+
}

modules/dnn/src/torch/torch_importer.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -971,23 +971,6 @@ Mat readTorchBlob(const String &filename, bool isBinary)
971971
return importer->tensors.begin()->second;
972972
}
973973

974-
Net readNetFromTorch(const String &model, bool isBinary)
975-
{
976-
Ptr<Importer> importer;
977-
try
978-
{
979-
importer = createTorchImporter(model, isBinary);
980-
}
981-
catch(...)
982-
{
983-
}
984-
985-
Net net;
986-
if (importer)
987-
importer->populateNet(net);
988-
return net;
989-
}
990-
991974
#else
992975

993976
Ptr<Importer> createTorchImporter(const String&, bool)
@@ -1003,5 +986,15 @@ Mat readTorchBlob(const String&, bool)
1003986
}
1004987

1005988
#endif //defined(ENABLE_TORCH_IMPORTER) && ENABLE_TORCH_IMPORTER
989+
990+
Net readNetFromTorch(const String &model, bool isBinary)
991+
{
992+
Ptr<Importer> importer = createTorchImporter(model, isBinary);
993+
Net net;
994+
if (importer)
995+
importer->populateNet(net);
996+
return net;
997+
}
998+
1006999
}
10071000
}

0 commit comments

Comments
 (0)