Skip to content

Commit 9ce2169

Browse files
Removed unused parameter spPoseBlob
1 parent b878cbf commit 9ce2169

File tree

4 files changed

+54
-51
lines changed

4 files changed

+54
-51
lines changed
Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,81 @@
1-
# Usage example:
2-
# clear && clear && make all -j`nproc` && bash ./examples/tests/hand_accuracy_test.sh
3-
41
# Disclaimer:
52
# Script for internal use. We might make continuous changess on it and we will not answer questions about it.
63

4+
# Full usage description:
5+
# Step 1 - Getting JSON output
6+
# Running it:
7+
# Run it from OpenPose main folder with the following command:
8+
# clear && clear && make all -j`nproc` && bash ./examples/tests/hand_accuracy_test.sh
9+
10+
# Image paths:
11+
# Read that script for details about all the paths and change them for your own paths.
12+
13+
# Careful:
14+
# If you are using the NAS, please do not override my files, i.e. please change the output paths (corresponding to the ones indicated by `--write_keypoint_json`, which is ).
15+
16+
# In order to generate the JSON output:
17+
# Uncomment the commented lines starting by `--write_keypoint_json` and `--no_display`
18+
19+
# Step 2 - Running JSON output to get accuracy
20+
# Once you have the JSON files, run them with the script Tomas prepared for it, which in my case I use:
21+
# From Matlab, `cd /media/posefs3b/Users/gines/openpose_train/dataset/hand_testing`
22+
# Run `b_keypointJsonToMatAndImage` to generate your new file (you can run the current code to try it, I commented everything but test 1)
23+
# Run `c_plot_save_results` to plot and save the results. Just modify `models` and `texts` with your new model path and desired name.
24+
725
# Clear terminal screen
826
clear && clear
927

1028

1129

30+
# Fix paths
1231
HAND_TESTING_FOLDER="/media/posefs3b/Users/gines/openpose_train/dataset/hand_testing/"
1332
IMAGES_FOLDER=${HAND_TESTING_FOLDER}"0_images/"
1433
IMAGES_BB_FOLDER=${HAND_TESTING_FOLDER}"3_images_bounding_box"
1534
HAND_GROUND_TRUTH_FOLDER=${HAND_TESTING_FOLDER}"4_hand_detections"
1635
KEYPOINT_JSON_FOLDER=${HAND_TESTING_FOLDER}"5_keypointJson/"
1736

37+
# Variable paths
1838
SCALES=6
19-
SUFFIX="_test${SCALES}"
39+
SUFFIX="_${SCALES}"
40+
HAND_RESULTS_FOLDER_BASE=${KEYPOINT_JSON_FOLDER}"hand_keypoints_estimated"
41+
HAND_RESULTS_FOLDER_NO_BB=${HAND_RESULTS_FOLDER_BASE}"_old"${SUFFIX}
42+
HAND_RESULTS_FOLDER_BB=${HAND_RESULTS_FOLDER_BASE}"_BBox"${SUFFIX}
43+
HAND_RESULTS_FOLDER_BODY_59=${HAND_RESULTS_FOLDER_BASE}"_BODY_59"
2044

2145

2246

2347
# Given bounding box
24-
HAND_RESULTS_FOLDER_BB=${KEYPOINT_JSON_FOLDER}"hand_keypoints_estimated"${SUFFIX}"_bounding_box"
2548
echo "Output on ${HAND_RESULTS_FOLDER_BB}"
2649
rm -rf $HAND_RESULTS_FOLDER_BB
2750
# 1 scale
2851
./build/examples/tests/handFromJsonTest.bin \
2952
--hand_scale_number ${SCALES} --hand_scale_range 0.4 \
3053
--image_dir ${IMAGES_BB_FOLDER} \
31-
--hand_ground_truth ${HAND_GROUND_TRUTH_FOLDER}
32-
# --write_keypoint_json $HAND_RESULTS_FOLDER_BB \
33-
# --no_display
54+
--hand_ground_truth ${HAND_GROUND_TRUTH_FOLDER} \
55+
--write_keypoint_json $HAND_RESULTS_FOLDER_BB \
56+
--no_display
3457

