diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index ca2e3ad9e5e..59cf3605a9e 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -43,13 +43,13 @@ list(APPEND Caffe_LINKER_LIBS PUBLIC ${GFLAGS_LIBRARIES}) include(cmake/ProtoBuf.cmake) # ---[ HDF5 -find_package(HDF5 COMPONENTS HL REQUIRED) -list(APPEND Caffe_INCLUDE_DIRS PUBLIC ${HDF5_INCLUDE_DIRS}) -list(APPEND Caffe_LINKER_LIBS PUBLIC ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}) + # This code is taken from https://github.com/sh1r0/caffe-android-lib if(USE_HDF5) find_package(HDF5 COMPONENTS HL REQUIRED) + list(APPEND Caffe_INCLUDE_DIRS PUBLIC ${HDF5_INCLUDE_DIRS}) + list(APPEND Caffe_LINKER_LIBS PUBLIC ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}) include_directories(SYSTEM ${HDF5_INCLUDE_DIRS} ${HDF5_HL_INCLUDE_DIR}) list(APPEND Caffe_LINKER_LIBS ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}) add_definitions(-DUSE_HDF5) diff --git a/src/caffe/net.cpp b/src/caffe/net.cpp index 5e844b03899..fb928cfd032 100644 --- a/src/caffe/net.cpp +++ b/src/caffe/net.cpp @@ -771,9 +771,14 @@ void Net::CopyTrainedLayersFrom(const NetParameter& param) { template void Net::CopyTrainedLayersFrom(const string& trained_filename) { - if (H5Fis_hdf5(trained_filename.c_str())) { +#ifdef USE_HDF5 + if (H5Fis_hdf5(trained_filename.c_str())) + { CopyTrainedLayersFromHDF5(trained_filename); - } else { + } + else +#endif + { CopyTrainedLayersFromBinaryProto(trained_filename); } }