Skip to content

Commit

Permalink
files changed for successful build of openpose and caffe
Browse files Browse the repository at this point in the history
  • Loading branch information
franzcrs committed Jun 4, 2024
1 parent e03ad73 commit e0e5833
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 8 deletions.
7 changes: 6 additions & 1 deletion 3rdparty/caffe/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)

cmake_minimum_required(VERSION 2.8.7)
if(POLICY CMP0046)
cmake_policy(SET CMP0046 NEW)
Expand Down Expand Up @@ -50,7 +55,7 @@ include(cmake/Dependencies.cmake)

# ---[ Flags
if(UNIX OR APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")
endif()

caffe_set_caffe_link()
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/caffe/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ DYNAMIC_VERSIONED_NAME_SHORT := $(DYNAMIC_NAME_SHORT).$(DYNAMIC_VERSION_MAJOR).$
DYNAMIC_NAME := $(LIB_BUILD_DIR)/$(DYNAMIC_VERSIONED_NAME_SHORT)
COMMON_FLAGS += -DCAFFE_VERSION=$(DYNAMIC_VERSION_MAJOR).$(DYNAMIC_VERSION_MINOR).$(DYNAMIC_VERSION_REVISION)
# OpenPose: added C++11 flag to avoid crashing in some old GCC compilers
COMMON_FLAGS += -std=c++11
#COMMON_FLAGS += -std=c++11
# OpenPose: end modified

##############################
Expand Down
2 changes: 2 additions & 0 deletions 3rdparty/caffe/cmake/Modules/FindvecLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ find_path(vecLib_INCLUDE_DIR vecLib.h
${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
NO_DEFAULT_PATH)

set(vecLib_INCLUDE_DIR "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/")

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(vecLib DEFAULT_MSG vecLib_INCLUDE_DIR)

Expand Down
29 changes: 28 additions & 1 deletion 3rdparty/caffe/src/caffe/layers/hdf5_data_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <fstream> // NOLINT(readability/streams)
#include <string>
#include <vector>
#include <algorithm>
#include <random>

#include "hdf5.h"
#include "hdf5_hl.h"
Expand Down Expand Up @@ -62,7 +64,13 @@ void HDF5DataLayer<Dtype>::LoadHDF5FileData(const char* filename) {

// Shuffle if needed.
if (this->layer_param_.hdf5_data_param().shuffle()) {
#if __cplusplus < 201703L
std::random_shuffle(data_permutation_.begin(), data_permutation_.end());
#else
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(data_permutation_.begin(), data_permutation_.end(), g);
#endif
DLOG(INFO) << "Successfully loaded " << hdf_blobs_[0]->shape(0)
<< " rows (shuffled)";
} else {
Expand Down Expand Up @@ -105,7 +113,13 @@ void HDF5DataLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,

// Shuffle if needed.
if (this->layer_param_.hdf5_data_param().shuffle()) {
#if __cplusplus < 201703L
std::random_shuffle(file_permutation_.begin(), file_permutation_.end());
#else
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(file_permutation_.begin(), file_permutation_.end(), g);
#endif
}

// Load the first HDF5 file and initialize the line counter.
Expand Down Expand Up @@ -144,17 +158,30 @@ void HDF5DataLayer<Dtype>::Next() {
if (current_file_ == num_files_) {
current_file_ = 0;
if (this->layer_param_.hdf5_data_param().shuffle()) {
#if __cplusplus < 201703L
std::random_shuffle(file_permutation_.begin(),
file_permutation_.end());
#else
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(file_permutation_.begin(), file_permutation_.end(), g);
#endif
}
DLOG(INFO) << "Looping around to first file.";
}
LoadHDF5FileData(
hdf_filenames_[file_permutation_[current_file_]].c_str());
}
current_row_ = 0;
if (this->layer_param_.hdf5_data_param().shuffle())
if (this->layer_param_.hdf5_data_param().shuffle()){
#if __cplusplus < 201703L
std::random_shuffle(data_permutation_.begin(), data_permutation_.end());
#else
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(data_permutation_.begin(), data_permutation_.end(), g);
#endif
}
}
offset_++;
}
Expand Down
4 changes: 4 additions & 0 deletions 3rdparty/caffe/src/caffe/util/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ bool ReadProtoFromBinaryFile(const char* filename, Message* proto) {
CHECK_NE(fd, -1) << "File not found: " << filename;
ZeroCopyInputStream* raw_input = new FileInputStream(fd);
CodedInputStream* coded_input = new CodedInputStream(raw_input);
#if __cplusplus < 201703L
coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912);
#else
coded_input->SetTotalBytesLimit(kProtoReadBytesLimit);
#endif

bool success = proto->ParseFromCodedStream(coded_input);

Expand Down
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)

### VERSION INFO
set(OpenPose_VERSION_MAJOR 1)
set(OpenPose_VERSION_MINOR 7)
Expand Down Expand Up @@ -99,11 +104,11 @@ if (WIN32)
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG:incremental /OPT:REF /OPT:ICF")
elseif (UNIX)
# Turn on C++11
add_definitions(-std=c++11)
add_definitions(-std=c++17)
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
elseif (APPLE)
# Turn on C++11
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
endif (WIN32)

Expand Down Expand Up @@ -867,6 +872,7 @@ endif (NOT ${WITH_EIGEN} MATCHES "NONE")

if (APPLE)
include_directories("/usr/local/opt/openblas/include")
include_directories("/opt/homebrew/opt/openblas/include")
endif (APPLE)

if (USE_MKL)
Expand Down
6 changes: 3 additions & 3 deletions scripts/osx/install_deps.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
brew_packages="openblas snappy leveldb gflags glog szip lmdb hdf5 opencv protobuf boost cmake viennacl"
brew_packages="openblas snappy leveldb gflags glog szip lmdb hdf5 opencv protobuf boost viennacl"
for pkg in $brew_packages
do
echo "brew install $pkg || brew upgrade $pkg"
Expand All @@ -14,6 +14,6 @@ done
pip_packages="numpy<1.17 opencv-python<4.3"
for pkg in $pip_packages
do
echo "sudo -H python2 -m pip install $pkg"
sudo -H python2 -m pip install "$pkg"
echo "sudo -H python -m pip install $pkg"
sudo -H python -m pip install "$pkg"
done
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)
add_subdirectory(openpose)
5 changes: 5 additions & 0 deletions src/openpose/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)

include(${CMAKE_SOURCE_DIR}/cmake/Utils.cmake)
subdirlist(SUB_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
foreach (SUB_DIR ${SUB_DIRS})
Expand Down

0 comments on commit e0e5833

Please sign in to comment.