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

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

This commit is contained in:
Alexander Alekhin
2021-11-05 09:27:46 +00:00
11 changed files with 167 additions and 57 deletions
+4 -3
View File
@@ -14,9 +14,6 @@ ocv_add_dispatched_file_force_all("int8layers/layers_common" AVX2 AVX512_SKX)
ocv_add_module(dnn opencv_core opencv_imgproc WRAP python java objc js)
ocv_option(OPENCV_DNN_OPENCL "Build with OpenCL support" HAVE_OPENCL AND NOT APPLE)
if(HAVE_TENGINE)
add_definitions(-DHAVE_TENGINE=1)
endif()
if(OPENCV_DNN_OPENCL AND HAVE_OPENCL)
add_definitions(-DCV_OCL4DNN=1)
@@ -44,6 +41,10 @@ endif()
ocv_cmake_hook_append(INIT_MODULE_SOURCES_opencv_dnn "${CMAKE_CURRENT_LIST_DIR}/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake")
if(HAVE_TENGINE)
add_definitions(-DHAVE_TENGINE=1)
endif()
if(MSVC)
add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
+4 -4
View File
@@ -49,6 +49,7 @@
#include <google/protobuf/message.h>
#include <google/protobuf/text_format.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/reflection.h>
#include "caffe_io.hpp"
#endif
@@ -57,8 +58,7 @@ namespace dnn {
CV__DNN_INLINE_NS_BEGIN
#ifdef HAVE_PROTOBUF
using ::google::protobuf::RepeatedField;
using ::google::protobuf::RepeatedPtrField;
using ::google::protobuf::RepeatedFieldRef;
using ::google::protobuf::Message;
using ::google::protobuf::Descriptor;
using ::google::protobuf::FieldDescriptor;
@@ -136,7 +136,7 @@ public:
#define SET_UP_FILED(getter, arrayConstr, gtype) \
if (isRepeated) { \
const RepeatedField<gtype> &v = refl->GetRepeatedField<gtype>(msg, field); \
const RepeatedFieldRef<gtype> v = refl->GetRepeatedFieldRef<gtype>(msg, field); \
params.set(name, DictValue::arrayConstr(v.begin(), (int)v.size())); \
} \
else { \
@@ -168,7 +168,7 @@ public:
break;
case FieldDescriptor::CPPTYPE_STRING:
if (isRepeated) {
const RepeatedPtrField<std::string> &v = refl->GetRepeatedPtrField<std::string>(msg, field);
const RepeatedFieldRef<std::string> v = refl->GetRepeatedFieldRef<std::string>(msg, field);
params.set(name, DictValue::arrayString(v.begin(), (int)v.size()));
}
else {
+16 -4
View File
@@ -2888,14 +2888,21 @@ DataLayout TFImporter::predictOutputDataLayout(const tensorflow::NodeDef& layer)
void TFImporter::populateNet()
{
CV_Assert(netBin.ByteSize() || netTxt.ByteSize());
#if GOOGLE_PROTOBUF_VERSION < 3005000
size_t netBinSize = saturate_cast<size_t>(netBin.ByteSize());
size_t netTxtSize = saturate_cast<size_t>(netTxt.ByteSize());
#else
size_t netBinSize = netBin.ByteSizeLong();
size_t netTxtSize = netTxt.ByteSizeLong();
#endif
CV_Assert(netBinSize || netTxtSize);
CV_LOG_INFO(NULL, "DNN/TF: parsing model"
<< (netBin.has_versions() ? cv::format(" produced by TF v%d (min_consumer=%d)", (int)netBin.versions().producer(), (int)netBin.versions().min_consumer()) : cv::String(" (N/A version info)"))
<< ". Number of nodes = " << netBin.node_size()
);
if (netTxt.ByteSize())
if (netTxtSize)
{
CV_LOG_INFO(NULL, "DNN/TF: parsing config"
<< (netTxt.has_versions() ? cv::format(" produced by TF v%d (min_consumer=%d)", (int)netTxt.versions().producer(), (int)netTxt.versions().min_consumer()) : cv::String(" (N/A version info)"))
@@ -2924,7 +2931,7 @@ void TFImporter::populateNet()
CV_LOG_DEBUG(NULL, "DNN/TF: sortByExecutionOrder(model) => " << netBin.node_size() << " nodes");
}
tensorflow::GraphDef& net = netTxt.ByteSize() != 0 ? netTxt : netBin;
tensorflow::GraphDef& net = netTxtSize != 0 ? netTxt : netBin;
int layersSize = net.node_size();
@@ -3027,7 +3034,12 @@ void TFImporter::addPermuteLayer(const int* order, const std::string& permName,
void TFImporter::parseNode(const tensorflow::NodeDef& layer)
{
tensorflow::GraphDef& net = netTxt.ByteSize() != 0 ? netTxt : netBin;
#if GOOGLE_PROTOBUF_VERSION < 3005000
size_t netTxtSize = saturate_cast<size_t>(netTxt.ByteSize());
#else
size_t netTxtSize = netTxt.ByteSizeLong();
#endif
tensorflow::GraphDef& net = netTxtSize != 0 ? netTxt : netBin;
const std::string& name = layer.name();
const std::string& type = layer.op();