3558

3659

3760
# No bounding box
38-
HAND_RESULTS_FOLDER_NO_BB=${KEYPOINT_JSON_FOLDER}"hand_keypoints_estimated"${SUFFIX}
3961
echo "Output on ${HAND_RESULTS_FOLDER_NO_BB}"
4062
rm -rf $HAND_RESULTS_FOLDER_NO_BB
4163
# 1 scale
4264
./build/examples/openpose/openpose.bin \
43-
--hand --hand_scale_number ${SCALES} --hand_scale_range 0.4 \
44-
--image_dir ${IMAGES_FOLDER} #\
45-
# --write_keypoint_json $HAND_RESULTS_FOLDER_NO_BB \
46-
# --no_display
65+
--hand \
66+
--hand_scale_number ${SCALES} --hand_scale_range 0.4 \
67+
--image_dir ${IMAGES_FOLDER} \
68+
--write_keypoint_json $HAND_RESULTS_FOLDER_NO_BB \
69+
--no_display
70+
71+
72+
73+
# No bounding box BODY_59
74+
echo "Output on ${HAND_RESULTS_FOLDER_BODY_59}"
75+
rm -rf $HAND_RESULTS_FOLDER_BODY_59
76+
# 1 scale
77+
./build/examples/openpose/openpose.bin \
78+
--model_pose BODY_59 \
79+
--image_dir ${IMAGES_FOLDER} \
80+
--write_keypoint_json $HAND_RESULTS_FOLDER_BODY_59 \
81+
--no_display

include/openpose/pose/bodyPartConnectorCaffe.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ namespace op
2222
public:
2323
explicit BodyPartConnectorCaffe();
2424

25-
virtual void LayerSetUp(const std::vector<caffe::Blob<T>*>& bottom, const std::vector<caffe::Blob<T>*>& top);
26-
27-
virtual void Reshape(const std::vector<caffe::Blob<T>*>& bottom, const std::vector<caffe::Blob<T>*>& top);
25+
virtual void Reshape(const std::vector<caffe::Blob<T>*>& bottom);
2826

2927
virtual inline const char* type() const { return "BodyPartConnector"; }
3028

src/openpose/pose/bodyPartConnectorCaffe.cpp

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,53 +23,26 @@ namespace op
2323
}
2424

