提交 c42443f6 编写于 作者: G gineshidalgo99

Profiler working again

上级 24d29e59
......@@ -7,7 +7,7 @@
namespace op
{
// #define when needed in CUDA code
// All #define are for CUDA code
// Constant Global Parameters
const unsigned int POSE_MAX_PEOPLE = 96u;
......@@ -206,31 +206,35 @@ namespace op
{22, "LEar"},
{23, "Background"}
};
const unsigned int POSE_BODY_23_NUMBER_PARTS = 22u; // Equivalent to size of std::map POSE_BODY_23_BODY_PARTS - 1 (removing background)
const unsigned int POSE_BODY_23_NUMBER_PARTS = 23u; // Equivalent to size of std::map POSE_BODY_23_BODY_PARTS - 1 (removing background)
const std::vector<unsigned int> POSE_BODY_23_MAP_IDX {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};
#define POSE_BODY_23_PAIRS_RENDER_GPU { 0,1, 0,4, 1,2, 2,3, 4,5, 5,6, 0,7, 7,8, 7,13, 8,9, 9,10,10,11,10,12,13,14,14,15,15,16,15,17, 0,18,18,19,18,21,19,20,21,22}
#define POSE_BODY_23_PAIRS_RENDER_GPU { 0,1, 0,4, 1,2, 2,3, 4,5, 5,6, 0,7, 7,8, 7,13, 8,9, 9,10,10,11,11,12,13,14,14,15,15,16,16,17, 0,18,18,19,18,21,19,20,21,22}
const std::vector<unsigned int> POSE_BODY_23_PAIRS_RENDER {POSE_BODY_23_PAIRS_RENDER_GPU};
const std::vector<unsigned int> POSE_BODY_23_PAIRS { 0,1, 0,4, 1,2, 2,3, 4,5, 5,6, 0,7, 7,8, 7,13, 8,9, 9,10,10,11,10,12,13,14,14,15,15,16,15,17, 0,18,18,19,18,21,19,20,21,22, 1,20, 4,22};
#define POSE_BODY_23_COLORS_RENDER_GPU \
255.f, 0.f, 85.f, \
255.f, 0.f, 0.f, \
255.f, 85.f, 0.f, \
255.f, 170.f, 0.f, \
255.f, 55.f, 0.f, \
255.f, 110.f, 0.f, \
255.f, 165.f, 0.f, \
255.f, 215.f, 0.f, \
255.f, 235.f, 0.f, \
255.f, 255.f, 0.f, \
170.f, 255.f, 0.f, \
255.f, 0.f, 0.f, \
175.f, 255.f, 0.f, \
85.f, 255.f, 0.f, \
0.f, 255.f, 0.f, \
255.f, 0.f, 0.f, \
0.f, 255.f, 85.f, \
0.f, 255.f, 170.f, \
0.f, 255.f, 255.f, \
0.f, 170.f, 255.f, \
25.f, 25.f, 128.f, \
0.f, 85.f, 255.f, \
0.f, 0.f, 255.f, \
255.f, 0.f, 170.f, \
170.f, 0.f, 255.f, \
0.f, 170.f, 255.f, \
0.f, 212.5f, 255.f, \
0.f, 255.f, 255.f, \
255.f, 0.f, 0.f, \
255.f, 0.f, 255.f, \
85.f, 0.f, 255.f
238.f, 130.f, 238.f, \
138.f, 43.f, 226.f, \
75.f, 0.f, 130.f
const std::vector<float> POSE_BODY_23_COLORS_RENDER{POSE_BODY_23_COLORS_RENDER_GPU};
// Constant Array Parameters
......@@ -269,7 +273,7 @@ namespace op
"pose/mpi/pose_iter_160000.caffemodel",
"pose/body_18/pose_iter_XXXXXX.caffemodel",
"pose/body_19/pose_iter_XXXXXX.caffemodel",
"pose/body_23/pose_iter_42000.caffemodel"
"pose/body_23/pose_iter_XXXXXX.caffemodel"
};
// POSE_BODY_PART_MAPPING crashes on Windows at dynamic initialization, to avoid this crash:
// POSE_BODY_PART_MAPPING has been moved to poseParameters.cpp and getPoseBodyPartMapping() wraps it
......
......@@ -11,7 +11,7 @@
namespace op
{
std::mutex sMutex;
std::mutex sMutexNetCaffe;
std::atomic<bool> sGoogleLoggingInitialized{false};
struct NetCaffe::ImplNetCaffe
......@@ -51,7 +51,7 @@ namespace op
// Double if condition in order to speed up the program if it is called several times
if (enableGoogleLogging && !sGoogleLoggingInitialized)
{
std::lock_guard<std::mutex> lock{sMutex};
std::lock_guard<std::mutex> lock{sMutexNetCaffe};
if (enableGoogleLogging && !sGoogleLoggingInitialized)
{
google::InitGoogleLogging("OpenPose");
......
......@@ -64,11 +64,14 @@ namespace op
mJsonOfstream.arrayOpen();
std::vector<int> indexesInCocoOrder;
if (numberBodyParts == 18)
indexesInCocoOrder = std::vector<int>{0, 15, 14, 17, 16, 5, 2, 6, 3, 7, 4, 11, 8, 12, 9, 13, 10};
indexesInCocoOrder = std::vector<int>{0, 15,14,17,16, 5,2,6,3,7, 4,11,8,12, 9, 13,10};
else if (numberBodyParts == 19)
indexesInCocoOrder = std::vector<int>{0, 16, 15, 18, 17, 5, 2, 6, 3, 7, 4, 12, 9, 13, 10, 14, 11};
indexesInCocoOrder = std::vector<int>{0, 16,15,18,17, 5,2,6,3,7, 4,12,9,13,10, 14,11};
else if (numberBodyParts == 23)
indexesInCocoOrder = std::vector<int>{18,21,19,22,20, 4,1,5,2,6, 3,13,8,14, 9, 15,10};
else
error("Unvalid number of body parts (" + std::to_string(numberBodyParts) + ").", __LINE__, __FUNCTION__, __FILE__);
error("Unvalid number of body parts (" + std::to_string(numberBodyParts) + ").",
__LINE__, __FUNCTION__, __FILE__);
for (auto bodyPart = 0u ; bodyPart < indexesInCocoOrder.size() ; bodyPart++)
{
const auto finalIndex = 3*(person*numberBodyParts + indexesInCocoOrder.at(bodyPart));
......
......@@ -17,7 +17,7 @@ namespace op
std::map<std::string, std::tuple<double, unsigned long long, std::chrono::high_resolution_clock::time_point>> sProfilerTuple{
std::map<std::string, std::tuple<double, unsigned long long, std::chrono::high_resolution_clock::time_point>>()
};
std::mutex sMutex{};
std::mutex sMutexProfiler{};
std::string getKey(const int line, const std::string& function, const std::string& file)
{
......@@ -37,7 +37,7 @@ namespace op
{
#ifdef PROFILER_ENABLED
const auto key = getKey(line, function, file);
std::unique_lock<std::mutex> lock{sMutex};
std::unique_lock<std::mutex> lock{sMutexProfiler};
if (sProfilerTuple.count(key) > 0)
std::get<2>(sProfilerTuple[key]) = std::chrono::high_resolution_clock::now();
else
......@@ -55,7 +55,7 @@ namespace op
void Profiler::timerEnd(const std::string& key)
{
#ifdef PROFILER_ENABLED
const std::lock_guard<std::mutex> lock{sMutex};
const std::lock_guard<std::mutex> lock{sMutexProfiler};
if (sProfilerTuple.count(key) > 0)
{
auto tuple = sProfilerTuple[key];
......@@ -77,7 +77,7 @@ namespace op
void Profiler::printAveragedTimeMsOnIterationX(const std::string& key, const int line, const std::string& function, const std::string& file, const unsigned long long x)
{
#ifdef PROFILER_ENABLED
std::unique_lock<std::mutex> lock{sMutex};
std::unique_lock<std::mutex> lock{sMutexProfiler};
if (sProfilerTuple.count(key) > 0)
{
const auto tuple = sProfilerTuple[key];
......@@ -101,7 +101,7 @@ namespace op
void Profiler::printAveragedTimeMsEveryXIterations(const std::string& key, const int line, const std::string& function, const std::string& file, const unsigned long long x)
{
#ifdef PROFILER_ENABLED
std::unique_lock<std::mutex> lock{sMutex};
std::unique_lock<std::mutex> lock{sMutexProfiler};
if (sProfilerTuple.count(key) > 0)
{
const auto tuple = sProfilerTuple[key];
......@@ -111,7 +111,7 @@ namespace op
printAveragedTimeMsCommon(std::get<0>(tuple), std::get<1>(tuple), line, function, file);
// Reset
const std::lock_guard<std::mutex> lock{sMutex};
const std::lock_guard<std::mutex> lock{sMutexProfiler};
auto& tuple = sProfilerTuple[key];
std::get<0>(tuple) = 0.;
std::get<1>(tuple) = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册