Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

CMakeLists.txt 7.9 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
  1. project(openpose)
  2. cmake_minimum_required(VERSION 2.8.7 FATAL_ERROR) # min. cmake version recommmended by Caffe
  3. ### FIND THE OS
  4. if (WIN32) # OS is Windows
  5. message(FATAL_ERROR "Windows OS is not currently supported.")
  6. elseif (APPLE) # OS is Apple
  7. message(FATAL_ERROR "Apple OS is not currently supported.")
  8. elseif (UNIX AND NOT APPLE) # OS is a Linux distribution (it assumes Ubuntu)
  9. set(EXECUTE_COMMAND lsb_release -rs)
  10. execute_process(COMMAND ${EXECUTE_COMMAND} OUTPUT_VARIABLE UBUNTU_VERSION)
  11. string(SUBSTRING ${UBUNTU_VERSION} 0 2 UBUNTU_MAJOR_VERSION)
  12. if (${UBUNTU_MAJOR_VERSION} MATCHES "16") # if 16
  13. set(IS_UBUNTU_16 TRUE)
  14. set(IS_UBUNTU_14_OR_LESS FALSE)
  15. else (${UBUNTU_MAJOR_VERSION MATCHES "16") # if 14 or less
  16. set(IS_UBUNTU_16 FALSE)
  17. set(IS_UBUNTU_14_OR_LESS TRUE)
  18. endif (${UBUNTU_MAJOR_VERSION} MATCHES "16")
  19. endif ()
  20. ### FLAGS
  21. # Build as shared library
  22. set(BUILD_SHARED_LIBS ON)
  23. # Turn on C++11
  24. add_definitions(-std=c++11)
  25. # OpenPose flags
  26. add_definitions(-DUSE_CAFFE)
  27. # C++ additional flags
  28. set(OP_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -Wpedantic -Wall -Wextra -Wfatal-errors")
  29. ### PROJECT OPTIONS
  30. # Select the DL Framework
  31. set(DL_FRAMEWORK CAFFE CACHE STRING "Select Deep Learning Framework.")
  32. set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE)
  33. # set_property(CACHE DL_FRAMEWORK PROPERTY STRINGS CAFFE CAFFE2 TENSORFLOW)
  34. # Suboptions for Caffe DL Framework
  35. include(CMakeDependentOption)
  36. if (${DL_FRAMEWORK} MATCHES "CAFFE")
  37. CMAKE_DEPENDENT_OPTION(BUILD_CAFFE "Build Caffe as part of OpenPose." ON
  38. "DL_FRAMEWORK" ON)
  39. endif (${DL_FRAMEWORK} MATCHES "CAFFE")
  40. # Set the acceleration library
  41. set(GPU_MODE CUDA CACHE STRING "Select the acceleration GPU library or CPU otherwise.")
  42. set_property(CACHE GPU_MODE PROPERTY STRINGS CUDA)
  43. # set_property(CACHE GPU_MODE PROPERTY STRINGS CUDA OPENCL CPU_ONLY)
  44. # Suboptions for GPU architectures
  45. if (${GPU_MODE} MATCHES "CUDA")
  46. set(CUDA_ARCH Auto CACHE STRING "Select target NVIDIA GPU achitecture.")
  47. set_property(CACHE CUDA_ARCH PROPERTY STRINGS Auto All Manual)
  48. endif (${GPU_MODE} MATCHES "CUDA")
  49. # Suboptions for acceleration library
  50. if (${GPU_MODE} MATCHES "CUDA")
  51. option(USE_CUDNN "Build OpenPose with cuDNN library support." ON)
  52. endif (${GPU_MODE} MATCHES "CUDA")
  53. # Download the models
  54. option(DOWNLOAD_COCO_MODEL "Download COCO model." ON)
  55. option(DOWNLOAD_MPI_MODEL "Download MPI model." OFF)
  56. option(DOWNLOAD_HAND_MODEL "Download hand model." ON)
  57. option(DOWNLOAD_FACE_MODEL "Download face model." ON)
  58. # More options
  59. option(BUILD_EXAMPLES "Build OpenPose examples." ON)
  60. option(BUILD_DOCS "Build OpenPose documentation." OFF)
  61. ### FIND REQUIRED PACKAGES
  62. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
  63. include(cmake/Cuda.cmake)
  64. # find_package(CUDA)
  65. find_package(Boost COMPONENTS system filesystem)
  66. find_package(CuDNN)
  67. find_package(GFlags)
  68. find_package(Glog)
  69. find_package(OpenCV)
  70. if (NOT Boost_FOUND)
  71. message(FATAL_ERROR "Boost not found. Install Boost from the command line using the command(s) --\
  72. sudo apt-get install libboost-all-dev")
  73. endif (NOT Boost_FOUND)
  74. if (NOT CUDA_FOUND)
  75. message(STATUS "CUDA not found.")
  76. execute_process(COMMAND cat install_cuda.sh WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/ubuntu)
  77. message(FATAL_ERROR "Install CUDA using the above commands.")
  78. endif (NOT CUDA_FOUND)
  79. if (USE_CUDNN AND NOT CUDNN_FOUND)
  80. message(STATUS "cuDNN not found.")
  81. execute_process(COMMAND cat install_cudnn.sh WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/ubuntu)
  82. message(FATAL_ERROR "Install cuDNN using the above commands. or turn off cuDNN by setting USE_CUDNN to OFF.")
  83. endif (USE_CUDNN AND NOT CUDNN_FOUND)
  84. if (NOT GLOG_FOUND)
  85. message(FATAL_ERROR "Glog not found. Install Glog from the command line using the command(s) -\
  86. sudo apt-get install libgoogle-glog-dev")
  87. endif (NOT GLOG_FOUND)
  88. if (NOT GFLAGS_FOUND)
  89. message(FATAL_ERROR "GFlags not found. Install GFlags from the command line using the command(s) --\
  90. sudo apt-get install libgflags-dev")
  91. endif (NOT GFLAGS_FOUND)
  92. if (NOT OpenCV_FOUND)
  93. message(FATAL_ERROR "OpenCV not found. Install OpenCV from the command line using the command(s) --\
  94. sudo apt-get install libopencv-dev")
  95. endif (NOT OpenCV_FOUND)
  96. # Set CUDA Flags
  97. set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11")
  98. ### CAFFE
  99. if (${DL_FRAMEWORK} MATCHES "CAFFE")
  100. # Check if the user specified caffe paths
  101. if (Caffe_INCLUDE_DIRS AND Caffe_LIBS AND NOT BUILD_CAFFE)
  102. message(STATUS "\${Caffe_INCLUDE_DIRS} set by the user to " ${Caffe_INCLUDE_DIRS})
  103. message(STATUS "\${Caffe_LIBS} set by the user to " ${Caffe_LIBS})
  104. set(Caffe_FOUND 1)
  105. endif (Caffe_INCLUDE_DIRS AND Caffe_LIBS AND NOT BUILD_CAFFE)
  106. # Check if caffe is installed in known paths
  107. if (NOT Caffe_FOUND AND NOT BUILD_CAFFE)
  108. message(STATUS "Looking for caffe around in expected paths.")
  109. find_package(Caffe)
  110. endif (NOT Caffe_FOUND AND NOT BUILD_CAFFE)
  111. # Else build from scratch
  112. if (BUILD_CAFFE)
  113. message(STATUS "Caffe will be build from source now.")
  114. # Build Caffe
  115. include(ExternalProject)
  116. set(BUILD_CAFFE ON)
  117. set(CAFFE_PREFIX caffe)
  118. set(CAFFE_URL ${CMAKE_SOURCE_DIR}/3rdparty/caffe)
  119. ExternalProject_Add(${CAFFE_PREFIX}
  120. SOURCE_DIR ${CAFFE_URL}
  121. PREFIX ${CAFFE_PREFIX}
  122. CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
  123. -DUSE_CUDNN=${USE_CUDNN}
  124. -DOpenCV_DIR=${OpenCV_DIR})
  125. ExternalProject_Get_Property(caffe install_dir)
  126. set(Caffe_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/build/caffe/include)
  127. # TODO -- Find a better soln.
  128. set(Caffe_LIBS ${CMAKE_SOURCE_DIR}/build/caffe/lib/libcaffe.so)
  129. endif (BUILD_CAFFE)
  130. if (NOT Caffe_FOUND AND NOT BUILD_CAFFE)
  131. message(FATAL_ERROR "Caffe not found. Either turn on the BUILD_CAFFE option or specify the path of Caffe includes
  132. and libs using -DCaffe_INCLUDE_DIRS and -DCaffe_LIBS")
  133. endif (NOT Caffe_FOUND AND NOT BUILD_CAFFE)
  134. endif (${DL_FRAMEWORK} MATCHES "CAFFE")
  135. ### PROJECT INCLUDES
  136. # Specify the include directories
  137. include_directories(
  138. ${CMAKE_SOURCE_DIR}/include
  139. ${CUDA_INCLUDE_DIRS}
  140. ${GFLAGS_INCLUDE_DIR}
  141. ${GLOG_INCLUDE_DIR}
  142. ${Caffe_INCLUDE_DIRS}
  143. ${OpenCV_INCLUDE_DIRS})
  144. ### ADD SUBDIRECTORIES
  145. add_subdirectory(src)
  146. if (BUILD_EXAMPLES)
  147. add_subdirectory(examples)
  148. endif (BUILD_EXAMPLES)
  149. ### GENERATE DOCUMENTATION
  150. if (BUILD_DOCS)
  151. find_package(Doxygen)
  152. if (DOXYGEN_FOUND)
  153. # Set input and output files
  154. set(DOXYGEN_FILE ${CMAKE_SOURCE_DIR}/doc/doc_autogeneration.doxygen)
  155. # Custom target to build the documentation
  156. add_custom_target(doc_doxygen ALL
  157. COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_FILE}
  158. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/doc
  159. COMMENT "Generating API documentation with Doxygen"
  160. VERBATIM )
  161. else (DOXYGEN_FOUND)
  162. message("Doxygen need to be installed to generate the doxygen documentation")
  163. endif (DOXYGEN_FOUND)
  164. endif (BUILD_DOCS)
  165. ### DOWNLOAD MODELS
  166. # Download the models if flag is set
  167. # TODO -- remove hardcoded ubuntu paths
  168. include(cmake/Utils.cmake)
  169. message(STATUS "Download the models.")
  170. # URL to the models
  171. set(OPENPOSE_URL "http://posefs1.perception.cs.cmu.edu/OpenPose/models/")
  172. # Body (COCO)
  173. if (DOWNLOAD_COCO_MODEL)
  174. download_model("body (COCO)" ${DOWNLOAD_COCO_MODEL} pose/coco/pose_iter_440000.caffemodel
  175. 5156d31f670511fce9b4e28b403f2939)
  176. endif (DOWNLOAD_COCO_MODEL)
  177. # Body (MPI)
  178. if (DOWNLOAD_MPI_MODEL)
  179. download_model("body (MPI)" ${DOWNLOAD_MPI_MODEL} pose/mpi/pose_iter_160000.caffemodel
  180. 2ca0990c7562bd7ae03f3f54afa96e00)
  181. endif (DOWNLOAD_MPI_MODEL)
  182. # Face
  183. if (DOWNLOAD_FACE_MODEL)
  184. download_model("face" ${DOWNLOAD_FACE_MODEL} face/pose_iter_116000.caffemodel
  185. e747180d728fa4e4418c465828384333)
  186. endif (DOWNLOAD_FACE_MODEL)
  187. # Hand
  188. if (DOWNLOAD_HAND_MODEL)
  189. download_model("hand" ${DOWNLOAD_HAND_MODEL} hand/pose_iter_102000.caffemodel
  190. a82cfc3fea7c62f159e11bd3674c1531)
  191. endif (DOWNLOAD_HAND_MODEL)
  192. message(STATUS "Models Downloaded.")
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...