2525
template <typename T>
26-
void BodyPartConnectorCaffe<T>::LayerSetUp(const std::vector<caffe::Blob<T>*>& bottom,
27-
const std::vector<caffe::Blob<T>*>& top)
28-
{
29-
try
30-
{
31-
#ifdef USE_CAFFE
32-
if (top.size() != 1)
33-
error("top.size() != 1", __LINE__, __FUNCTION__, __FILE__);
34-
if (bottom.size() != 2)
35-
error("bottom.size() != 2", __LINE__, __FUNCTION__, __FILE__);
36-
#else
37-
UNUSED(bottom);
38-
UNUSED(top);
39-
#endif
40-
}
41-
catch (const std::exception& e)
42-
{
43-
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
44-
}
45-
}
46-
47-
template <typename T>
48-
void BodyPartConnectorCaffe<T>::Reshape(const std::vector<caffe::Blob<T>*>& bottom,
49-
const std::vector<caffe::Blob<T>*>& top)
26+
void BodyPartConnectorCaffe<T>::Reshape(const std::vector<caffe::Blob<T>*>& bottom)
5027
{
5128
try
5229
{
5330
#ifdef USE_CAFFE
5431
auto heatMapsBlob = bottom.at(0);
5532
auto peaksBlob = bottom.at(1);
56-
auto topBlob = top.at(0);
5733

5834
// Top shape
5935
const auto maxPeaks = peaksBlob->shape(2) - 1;
6036
const auto numberBodyParts = peaksBlob->shape(1);
61-
topBlob->Reshape({1, maxPeaks, numberBodyParts, 3});
6237

6338
// Array sizes
64-
mTopSize = std::array<int, 4>{topBlob->shape(0), topBlob->shape(1), topBlob->shape(2),
65-
topBlob->shape(3)};
39+
mTopSize = std::array<int, 4>{1, maxPeaks, numberBodyParts, 3};
6640
mHeatMapsSize = std::array<int, 4>{heatMapsBlob->shape(0), heatMapsBlob->shape(1),
6741
heatMapsBlob->shape(2), heatMapsBlob->shape(3)};
6842
mPeaksSize = std::array<int, 4>{peaksBlob->shape(0), peaksBlob->shape(1), peaksBlob->shape(2),
6943
peaksBlob->shape(3)};
7044
#else
7145
UNUSED(bottom);
72-
UNUSED(top);
7346
#endif
7447
}
7548
catch (const std::exception& e)

src/openpose/pose/poseExtractorCaffe.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ namespace op
3434
std::vector<boost::shared_ptr<caffe::Blob<float>>> spCaffeNetOutputBlobs;
3535
std::shared_ptr<caffe::Blob<float>> spHeatMapsBlob;
3636
std::shared_ptr<caffe::Blob<float>> spPeaksBlob;
37-
std::shared_ptr<caffe::Blob<float>> spPoseBlob;
3837

3938
ImplPoseExtractorCaffe(const PoseModel poseModel, const int gpuId,
4039
const std::string& modelFolder, const bool enableGoogleLogging) :
@@ -75,7 +74,6 @@ namespace op
7574
std::vector<boost::shared_ptr<caffe::Blob<float>>>& caffeNetOutputBlob,
7675
std::shared_ptr<caffe::Blob<float>>& heatMapsBlob,
7776
std::shared_ptr<caffe::Blob<float>>& peaksBlob,
78-
std::shared_ptr<caffe::Blob<float>>& poseBlob,
7977
const float scaleInputToNetInput,
8078
const PoseModel poseModel)
8179
{
@@ -88,7 +86,7 @@ namespace op
8886
// Pose extractor blob and layer
8987
nmsCaffe->Reshape({heatMapsBlob.get()}, {peaksBlob.get()}, getPoseMaxPeaks(poseModel));
9088
// Pose extractor blob and layer
91-
bodyPartConnectorCaffe->Reshape({heatMapsBlob.get(), peaksBlob.get()}, {poseBlob.get()});
89+
bodyPartConnectorCaffe->Reshape({heatMapsBlob.get(), peaksBlob.get()});
9290
// Cuda check
9391
#ifdef USE_CUDA
9492
cudaCheck(__LINE__, __FUNCTION__, __FILE__);
@@ -180,7 +178,6 @@ namespace op
180178
// Initialize blobs
181179
upImpl->spHeatMapsBlob = {std::make_shared<caffe::Blob<float>>(1,1,1,1)};
182180
upImpl->spPeaksBlob = {std::make_shared<caffe::Blob<float>>(1,1,1,1)};
183-
upImpl->spPoseBlob = {std::make_shared<caffe::Blob<float>>(1,1,1,1)};
184181
#ifdef USE_CUDA
185182
cudaCheck(__LINE__, __FUNCTION__, __FILE__);
186183
#endif
@@ -236,7 +233,7 @@ namespace op
236233
// upImpl->mScaleInputToNetInputs = scaleInputToNetInputs;
237234
reshapePoseExtractorCaffe(upImpl->spResizeAndMergeCaffe, upImpl->spNmsCaffe,
238235
upImpl->spBodyPartConnectorCaffe, upImpl->spCaffeNetOutputBlobs,
239-
upImpl->spHeatMapsBlob, upImpl->spPeaksBlob, upImpl->spPoseBlob,
236+
upImpl->spHeatMapsBlob, upImpl->spPeaksBlob,
240237
1.f, mPoseModel);
241238
// scaleInputToNetInputs[i], mPoseModel);
242239
}
@@ -364,7 +361,7 @@ namespace op
364361
#ifdef USE_CAFFE
365362
error("GPU pointer for people pose data not implemented yet.", __LINE__, __FUNCTION__, __FILE__);
366363
checkThread();
367-
return upImpl->spPoseBlob->gpu_data();
364+
return nullptr;
368365
#else
369366
return nullptr;
370367
#endif

0 commit comments

Comments
 (0)