Commit 327aa89c authored by Aleksandr Rybnikov's avatar Aleksandr Rybnikov Committed by arrybn

Added TensorFlow models loading

parent e36e2ff0
...@@ -16,9 +16,10 @@ if(MSVC) ...@@ -16,9 +16,10 @@ if(MSVC)
/wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506 /wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506
) )
else() else()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo -Wundef ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
-Wtautological-undefined-compare -Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
-Wignored-qualifiers -Wextra -Wunused-function -Wunused-const-variable -Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
-Wunused-function -Wunused-const-variable
) )
endif() endif()
......
...@@ -15,6 +15,20 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninit ...@@ -15,6 +15,20 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninit
) )
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4701 /wd4100) ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4701 /wd4100)
if(MSVC)
add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
/wd4305 /wd4127 /wd4100 /wd4512 /wd4125 /wd4389 /wd4510 /wd4610
/wd4702 /wd4456 /wd4457 /wd4065 /wd4310 /wd4661 /wd4506
)
else()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
-Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
-Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
-Wunused-function -Wunused-const-variable -Wdeprecated-declarations
)
endif()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Resolve libprotobuf dependency # Resolve libprotobuf dependency
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
......
...@@ -16,7 +16,7 @@ if(${the_module}_WITH_BLAS) ...@@ -16,7 +16,7 @@ if(${the_module}_WITH_BLAS)
endif() endif()
if(NOT HAVE_BLAS) if(NOT HAVE_BLAS)
include(cmake/OpenCVFindMKL.cmake) include(cmake/OpenCVFindMKL.cmake)
if(MKL_FOUND) if(HAVE_MKL)
set(BLAS_INCLUDE_DIR ${MKL_INCLUDE_DIRS}) set(BLAS_INCLUDE_DIR ${MKL_INCLUDE_DIRS})
set(BLAS_LIBRARIES ${MKL_LIBRARIES} ) set(BLAS_LIBRARIES ${MKL_LIBRARIES} )
set(BLAS_CBLAS_H "mkl_cblas.h" ) set(BLAS_CBLAS_H "mkl_cblas.h" )
......
...@@ -12,9 +12,9 @@ if(UPDATE_PROTO_FILES) ...@@ -12,9 +12,9 @@ if(UPDATE_PROTO_FILES)
endif() endif()
if(DEFINED PROTOBUF_PROTOC_EXECUTABLE AND EXISTS ${PROTOBUF_PROTOC_EXECUTABLE}) if(DEFINED PROTOBUF_PROTOC_EXECUTABLE AND EXISTS ${PROTOBUF_PROTOC_EXECUTABLE})
message(STATUS "The protocol buffer compiler is found (${PROTOBUF_PROTOC_EXECUTABLE})") message(STATUS "The protocol buffer compiler is found (${PROTOBUF_PROTOC_EXECUTABLE})")
PROTOBUF_GENERATE_CPP(PROTOBUF_HDRS PROTOBUF_SRCS file(GLOB proto_files src/tensorflow/*.proto)
src/caffe/caffe.proto list(APPEND proto_files src/caffe/caffe.proto)
) PROTOBUF_GENERATE_CPP(PROTOBUF_HDRS PROTOBUF_SRCS ${proto_files})
else() else()
message(FATAL_ERROR "The protocol buffer compiler is not found (PROTOBUF_PROTOC_EXECUTABLE='${PROTOBUF_PROTOC_EXECUTABLE}')") message(FATAL_ERROR "The protocol buffer compiler is not found (PROTOBUF_PROTOC_EXECUTABLE='${PROTOBUF_PROTOC_EXECUTABLE}')")
endif() endif()
...@@ -34,13 +34,21 @@ else() ...@@ -34,13 +34,21 @@ else()
endif() endif()
if(NOT UPDATE_PROTO_FILES) if(NOT UPDATE_PROTO_FILES)
list(APPEND PROTOBUF_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.cc) file(GLOB fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.cc)
list(APPEND PROTOBUF_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.h) file(GLOB fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.h)
list(APPEND fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.cc)
list(APPEND fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.h)
list(APPEND PROTOBUF_SRCS ${fw_srcs})
list(APPEND PROTOBUF_HDRS ${fw_hdrs})
list(APPEND PROTOBUF_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe) list(APPEND PROTOBUF_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe)
list(APPEND PROTOBUF_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow)
endif() endif()
add_definitions(-DHAVE_PROTOBUF=1) add_definitions(-DHAVE_PROTOBUF=1)
#supress warnings in autogenerated caffe.pb.* files #supress warnings in autogenerated caffe.pb.* files
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-parameter -Wundef) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-parameter -Wundef -Wignored-qualifiers -Wno-enum-compare
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702) -Wdeprecated-declarations)
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702
/wd4456 /wd4510 /wd4610 /wd4800
)
...@@ -210,6 +210,7 @@ namespace dnn ...@@ -210,6 +210,7 @@ namespace dnn
public: public:
CV_PROP_RW Size kernel, stride, pad, dilation; CV_PROP_RW Size kernel, stride, pad, dilation;
CV_PROP_RW String padMode;
}; };
class CV_EXPORTS_W ConvolutionLayer : public BaseConvolutionLayer class CV_EXPORTS_W ConvolutionLayer : public BaseConvolutionLayer
...@@ -238,9 +239,12 @@ namespace dnn ...@@ -238,9 +239,12 @@ namespace dnn
CV_PROP_RW int type; CV_PROP_RW int type;
CV_PROP_RW int size; CV_PROP_RW int size;
CV_PROP_RW double alpha, beta; CV_PROP_RW double alpha, beta, bias;
CV_PROP_RW bool normBySize;
static CV_WRAP Ptr<LRNLayer> create(int type = LRNLayer::CHANNEL_NRM, int size = 5, double alpha = 1, double beta = 0.75); static CV_WRAP Ptr<LRNLayer> create(int type = LRNLayer::CHANNEL_NRM, int size = 5,
double alpha = 1, double beta = 0.75, double bias = 1,
bool normBySize = true);
}; };
class CV_EXPORTS_W PoolingLayer : public Layer class CV_EXPORTS_W PoolingLayer : public Layer
...@@ -257,8 +261,11 @@ namespace dnn ...@@ -257,8 +261,11 @@ namespace dnn
CV_PROP_RW int type; CV_PROP_RW int type;
CV_PROP_RW Size kernel, stride, pad; CV_PROP_RW Size kernel, stride, pad;
CV_PROP_RW bool globalPooling; CV_PROP_RW bool globalPooling;
CV_PROP_RW String padMode;
static CV_WRAP Ptr<PoolingLayer> create(int type = PoolingLayer::MAX, Size kernel = Size(2, 2), Size stride = Size(1, 1), Size pad = Size(0, 0)); static CV_WRAP Ptr<PoolingLayer> create(int type = PoolingLayer::MAX, Size kernel = Size(2, 2),
Size stride = Size(1, 1), Size pad = Size(0, 0),
const cv::String& padMode = "");
static CV_WRAP Ptr<PoolingLayer> createGlobal(int type = PoolingLayer::MAX); static CV_WRAP Ptr<PoolingLayer> createGlobal(int type = PoolingLayer::MAX);
}; };
...@@ -294,7 +301,8 @@ namespace dnn ...@@ -294,7 +301,8 @@ namespace dnn
CV_PROP_RW BlobShape newShapeDesc; CV_PROP_RW BlobShape newShapeDesc;
CV_PROP_RW Range newShapeRange; CV_PROP_RW Range newShapeRange;
static CV_WRAP Ptr<ReshapeLayer> create(const BlobShape &newShape, Range applyingRange = Range::all()); static CV_WRAP Ptr<ReshapeLayer> create(const BlobShape &newShape, Range applyingRange = Range::all(),
bool enableReordering = false);
}; };
class CV_EXPORTS_W ConcatLayer : public Layer class CV_EXPORTS_W ConcatLayer : public Layer
......
...@@ -299,6 +299,12 @@ namespace dnn //! This namespace is used for dnn module functionlaity. ...@@ -299,6 +299,12 @@ namespace dnn //! This namespace is used for dnn module functionlaity.
*/ */
CV_EXPORTS_W Net readNetFromCaffe(const String &prototxt, const String &caffeModel = String()); CV_EXPORTS_W Net readNetFromCaffe(const String &prototxt, const String &caffeModel = String());
/** @brief Creates the importer of <a href="http://www.tensorflow.org">TensorFlow</a> framework network.
* @param model path to the .pb file with binary protobuf description of the network architecture.
* @returns Pointer to the created importer, NULL in failure cases.
*/
CV_EXPORTS Ptr<Importer> createTensorflowImporter(const String &model);
/** @brief Creates the importer of <a href="http://torch.ch">Torch7</a> framework network. /** @brief Creates the importer of <a href="http://torch.ch">Torch7</a> framework network.
* @param filename path to the file, dumped from Torch by using torch.save() function. * @param filename path to the file, dumped from Torch by using torch.save() function.
* @param isBinary specifies whether the network was serialized in ascii mode or binary. * @param isBinary specifies whether the network was serialized in ascii mode or binary.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -159,6 +159,7 @@ struct Net::Impl ...@@ -159,6 +159,7 @@ struct Net::Impl
inpl.name = "_input"; inpl.name = "_input";
inpl.type = "__NetInputLayer__"; inpl.type = "__NetInputLayer__";
inpl.layerInstance = netInputLayer; inpl.layerInstance = netInputLayer;
layerNameToId.insert(std::make_pair(inpl.name, inpl.id));
lastLayerId = 1; lastLayerId = 1;
netWasAllocated = false; netWasAllocated = false;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment