Daniil-Osokin / lightweight-human-pose-estimation.pytorch

Fast and accurate human pose estimation in PyTorch. Contains implementation of "Real-time 2D Multi-Person Pose Estimation on CPU: Lightweight OpenPose" paper.
Apache License 2.0
2.11k stars 479 forks source link

Meet problem in coco.py line120 #273

Closed Candy-CY closed 2 years ago

Candy-CY commented 2 years ago

Hello again, I'm Candy! Now I meet some problems in code and hope you can give me some methods to solve it. These days, I am trying a new keypoints model (eg. openpose contains 18 keypoints), now I want to add some new keypoints base on it , so I hope my model can recongnize 22 keypoints in total, but based on your code, I have changed the essential information about keypoints list (BODY_PARTS_KPT_IDS) in the code、 the code of PAF list (BODY_PARTS_PAF_IDS) and add some weight parameters about these. About the dataset, we use the dataset which is labeled by our team and change its type same as coco, but the code is still not to go, the wrong infomation as follow: datasets/coco.py", line 120, in _generate_paf_maps keypoint_a = label['keypoints'][BODY_PARTS_KPT_IDS[paf_idx][0]] TypeError: list indices must be integers or slices, not float Since this is a newly defined model about keypoints, I think I must have some mistakes in the process of modifying your code. I hope you can give me some suggestions about creating new model based on your code, so that I can quickly solve the problem and reproduce my model based on your code. Thank you again! Wish you all the best in your work and happy everyday!

Daniil-Osokin commented 2 years ago

Hi! The error is general to Python not the pose estimation code. It tells that one of your list indices, possibly the paf_idx is float, but has to be the integer. So, you can either use int(paf_idx) instead, or check why paf_idx is float. In general, you need o extend the arrays with new keypoints pair and modify keypoint heatmaps generation code to support more keypoints.

Candy-CY commented 2 years ago

Thank you for your reply! Recently, I debug the 120 code line and find the list about the paf_idx value, even the list about keypoints value is not wrong , so I am confused about this problem. I also extend the list of BODY_PARTS_KPT_IDS、BODY_PARTS_PAF_IDS and the sigma value about PAF maps, but also get same wrong in this code line. I didn't understand the process about keypoint heatmaps generation code in this program every well. I hope you can give me a general explanation about the keypoint heatmaps generation. Thank you again! Wish you all the best in your work and happy everyday!

Daniil-Osokin commented 2 years ago

I did my best in TRAIN-ON-CUSTOM-DATASET.md with adapting the code to a custom dataset. The idea of keypoints heatmaps is to have keypoints of specific type (e.g. right shoulder) of all persons inside image in a single heatmap. All heatmaps are stored in single tensor, which has number of channels equals to the number of different keypoints (+1 for background). This code generates such tensor and this code puts single keypoint in the specified heatmap.

Candy-CY commented 2 years ago

Ok,Thank you again ! If I have any questions later, I hope you can help me to slove them !

Candy-CY commented 2 years ago

Hi, Dan!After the train.py and the val.py code has been modified, our dataset can now be used in the model for training, and obtained some .pth files. I thought it meant the model had been successfully trained, when I run the demo.py to the model, I found that the test images or the vedio have no labeled information after passing the code, I was very confused to get this result. What do you think have made this happen? dataset or the code ? Thank you ! Waiting for your reply!

Daniil-Osokin commented 2 years ago

Hi! You can check one of closed issues in this repository for debugging tips, e.g. #235. The first thing to try is to overfit during training on small dataset, e.g. 4 or 16 images without augmenations. If loss has decreased significantly, then it is time to train on bigger dataset, then check accuracy on validation dataset. Since you have trained model, you can visualize its heatmaps to see if keypoints are predicted at proper place (where person has it).

Daniil-Osokin commented 2 years ago

Hope, it helped.