Skip to content

Commit

Permalink
Added flag maximize_positives
Browse files Browse the repository at this point in the history
  • Loading branch information
gineshidalgo99 committed Nov 15, 2018
1 parent b2725c0 commit d2dc996
Show file tree
Hide file tree
Showing 46 changed files with 206 additions and 136 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -802,10 +802,10 @@ if (WITH_CERES)
include_directories(${CERES_INCLUDE_DIRS})
endif (WITH_CERES)
if (WITH_FLIR_CAMERA)
include_directories(${SPINNAKER_INCLUDE_DIRS})
include_directories(SYSTEM ${SPINNAKER_INCLUDE_DIRS}) # To remove its warnings, equiv. to -isystem
endif (WITH_FLIR_CAMERA)
if (WITH_3D_ADAM_MODEL)
include_directories(include/adam) # TEMPORARY - TO BE REMOVED IN THE FUTURE
include_directories(include/adam) # TODO: TEMPORARY - TO BE REMOVED IN THE FUTURE
include_directories(${CERES_INCLUDE_DIRS})
include_directories(${EIGEN3_INCLUDE_DIRS})
include_directories(${IGL_INCLUDE_DIRS})
Expand Down
1 change: 1 addition & 0 deletions doc/demo_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Each flag is divided into flag name, default value, and description.
- DEFINE_int32(num_gpu_start, 0, "GPU device start number.");
- DEFINE_int32(keypoint_scale, 0, "Scaling of the (x,y) coordinates of the final pose data array, i.e., the scale of the (x,y) coordinates that will be saved with the `write_json` & `write_keypoint` flags. Select `0` to scale it to the original source resolution; `1`to scale it to the net output size (set with `net_resolution`); `2` to scale it to the final output size (set with `resolution`); `3` to scale it in the range [0,1], where (0,0) would be the top-left corner of the image, and (1,1) the bottom-right one; and 4 for range [-1,1], where (-1,-1) would be the top-left corner of the image, and (1,1) the bottom-right one. Non related with `scale_number` and `scale_gap`.");
- DEFINE_int32(number_people_max, -1, "This parameter will limit the maximum number of people detected, by keeping the people with top scores. The score is based in person area over the image, body part score, as well as joint score (between each pair of connected body parts). Useful if you know the exact number of people in the scene, so it can remove false positives (if all the people have been detected. However, it might also include false negatives by removing very small or highly occluded people. -1 will keep them all.");
- DEFINE_bool(maximize_positives, false, "It reduces the thresholds to accept a person candidate. It highly increases both false and true positives. I.e., it maximizes average recall but could harm average precision.");

4. OpenPose Body Pose
- DEFINE_bool(body_disable, false, "Disable body keypoint detection. Option only possible for faster (but less accurate) face keypoint detection.");
Expand Down
3 changes: 3 additions & 0 deletions doc/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,14 @@ OpenPose Library - Release Notes
15. Function `resizeFixedAspectRatio` can take already allocated memory (e.g., faster if target is an Array<T> object, no intermediate cv::Mat required).
16. Added compatibility for OpenCV 4.0, while preserving 2.4.X and 3.X compatibility.
17. Improved and added several functions to `utilities/keypoints.hpp` and Array to simplify keypoint post-processing.
18. Removed warnings from Spinnaker SDK at compiling time.
19. All bash scripts incorporate `#!/bin/bash` to tell the terminal that they are bash scripts.
2. Functions or parameters renamed:
1. By default, python example `tutorial_developer/python_2_pose_from_heatmaps.py` was using 2 scales starting at -1x736, changed to 1 scale at -1x368.
2. WrapperStructPose default parameters changed to match those of the OpenPose demo binary.
3. WrapperT.configure() changed from 1 function that requries all arguments to individual functions that take 1 argument each.
4. Added `Forward` to all net classes that automatically selects between CUDA, OpenCL, or CPU-only version depending on the defines.
5. Previously hardcoded `COCO_CHALLENGE` variable turned into user configurable flag `--maximize_positives`.
3. Main bugs fixed:
1. CMake-GUI was forcing to Release mode, allowed Debug modes too.
2. NMS returns in index 0 the number of found peaks. However, while the number of peaks was truncated to a maximum of 127, this index 0 was saving the real number instead of the truncated one.
Expand Down
2 changes: 1 addition & 1 deletion examples/openpose/openpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int openPoseDemo()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapper.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
Expand Down
4 changes: 4 additions & 0 deletions examples/tests/drawProtoTxt.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash



