Remove OpenCV dependency from CNTK core
commit aecc380d21e04e803d683e25af2aac42c1a90125 Author: Manik Jindal <manikj@microsoft.com> Date: Thu Nov 16 15:03:13 2017 -0800 Remove OpenCV dependency from CNTK core Tensorboard's Image feature has a hard dependency on OpenCV and Tensorboard is a part of CNTK core. Removing this hard dependency by creating a new DLL ImageWriter just to write an image an PNG.
This commit is contained in:
Родитель
db2e817cdc
Коммит
e4b8e85ef3
19
CNTK.sln
19
CNTK.sln
|
@ -369,6 +369,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EvalDll", "Source\EvalDll\E
|
|||
{EAD17188-072C-4726-B840-A769C36DAD1B} = {EAD17188-072C-4726-B840-A769C36DAD1B}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageWriterDll", "Source\ImageWriterDll\ImageWriterDll.vcxproj", "{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{86883653-8A61-4038-81A0-2379FAE4200A} = {86883653-8A61-4038-81A0-2379FAE4200A}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Math", "Source\Math\Math.vcxproj", "{60BDB847-D0C4-4FD3-A947-0C15C08BCDB5}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{86883653-8A61-4038-81A0-2379FAE4200A} = {86883653-8A61-4038-81A0-2379FAE4200A}
|
||||
|
@ -854,6 +859,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CNTKv2LibraryDll", "Source\
|
|||
{86883653-8A61-4038-81A0-2379FAE4200A} = {86883653-8A61-4038-81A0-2379FAE4200A}
|
||||
{F0A9637C-20DA-42F0-83D4-23B4704DE602} = {F0A9637C-20DA-42F0-83D4-23B4704DE602}
|
||||
{EAD17188-072C-4726-B840-A769C36DAD1B} = {EAD17188-072C-4726-B840-A769C36DAD1B}
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D} = {2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "V2LibraryTests", "Tests\UnitTests\V2LibraryTests\V2LibraryTests.vcxproj", "{F4CC3AB2-0DB2-4281-929A-2E68E30F0F6E}"
|
||||
|
@ -1733,6 +1739,18 @@ Global
|
|||
{482999D1-B7E2-466E-9F8D-2119F93EAFD9}.Release_UWP|x64.ActiveCfg = Release_CpuOnly|x64
|
||||
{482999D1-B7E2-466E-9F8D-2119F93EAFD9}.Release|x64.ActiveCfg = Release|x64
|
||||
{482999D1-B7E2-466E-9F8D-2119F93EAFD9}.Release|x64.Build.0 = Release|x64
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}.Debug_CpuOnly|x64.ActiveCfg = Debug_CpuOnly|x64
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}.Debug_CpuOnly|x64.Build.0 = Debug_CpuOnly|x64
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}.Debug_UWP|x64.ActiveCfg = Debug_CpuOnly|x64
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}.Debug|x64.Build.0 = Debug|x64
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}.Release_CpuOnly|x64.ActiveCfg = Release_CpuOnly|x64
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}.Release_CpuOnly|x64.Build.0 = Release_CpuOnly|x64
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}.Release_NoOpt|x64.ActiveCfg = Release_NoOpt|x64
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}.Release_NoOpt|x64.Build.0 = Release_NoOpt|x64
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}.Release_UWP|x64.ActiveCfg = Release_NoOpt|x64
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}.Release|x64.ActiveCfg = Release|x64
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}.Release|x64.Build.0 = Release|x64
|
||||
{60BDB847-D0C4-4FD3-A947-0C15C08BCDB5}.Debug_CpuOnly|x64.ActiveCfg = Debug_CpuOnly|x64
|
||||
{60BDB847-D0C4-4FD3-A947-0C15C08BCDB5}.Debug_CpuOnly|x64.Build.0 = Debug_CpuOnly|x64
|
||||
{60BDB847-D0C4-4FD3-A947-0C15C08BCDB5}.Debug_UWP|x64.ActiveCfg = Debug_UWP|x64
|
||||
|
@ -2360,6 +2378,7 @@ Global
|
|||
{3CE841C0-02E5-46DB-B401-6F8784880173} = {47755F2E-D674-4175-9E38-8EA053455072}
|
||||
{A4FC3467-4787-43E8-BBC0-D79AE56B468D} = {6F19321A-65E7-4829-B00C-3886CD6C6EDE}
|
||||
{482999D1-B7E2-466E-9F8D-2119F93EAFD9} = {DD043083-71A4-409A-AA91-F9C548DCF7EC}
|
||||
{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D} = {DD043083-71A4-409A-AA91-F9C548DCF7EC}
|
||||
{60BDB847-D0C4-4FD3-A947-0C15C08BCDB5} = {DD043083-71A4-409A-AA91-F9C548DCF7EC}
|
||||
{B3DD765E-694E-4494-BAD7-37BBF2942517} = {DD043083-71A4-409A-AA91-F9C548DCF7EC}
|
||||
{D667AF32-028A-4A5D-BE19-F46776F0F6B2} = {33EBFE78-A1A8-4961-8938-92A271941F94}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
# CNTK v2.3 Release Notes
|
||||
|
||||
### Highlights of this Release
|
||||
- OpenCV is not required to install CNTK but to use Tensorboard Image feature.
|
||||
|
||||
### Python-binding for CNTK
|
||||
Support for Python 3.4 will be removed from CNTK releases later than v2.3.
|
||||
|
||||
|
|
42
Makefile
42
Makefile
|
@ -531,13 +531,11 @@ PYTHON_LIBS+=$(CNTKLIBRARY_LIB)
|
|||
JAVA_LIBS+=$(CNTKLIBRARY_LIB)
|
||||
SRC+=$(CNTKLIBRARY_SRC)
|
||||
|
||||
OPENCV_LIBS:=-lopencv_core -lopencv_imgproc -lopencv_imgcodecs
|
||||
|
||||
$(CNTKLIBRARY_LIB): $(CNTKLIBRARY_OBJ) | $(CNTKMATH_LIB)
|
||||
@echo $(SEPARATOR)
|
||||
@mkdir -p $(dir $@)
|
||||
@echo building $@ for $(ARCH) with build type $(BUILDTYPE)
|
||||
$(CXX) $(LDFLAGS) -shared $(patsubst %,-L%, $(LIBDIR) $(LIBPATH) $(GDK_NVML_LIB_PATH)) $(patsubst %,$(RPATH)%, $(ORIGINDIR) $(LIBPATH)) -o $@ $^ $(LIBS) $(OPENCV_LIBS) -l$(CNTKMATH) $(PROTOBUF_PATH)/lib/libprotobuf.a -ldl -fopenmp
|
||||
$(CXX) $(LDFLAGS) -shared $(patsubst %,-L%, $(LIBDIR) $(LIBPATH) $(GDK_NVML_LIB_PATH)) $(patsubst %,$(RPATH)%, $(ORIGINDIR) $(LIBPATH)) -o $@ $^ $(LIBS) -l$(CNTKMATH) $(PROTOBUF_PATH)/lib/libprotobuf.a -ldl -fopenmp
|
||||
|
||||
|
||||
########################################
|
||||
|
@ -600,7 +598,7 @@ $(PROPOSAL_LAYER_LIB): $(PROPOSAL_LAYER_LIBRARY_OBJ) | $(CNTKLIBRARY_LIB)
|
|||
@echo $(SEPARATOR)
|
||||
@echo creating $@ for $(ARCH) with build type $(BUILDTYPE)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CXX) $(LDFLAGS) -shared $(patsubst %,-L%, $(LIBDIR) $(LIBPATH)) $(patsubst %,$(RPATH)%, $(LIBDIR) $(LIBPATH) $(ORIGINDIR)) -o $@ $^ -l$(CNTKLIBRARY) $(OPENCV_LIBS)
|
||||
$(CXX) $(LDFLAGS) -shared $(patsubst %,-L%, $(LIBDIR) $(LIBPATH)) $(patsubst %,$(RPATH)%, $(LIBDIR) $(LIBPATH) $(ORIGINDIR)) -o $@ $^ -l$(CNTKLIBRARY)
|
||||
|
||||
|
||||
########################################
|
||||
|
@ -665,7 +663,7 @@ $(EVAL_CLIENT): $(EVAL_CLIENT_OBJ) | $(EVAL_LIB) $(READER_LIBS)
|
|||
@echo $(SEPARATOR)
|
||||
@mkdir -p $(dir $@)
|
||||
@echo building $(EVAL_CLIENT) for $(ARCH) with build type $(BUILDTYPE)
|
||||
$(CXX) $(LDFLAGS) $(patsubst %,-L%, $(LIBDIR) $(LIBPATH) $(GDK_NVML_LIB_PATH)) $(patsubst %,$(RPATH)%, $(ORIGINLIBDIR) $(LIBPATH)) -o $@ $^ $(LIBS) -l$(EVAL) $(L_READER_LIBS) $(lMULTIVERSO) $(OPENCV_LIBS)
|
||||
$(CXX) $(LDFLAGS) $(patsubst %,-L%, $(LIBDIR) $(LIBPATH) $(GDK_NVML_LIB_PATH)) $(patsubst %,$(RPATH)%, $(ORIGINLIBDIR) $(LIBPATH)) -o $@ $^ $(LIBS) -l$(EVAL) $(L_READER_LIBS) $(lMULTIVERSO)
|
||||
|
||||
EVAL_EXTENDED_CLIENT:=$(BINDIR)/cppevalextendedclient
|
||||
|
||||
|
@ -681,7 +679,7 @@ $(EVAL_EXTENDED_CLIENT): $(EVAL_EXTENDED_CLIENT_OBJ) | $(EVAL_LIB) $(READER_LIBS
|
|||
@echo $(SEPARATOR)
|
||||
@mkdir -p $(dir $@)
|
||||
@echo building $(EVAL_EXTENDED_CLIENT) for $(ARCH) with build type $(BUILDTYPE)
|
||||
$(CXX) $(LDFLAGS) $(patsubst %,-L%, $(LIBDIR) $(LIBPATH) $(GDK_NVML_LIB_PATH)) $(patsubst %,$(RPATH)%, $(ORIGINLIBDIR) $(LIBPATH)) -o $@ $^ $(LIBS) -l$(EVAL) $(L_READER_LIBS) $(lMULTIVERSO) $(OPENCV_LIBS)
|
||||
$(CXX) $(LDFLAGS) $(patsubst %,-L%, $(LIBDIR) $(LIBPATH) $(GDK_NVML_LIB_PATH)) $(patsubst %,$(RPATH)%, $(ORIGINLIBDIR) $(LIBPATH)) -o $@ $^ $(LIBS) -l$(EVAL) $(L_READER_LIBS) $(lMULTIVERSO)
|
||||
|
||||
########################################
|
||||
# Eval V2 Sample client
|
||||
|
@ -1009,6 +1007,32 @@ $(IMAGEREADER): $(IMAGEREADER_OBJ) | $(CNTKMATH_LIB)
|
|||
endif
|
||||
endif
|
||||
|
||||
########################################
|
||||
# ImageWriter plugin
|
||||
########################################
|
||||
|
||||
ifdef OPENCV_PATH
|
||||
IMAGEWRITER_LIBS_LIST := opencv_core opencv_imgproc opencv_imgcodecs
|
||||
IMAGEWRITER_LIBS:= $(addprefix -l,$(IMAGEWRITER_LIBS_LIST))
|
||||
|
||||
IMAGEWRITER_SRC =\
|
||||
$(SOURCEDIR)/ImageWriterDll/ImageWriter.cpp \
|
||||
|
||||
IMAGEWRITER_OBJ := $(patsubst %.cpp, $(OBJDIR)/%.o, $(IMAGEWRITER_SRC))
|
||||
|
||||
IMAGEWRITER:=$(LIBDIR)/Cntk.ImageWriter-$(CNTK_COMPONENT_VERSION).so
|
||||
ALL_LIBS += $(IMAGEWRITER)
|
||||
PYTHON_LIBS += $(IMAGEWRITER)
|
||||
SRC+=$(IMAGEWRITER_SRC)
|
||||
|
||||
INCLUDEPATH += $(OPENCV_PATH)/include
|
||||
LIBPATH += $(OPENCV_PATH)/lib $(OPENCV_PATH)/release/lib
|
||||
|
||||
$(IMAGEWRITER): $(IMAGEWRITER_OBJ)
|
||||
@echo $(SEPARATOR)
|
||||
$(CXX) $(LDFLAGS) -shared $(patsubst %,-L%, $(LIBDIR) $(LIBPATH)) $(patsubst %,$(RPATH)%, $(ORIGINDIR) $(LIBPATH)) -o $@ $^ $(IMAGEWRITER_LIBS)
|
||||
endif
|
||||
|
||||
########################################
|
||||
# 1bit SGD setup
|
||||
########################################
|
||||
|
@ -1131,7 +1155,7 @@ $(CNTK): $(CNTK_OBJ) | $(READER_LIBS) $(MULTIVERSO_LIB)
|
|||
@echo $(SEPARATOR)
|
||||
@mkdir -p $(dir $@)
|
||||
@echo building $@ for $(ARCH) with build type $(BUILDTYPE)
|
||||
$(CXX) $(LDFLAGS) $(patsubst %,-L%, $(LIBDIR) $(LIBPATH) $(GDK_NVML_LIB_PATH)) $(patsubst %,$(RPATH)%, $(ORIGINLIBDIR) $(LIBPATH)) -o $@ $^ $(LIBS) $(L_READER_LIBS) $(lMULTIVERSO) -ldl -fopenmp $(PROTOBUF_PATH)/lib/libprotobuf.a $(OPENCV_LIBS)
|
||||
$(CXX) $(LDFLAGS) $(patsubst %,-L%, $(LIBDIR) $(LIBPATH) $(GDK_NVML_LIB_PATH)) $(patsubst %,$(RPATH)%, $(ORIGINLIBDIR) $(LIBPATH)) -o $@ $^ $(LIBS) $(L_READER_LIBS) $(lMULTIVERSO) -ldl -fopenmp $(PROTOBUF_PATH)/lib/libprotobuf.a
|
||||
|
||||
# deployable resources: standard library of BS
|
||||
CNTK_CORE_BS:=$(BINDIR)/cntk.core.bs
|
||||
|
@ -1204,7 +1228,7 @@ $(UNITTEST_EVAL) : $(UNITTEST_EVAL_OBJ) | $(EVAL_LIB) $(READER_LIBS)
|
|||
@echo $(SEPARATOR)
|
||||
@mkdir -p $(dir $@)
|
||||
@echo building $@ for $(ARCH) with build type $(BUILDTYPE)
|
||||
$(CXX) $(LDFLAGS) $(patsubst %,-L%, $(LIBDIR) $(LIBPATH) $(GDK_NVML_LIB_PATH) $(BOOSTLIB_PATH)) $(patsubst %, $(RPATH)%, $(ORIGINLIBDIR) $(LIBPATH) $(BOOSTLIB_PATH)) -o $@ $^ $(BOOSTLIBS) $(LIBS) -l$(EVAL) $(L_READER_LIBS) $(lMULTIVERSO) $(OPENCV_LIBS)
|
||||
$(CXX) $(LDFLAGS) $(patsubst %,-L%, $(LIBDIR) $(LIBPATH) $(GDK_NVML_LIB_PATH) $(BOOSTLIB_PATH)) $(patsubst %, $(RPATH)%, $(ORIGINLIBDIR) $(LIBPATH) $(BOOSTLIB_PATH)) -o $@ $^ $(BOOSTLIBS) $(LIBS) -l$(EVAL) $(L_READER_LIBS) $(lMULTIVERSO)
|
||||
|
||||
#TODO: create project specific makefile or rules to avoid adding project specific path to the global path
|
||||
INCLUDEPATH += $(SOURCEDIR)/Readers/CNTKTextFormatReader
|
||||
|
@ -1271,7 +1295,7 @@ $(UNITTEST_NETWORK): $(UNITTEST_NETWORK_OBJ) | $(READER_LIBS) $(CNTKTEXTFORMATRE
|
|||
@echo $(SEPARATOR)
|
||||
@mkdir -p $(dir $@)
|
||||
@echo building $@ for $(ARCH) with build type $(BUILDTYPE)
|
||||
$(CXX) $(LDFLAGS) $(patsubst %,-L%, $(LIBDIR) $(LIBPATH) $(GDK_NVML_LIB_PATH) $(BOOSTLIB_PATH)) $(patsubst %, $(RPATH)%, $(ORIGINLIBDIR) $(LIBPATH) $(BOOSTLIB_PATH)) -o $@ $^ $(BOOSTLIBS) $(LIBS) $(lMULTIVERSO) $(L_READER_LIBS) -ldl -fopenmp $(PROTOBUF_PATH)/lib/libprotobuf.a $(OPENCV_LIBS)
|
||||
$(CXX) $(LDFLAGS) $(patsubst %,-L%, $(LIBDIR) $(LIBPATH) $(GDK_NVML_LIB_PATH) $(BOOSTLIB_PATH)) $(patsubst %, $(RPATH)%, $(ORIGINLIBDIR) $(LIBPATH) $(BOOSTLIB_PATH)) -o $@ $^ $(BOOSTLIBS) $(LIBS) $(lMULTIVERSO) $(L_READER_LIBS) -ldl -fopenmp $(PROTOBUF_PATH)/lib/libprotobuf.a
|
||||
|
||||
UNITTEST_MATH_SRC = \
|
||||
$(SOURCEDIR)/../Tests/UnitTests/MathTests/BatchNormalizationEngineTests.cpp \
|
||||
|
|
|
@ -67,16 +67,14 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>.\API;.\proto;$(BOOST_INCLUDE_PATH);$(SolutionDir)\Source\CNTKv2LibraryDll;$(SolutionDir)Source\SGDLib;$(SolutionDir)Source\Readers\ReaderLib;$(SolutionDir)Source\ComputationNetworkLib;$(SolutionDir)Source\SequenceTrainingLib;$(SolutionDir)Source\Math;$(SolutionDir)Source\Common\Include;$(SolutionDir)Source\CNTK\BrainScript;$(SolutionDir)Source\ActionsLib;$(MSMPI_INC);$(NvmlInclude);$(ProtobufInclude);$(SolutionDir)Source\PerformanceProfilerDll;$(OpenCvInclude)</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>.\API;.\proto;$(BOOST_INCLUDE_PATH);$(SolutionDir)\Source\CNTKv2LibraryDll;$(SolutionDir)Source\SGDLib;$(SolutionDir)Source\Readers\ReaderLib;$(SolutionDir)Source\ComputationNetworkLib;$(SolutionDir)Source\SequenceTrainingLib;$(SolutionDir)Source\Math;$(SolutionDir)Source\Common\Include;$(SolutionDir)Source\CNTK\BrainScript;$(SolutionDir)Source\ActionsLib;$(MSMPI_INC);$(NvmlInclude);$(ProtobufInclude);$(SolutionDir)Source\PerformanceProfilerDll</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories Condition="'$(CNTK_ENABLE_1BitSGD)'=='true' and '!$(IsUWP)'">$(SolutionDir)Source\1BitSGD;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(CNTK_ENABLE_1BitSGD)'=='true' and '!$(IsUWP)'">CNTK_PARALLEL_TRAINING_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)Source\ComputationNetworkLib;$(SolutionDir)Source\Math;$(MSMPI_LIB64);$(SolutionDir)$(Platform)\$(Configuration);$(NvmlLibPath);$(ProtobufLibPath)</AdditionalLibraryDirectories>
|
||||
<AdditionalLibraryDirectories Condition="!$(IsUWP)">$(OpenCvLibPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>$(ReaderLibs);Cntk.Common$(OutputSuffix)-$(CntkComponentVersion).lib;Cntk.ComputationNetwork$(OutputSuffix)-$(CntkComponentVersion).lib;Cntk.SequenceTrainingLib$(OutputSuffix)-$(CntkComponentVersion).lib;$(ProtobufLib);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies Condition="!$(IsUWP)">$(OpenCvLib);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>prebuild.bat "$(Configuration)" "$(CNTK_MKL_SEQUENTIAL)" "$(CNTK_ENABLE_1BitSGD)" "$(CudaPath)" "$(CUDNN_PATH)" "$(CUB_PATH)" "$(CNTK_ENABLE_ASGD)"</Command>
|
||||
|
@ -96,7 +94,7 @@
|
|||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<DelayLoadDLLs>Cntk.Math$(OutputSuffix)-$(CntkComponentVersion).dll; nvml.dll; $(CudaRuntimeDll); msmpi.dll;</DelayLoadDLLs>
|
||||
<DelayLoadDLLs Condition="!$(IsUWP)">%(DelayLoadDLLs); Cntk.PerformanceProfiler-$(CntkComponentVersion).dll</DelayLoadDLLs>
|
||||
<DelayLoadDLLs Condition="!$(IsUWP)">%(DelayLoadDLLs); Cntk.PerformanceProfiler-$(CntkComponentVersion).dll;Cntk.ImageWriter-$(CntkComponentVersion).dll</DelayLoadDLLs>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="$(ReleaseBuild)">
|
||||
|
@ -114,7 +112,7 @@
|
|||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<DelayLoadDLLs>Cntk.Math$(OutputSuffix)-$(CntkComponentVersion).dll; nvml.dll; $(CudaRuntimeDll); msmpi.dll;</DelayLoadDLLs>
|
||||
<DelayLoadDLLs Condition="!$(IsUWP)">%(DelayLoadDLLs); Cntk.PerformanceProfiler-$(CntkComponentVersion).dll</DelayLoadDLLs>
|
||||
<DelayLoadDLLs Condition="!$(IsUWP)">%(DelayLoadDLLs); Cntk.PerformanceProfiler-$(CntkComponentVersion).dll;Cntk.ImageWriter-$(CntkComponentVersion).dll</DelayLoadDLLs>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="$(CpuOnlyBuild)">
|
||||
|
@ -125,7 +123,7 @@
|
|||
</ClCompile>
|
||||
<Link>
|
||||
<DelayLoadDLLs>Cntk.Math$(OutputSuffix)-$(CntkComponentVersion).dll; msmpi.dll;</DelayLoadDLLs>
|
||||
<DelayLoadDLLs Condition="!$(IsUWP)">%(DelayLoadDLLs); Cntk.PerformanceProfiler-$(CntkComponentVersion).dll</DelayLoadDLLs>
|
||||
<DelayLoadDLLs Condition="!$(IsUWP)">%(DelayLoadDLLs); Cntk.PerformanceProfiler-$(CntkComponentVersion).dll;Cntk.ImageWriter-$(CntkComponentVersion).dll</DelayLoadDLLs>
|
||||
<OptimizeReferences Condition="'$(Configuration)|$(Platform)'=='Debug_CpuOnly|x64'">false</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
|
|
@ -200,10 +200,8 @@ namespace CNTK
|
|||
extent.push_back(width);
|
||||
extent.push_back(depth);
|
||||
extent.push_back(1);
|
||||
const int compression = -1;
|
||||
|
||||
const std::vector<size_t> imageDim({height, width, depth});
|
||||
NDShape imageShape(imageDim);
|
||||
|
||||
for (size_t i = 0; i < batch_size; i++) {
|
||||
tensorflow::Summary::Value* summaryValue = summary->add_value();
|
||||
|
@ -215,16 +213,16 @@ namespace CNTK
|
|||
summaryImage->set_colorspace(depth);
|
||||
start.back() = static_cast<size_t>(i);
|
||||
auto image = imageData->SliceView(start, extent)->AsShape(imageDim);
|
||||
vector<uchar> buffer;
|
||||
vector<unsigned char> buffer;
|
||||
|
||||
switch (dtype)
|
||||
{
|
||||
case DataType::Float:
|
||||
WriteImageToBuffer(image->WritableDataBuffer<float>(), height, width, CV_32FC(depth), buffer);
|
||||
WriteImageToBuffer(image->WritableDataBuffer<float>(), dtype, height, width, depth, buffer);
|
||||
break;
|
||||
|
||||
case DataType::Double:
|
||||
WriteImageToBuffer(image->WritableDataBuffer<double>(), height, width, CV_64FC(depth), buffer);
|
||||
WriteImageToBuffer(image->WritableDataBuffer<double>(), dtype, height, width, depth, buffer);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -238,7 +236,8 @@ namespace CNTK
|
|||
|
||||
WriteRecord(Serialize(event));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // !CNTK_UWP
|
||||
|
||||
void TensorBoardFileWriter::WriteVersion(time_t time)
|
||||
{
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#pragma warning(pop)
|
||||
|
||||
#include "Utils.h"
|
||||
#include "Basics.h"
|
||||
|
||||
namespace CNTK
|
||||
{
|
||||
|
@ -264,27 +265,20 @@ namespace CNTK
|
|||
|
||||
#ifndef CNTK_UWP
|
||||
|
||||
// Ensure OpenCV's imgproc library appears as direct dependency at link
|
||||
// time so rpath will apply (Linux). // TODO find a better way
|
||||
void _dummyRefForOpenCVImgProc()
|
||||
void WriteImageToBuffer(void* matrix, DataType dtype, int height, int width, int depth, std::vector<unsigned char>& buffer)
|
||||
{
|
||||
cvThreshHist(0, 0.0);
|
||||
}
|
||||
typedef void(*EncodeImageAsPNG)(void* matrix, DataType dtype, int height, int width, int depth, std::vector<unsigned char>& buffer);
|
||||
static EncodeImageAsPNG encodeImageAsPNG = nullptr;
|
||||
|
||||
void WriteImageToBuffer(void* matrix, int height, int weight, int dataType, std::vector<uchar>& buffer)
|
||||
{
|
||||
assert(matrix != nullptr);
|
||||
assert(&buffer != nullptr);
|
||||
vector<int> parameters = vector<int>(2);
|
||||
parameters[0] = CV_IMWRITE_PNG_COMPRESSION;
|
||||
parameters[1] = 3;//default(3) 0-9
|
||||
cv::Mat source = cv::Mat(height, weight, dataType, matrix);
|
||||
|
||||
if (!imencode(".png", source, buffer, parameters)) {
|
||||
fprintf(stderr, "TensorBoardFileWriter: PNG encoding failed. ");
|
||||
return;
|
||||
if (encodeImageAsPNG == nullptr)
|
||||
{
|
||||
Microsoft::MSR::CNTK::Plugin plugin;
|
||||
encodeImageAsPNG = (EncodeImageAsPNG)plugin.Load(L"ImageWriter", "EncodeImageAsPNG");
|
||||
}
|
||||
|
||||
encodeImageAsPNG(matrix, dtype, height, width, depth, buffer);
|
||||
}
|
||||
|
||||
#endif // !CNTK_UWP
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,6 @@
|
|||
#include "stdafx.h"
|
||||
#include "CNTKLibrary.h"
|
||||
|
||||
#ifndef CNTK_UWP
|
||||
#include <opencv2/core/mat.hpp>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include "opencv2/core/types.hpp"
|
||||
#endif
|
||||
|
||||
namespace tensorflow
|
||||
{
|
||||
class GraphDef;
|
||||
|
@ -29,7 +23,7 @@ namespace CNTK
|
|||
void CreateTensorBoardGraph(const FunctionPtr& src, tensorflow::GraphDef& dst);
|
||||
|
||||
#ifndef CNTK_UWP
|
||||
void WriteImageToBuffer(void* matrix, int height, int weight, int dataType, std::vector<uchar>& buffer);
|
||||
void WriteImageToBuffer(void* matrix, DataType dtype, int height, int width, int depth, std::vector<unsigned char>& buffer);
|
||||
#endif // !CNTK_UWP
|
||||
|
||||
}
|
||||
|
|
|
@ -1013,6 +1013,9 @@ static const std::unordered_map<std::wstring, std::wstring> s_deprecatedReaderWr
|
|||
{ L"CNTKTextFormatReader", L"Cntk.Deserializers.TextFormat" },
|
||||
{ L"CNTKBinaryReader", L"Cntk.Deserializers.Binary" },
|
||||
{ L"ImageReader", L"Cntk.Deserializers.Image" },
|
||||
|
||||
// Image writer
|
||||
{ L"ImageWriter", L"Cntk.ImageWriter" },
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
|
||||
//
|
||||
// ImageWriter.cpp : Defines the exported functions for the ImageWriter DLL.
|
||||
//
|
||||
|
||||
#define IMAGEWRITER_EXPORTS // creating the exports here
|
||||
#include "ImageWriter.h"
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/core/mat.hpp>
|
||||
|
||||
namespace Microsoft { namespace MSR { namespace CNTK {
|
||||
|
||||
// Ensure OpenCV's imgproc library appears as direct dependency at link
|
||||
// time so rpath will apply (Linux). // TODO find a better way
|
||||
void _dummyRefForOpenCVImgProc()
|
||||
{
|
||||
cvThreshHist(0, 0.0);
|
||||
}
|
||||
|
||||
extern "C" IMAGEWRITER_API void EncodeImageAsPNG(void* matrix, ::CNTK::DataType dtype, int height, int width, int depth, std::vector<unsigned char>& buffer)
|
||||
{
|
||||
assert(matrix != nullptr);
|
||||
assert(&buffer != nullptr);
|
||||
assert(dtype == ::CNTK::DataType::Float || dtype == ::CNTK::DataType::Double);
|
||||
|
||||
int cvDataType = dtype == ::CNTK::DataType::Float ? CV_32FC(depth) : CV_64FC(depth);
|
||||
cv::Mat source = cv::Mat(height, width, cvDataType, matrix);
|
||||
std::vector<int> parameters = std::vector<int>(2);
|
||||
parameters[0] = CV_IMWRITE_PNG_COMPRESSION;
|
||||
parameters[1] = 3; //default(3) 0-9
|
||||
|
||||
if (!imencode(".png", source, buffer, parameters)) {
|
||||
fprintf(stderr, "ImageWriter: PNG encoding failed.");
|
||||
}
|
||||
}
|
||||
|
||||
} } }
|
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
// The following ifdef block is the standard way of creating macros which make exporting
|
||||
// from a DLL simpler. All files within this DLL are compiled with the IMAGEWRITER_EXPORTS
|
||||
// symbol defined on the command line. This symbol should not be defined on any project
|
||||
// that uses this DLL. This way any other project whose source files include this file see
|
||||
// IMAGEWRITER_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
// defined with this macro as being exported.
|
||||
#ifdef _WIN32
|
||||
#if defined(IMAGEWRITER_EXPORTS)
|
||||
#define IMAGEWRITER_API __declspec(dllexport)
|
||||
#elif defined(IMAGEWRITER_LOCAL)
|
||||
#define IMAGEWRITER_API
|
||||
#else
|
||||
#define IMAGEWRITER_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define IMAGEWRITER_API
|
||||
#endif
|
||||
|
||||
// TODO: Fix CNTKLibrary.h and CNTKLibraryInternals.h for CNTK_HEADERONLY_DEFINITIONS.
|
||||
#include "CNTKLibraryInternals.h"
|
||||
#define CNTK_HEADERONLY_DEFINITIONS
|
||||
#include "CNTKLibrary.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Microsoft { namespace MSR { namespace CNTK {
|
||||
|
||||
extern "C" IMAGEWRITER_API void EncodeImageAsPNG(void* matrix, ::CNTK::DataType dtype, int height, int width, int depth, std::vector<unsigned char>& buffer);
|
||||
|
||||
} } }
|
|
@ -0,0 +1,138 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_NoOpt|x64">
|
||||
<Configuration>Release_NoOpt</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug_CpuOnly|x64">
|
||||
<Configuration>Debug_CpuOnly</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_CpuOnly|x64">
|
||||
<Configuration>Release_CpuOnly</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{2ECE5AEB-F471-4A1D-9BAD-963D5C8A8A1D}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>ImageWriterDll</RootNamespace>
|
||||
<ProjectName>ImageWriterDll</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\CNTK.Cpp.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="$(DebugBuild)" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(ReleaseBuild)" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="$(DebugBuild)">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>Cntk.ImageWriter-$(CntkComponentVersion)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(ReleaseBuild)">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>Cntk.ImageWriter-$(CntkComponentVersion)</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)Source\Common\Include;$(SolutionDir)Source\CNTKv2LibraryDll\API;$(OpenCvInclude)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)$(Platform)\$(Configuration);$(OpenCvLibPath)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>Cntk.Common-$(CntkComponentVersion).lib;$(OpenCvLib);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="$(DebugBuild)">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="$(ReleaseBuild)">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<AdditionalOptions>/d2Zi+ /bigobj %(AdditionalOptions)</AdditionalOptions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<Profile>true</Profile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="$(CpuOnlyBuild)">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>CPUONLY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<PostBuildEvent>
|
||||
<Command>
|
||||
if "$(HasOpenCv)" == "true" xcopy /I /D /Y "$(OpenCvBinPath)\$(OpenCvWorld).dll" "$(TargetDir)"
|
||||
</Command>
|
||||
<Message>Copying OpenCv dll to target folder</Message>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ImageWriter.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<CompileAsManaged>false</CompileAsManaged>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ImageWriter.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<Target Name="CheckDependencies">
|
||||
<Error Condition="!$(HasOpenCv)" Text="ImageReaderDll requires OpenCv to build. Please see https://docs.microsoft.com/en-us/cognitive-toolkit/Setup-CNTK-on-Windows#optional-opencv for installation instructions." />
|
||||
</Target>
|
||||
</Project>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ImageWriter.cpp" />
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>Misc</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ImageWriter.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,30 @@
|
|||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
|
||||
//
|
||||
// dllmain.cpp : Defines the entry point for the DLL application.
|
||||
//
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include "Windows.h"
|
||||
#endif
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE /*hModule*/,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID /*lpReserved*/
|
||||
)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
Загрузка…
Ссылка в новой задаче