# Script for internal use. We might completely change it continuously and we will not answer questions about it.

# Required
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/handFromJsonTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int handFromJsonTest()
op::ScaleMode::InputResolution, FLAGS_num_gpu, FLAGS_num_gpu_start,
1, 0.15f, op::RenderMode::None, op::PoseModel::BODY_25,
true, 0.f, 0.f, 0, "models/", {}, op::ScaleMode::ZeroToOne, false,
0.05f, -1, enableGoogleLogging};
0.05f, -1, false, enableGoogleLogging};
wrapperStructPose.modelFolder = FLAGS_model_folder;
// Hand configuration (use op::WrapperStructHand{} to disable it)
const op::WrapperStructHand wrapperStructHand{FLAGS_hand, handNetInputSize, FLAGS_hand_scale_number,
Expand Down
4 changes: 4 additions & 0 deletions examples/tests/hand_accuracy_test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash



# Disclaimer:
# Script for internal use. We might make continuous changess on it and we will not answer questions about it.

Expand Down
4 changes: 4 additions & 0 deletions examples/tests/pose_accuracy_car_val.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash



# Script for internal use. We might completely change it continuously and we will not answer questions about it.

clear && clear
Expand Down
4 changes: 4 additions & 0 deletions examples/tests/pose_accuracy_coco_test_dev.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash



# Script for internal use. We might completely change it continuously and we will not answer questions about it.

clear && clear
Expand Down
9 changes: 6 additions & 3 deletions examples/tests/pose_accuracy_coco_val.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash



# Script for internal use. We might completely change it continuously and we will not answer questions about it.

clear && clear
Expand All @@ -21,6 +25,7 @@ OP_BIN=./build/examples/openpose/openpose.bin

# 1 scale
$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --display 0 --render_pose 0
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_max.json --display 0 --render_pose 0 --maximize_positives --model_pose BODY_25E

# 1 scale - Debugging
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --display 0 --write_images ~/Desktop/CppValidation/
Expand All @@ -30,6 +35,4 @@ $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --displ

# # 4 scales
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736"

# # Debugging - Rendered frames saved
# $OP_BIN --image_dir $IMAGE_FOLDER --write_images ${JSON_FOLDER}frameOutput --display 0
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4_max.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" --maximize_positives
4 changes: 4 additions & 0 deletions examples/tests/pose_accuracy_coco_val_2014.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash



# Script for internal use. We might completely change it continuously and we will not answer questions about it.

clear && clear
Expand Down
4 changes: 4 additions & 0 deletions examples/tests/pose_accuracy_coco_val_foot.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash



# Script for internal use. We might completely change it continuously and we will not answer questions about it.

clear && clear
Expand Down
4 changes: 4 additions & 0 deletions examples/tests/pose_accuracy_coco_val_server.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash



# Script for internal use. We might completely change it continuously and we will not answer questions about it.

clear && clear
Expand Down
4 changes: 4 additions & 0 deletions examples/tests/pose_accuracy_coco_val_server_2014.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash



# Script for internal use. We might completely change it continuously and we will not answer questions about it.

clear && clear
Expand Down
4 changes: 4 additions & 0 deletions examples/tests/pose_time_Caffe_layers.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash



# Script for internal use. We might completely change it continuously and we will not answer questions about it.

# # Go back to main folder
Expand Down
4 changes: 4 additions & 0 deletions examples/tests/pose_time_visual_GUI.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash



# Script for internal use. We might completely change it continuously and we will not answer questions about it.

# # Go back to main folder
Expand Down
4 changes: 4 additions & 0 deletions examples/tests/speed_test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash



# Script for internal use. We might completely change it continuously and we will not answer questions about it.

# USAGE EXAMPLE
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_add_module/1_custom_post_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int tutorialAddModule1()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int tutorialApiCpp3()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapper.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ int tutorialApiCpp4()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ int tutorialApiCpp5()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ int tutorialApiCpp6()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_api_cpp/7_synchronous_custom_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ int tutorialApiCpp7()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_api_cpp/8_synchronous_custom_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ int tutorialApiCpp8()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorial_api_cpp/9_synchronous_custom_all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ int tutorialApiCpp9()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
Expand Down
2 changes: 2 additions & 0 deletions include/openpose/flags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ DEFINE_int32(number_people_max, -1, "This parameter will lim
" number of people in the scene, so it can remove false positives (if all the people have"
" been detected. However, it might also include false negatives by removing very small or"
" highly occluded people. -1 will keep them all.");
DEFINE_bool(maximize_positives, false, "It reduces the thresholds to accept a person candidate. It highly increases both false and"
" true positives. I.e., it maximizes average recall but could harm average precision.");
// OpenPose Body Pose
DEFINE_bool(body_disable, false, "Disable body keypoint detection. Option only possible for faster (but less accurate) face"
" keypoint detection.");
Expand Down
7 changes: 4 additions & 3 deletions include/openpose/net/bodyPartConnectorBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ namespace op
void connectBodyPartsCpu(
Array<T>& poseKeypoints, Array<T>& poseScores, const T* const heatMapPtr, const T* const peaksPtr,
const PoseModel poseModel, const Point<int>& heatMapSize, const int maxPeaks, const T interMinAboveThreshold,
const T interThreshold, const int minSubsetCnt, const T minSubsetScore, const T scaleFactor = 1.f);
const T interThreshold, const int minSubsetCnt, const T minSubsetScore, const T scaleFactor = 1.f,
const bool maximizePositives = false);

// Windows: Cuda functions do not include OP_API
template <typename T>
void connectBodyPartsGpu(
Array<T>& poseKeypoints, Array<T>& poseScores, const T* const heatMapGpuPtr, const T* const peaksPtr,
const PoseModel poseModel, const Point<int>& heatMapSize, const int maxPeaks, const T interMinAboveThreshold,
const T interThreshold, const int minSubsetCnt, const T minSubsetScore, const T scaleFactor = 1.f,
Array<T> pairScoresCpu = Array<T>{}, T* pairScoresGpuPtr = nullptr,
const bool maximizePositives = false, Array<T> pairScoresCpu = Array<T>{}, T* pairScoresGpuPtr = nullptr,
const unsigned int* const bodyPartPairsGpuPtr = nullptr, const unsigned int* const mapIdxGpuPtr = nullptr,
const T* const peaksGpuPtr = nullptr);

Expand All @@ -34,7 +35,7 @@ namespace op
void removePeopleBelowThresholds(std::vector<int>& validSubsetIndexes, int& numberPeople,
const std::vector<std::pair<std::vector<int>, T>>& subsets,
const unsigned int numberBodyParts, const int minSubsetCnt,
const T minSubsetScore, const int maxPeaks);
const T minSubsetScore, const int maxPeaks, const bool maximizePositives);

template <typename T>
void peopleVectorToPeopleArray(Array<T>& poseKeypoints, Array<T>& poseScores, const T scaleFactor,
Expand Down
3 changes: 3 additions & 0 deletions include/openpose/net/bodyPartConnectorCaffe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace op

void setPoseModel(const PoseModel poseModel);

void setMaximizePositives(const bool maximizePositives);

void setInterMinAboveThreshold(const T interMinAboveThreshold);

void setInterThreshold(const T interThreshold);
Expand Down Expand Up @@ -50,6 +52,7 @@ namespace op

private:
PoseModel mPoseModel;
bool mMaximizePositives;
T mInterMinAboveThreshold;
T mInterThreshold;
int mMinSubsetCnt;
Expand Down
1 change: 1 addition & 0 deletions include/openpose/pose/poseExtractorCaffe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace op
const std::vector<HeatMapType>& heatMapTypes = {},
const ScaleMode heatMapScale = ScaleMode::ZeroToOne,
const bool addPartCandidates = false,
const bool maximizePositives = false,
const bool enableGoogleLogging = true);

virtual ~PoseExtractorCaffe();
Expand Down
3 changes: 2 additions & 1 deletion include/openpose/pose/poseExtractorNet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ namespace op
PoseExtractorNet(const PoseModel poseModel,
const std::vector<HeatMapType>& heatMapTypes = {},
const ScaleMode heatMapScale = ScaleMode::ZeroToOne,
const bool addPartCandidates = false);
const bool addPartCandidates = false,
const bool maximizePositives = false);

virtual ~PoseExtractorNet();

Expand Down
Loading

0 comments on commit d2dc996

Please sign in to comment.