{"id":13574169,"url":"https://github.com/yuanyuanli85/Fast_Human_Pose_Estimation_Pytorch","last_synced_at":"2025-04-04T14:31:59.169Z","repository":{"id":35529737,"uuid":"166133477","full_name":"yuanyuanli85/Fast_Human_Pose_Estimation_Pytorch","owner":"yuanyuanli85","description":"Pytorch Code for CVPR2019 paper \"Fast Human Pose Estimation\" https://arxiv.org/abs/1811.05419","archived":false,"fork":false,"pushed_at":"2022-11-22T04:30:14.000Z","size":6824,"stargazers_count":326,"open_issues_count":19,"forks_count":53,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-11-05T09:43:56.467Z","etag":null,"topics":["knowledge-distillation","pose-estimation","pytorch","stacked-hourglass-networks"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuanyuanli85.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-17T00:38:16.000Z","updated_at":"2024-10-30T08:46:34.000Z","dependencies_parsed_at":"2023-01-15T23:01:12.968Z","dependency_job_id":null,"html_url":"https://github.com/yuanyuanli85/Fast_Human_Pose_Estimation_Pytorch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanyuanli85%2FFast_Human_Pose_Estimation_Pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanyuanli85%2FFast_Human_Pose_Estimation_Pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanyuanli85%2FFast_Human_Pose_Estimation_Pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanyuanli85%2FFast_Human_Pose_Estimation_Pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuanyuanli85","download_url":"https://codeload.github.com/yuanyuanli85/Fast_Human_Pose_Estimation_Pytorch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247194178,"owners_count":20899439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["knowledge-distillation","pose-estimation","pytorch","stacked-hourglass-networks"],"created_at":"2024-08-01T15:00:47.479Z","updated_at":"2025-04-04T14:31:54.160Z","avatar_url":"https://github.com/yuanyuanli85.png","language":"Python","funding_links":[],"categories":["Table of Contents","PyTorch"],"sub_categories":["AI - Computer Vision"],"readme":"# Fast Human Pose Estimation Pytorch\n\nThis is an unoffical implemention for paper [Fast Human Pose Estimation, Feng Zhang, Xiatian Zhu, Mao Ye](https://arxiv.org/abs/1811.05419). \nMost of code comes from pytorch implementation for stacked hourglass network [pytorch-pose](https://github.com/bearpaw/pytorch-pose).\nIn this repo, we followed Fast Pose Distillation approach proposed by Fast Human Pose Estimation to improve accuracy of a lightweight network. We first trained a deep \nteacher network (stacks=8, standard convolution, **88.33**@Mpii pckh), and used it to teach a student network (stacks=2, depthwise convolution, **84.69%**@Mpii pckh).\nOur experiment shows **0.7%** gain from knowledge distillation.\n\nI benchmarked the light student model `hg_s2_b1_mobile_fpd` and got **43fps** on **i7-8700K** via **OpenVino**. Details can be found from [Fast_Stacked_Hourglass_Network_OpenVino](https://github.com/yuanyuanli85/Fast_Stacked_Hourglass_Network_OpenVino)\n\nPlease check the offical implementation by [fast-human-pose-estimation.pytorch](https://github.com/ilovepose/fast-human-pose-estimation.pytorch)\n\n## Update at Feb 2019\n* Model trained by using extra unlabeled images uploaded, `hg_s2_b1_mobile_fpd_unlabeled`  shows **0.28%** extra gain from knowledge transfered from teacher on unlabeled data. \n* The key idea is inserting unlabeled images into mpii dataset. For unlabeled samples, loss comes from difference b/w teacher and student. For labeled samples, loss is the sum of teacher-vs-student and student-vs-groundtruth.\n\n## Results \n`hg_s8_b1`: teacher model, `hg_s2_b1_mobile`:student model, `hg_s2_b1_mobile_kd`: student model trained with FPD. `hg_s2_b1_mobile_fpd_unlabeled`: student model trained with FPD with extral unlabeled samples.\n\n| Model|in_res |featrues| # of Weights |Head|Shoulder|\tElbow|\tWrist|\tHip\t|Knee|\tAnkle|\tMean| GFlops | Link|\n| --- |---| ----|----------- | ----| ----| ---| ---| ---| ---| ---| ---|----| ----|\n| hg_s8_b1|256|128|25.59m| 96.59| 95.35| 89.38| 84.15| 88.70| 83.98 |79.59| 88.33|28|[GoogleDrive](https://drive.google.com/open?id=1yzR8UwhklJTMMJEtjK10oyYG1tVRtkqi)\n| hg_s2_b1_mobile|256|128|2.31m|95.80|  93.61| 85.50| 79.63| 86.13| 77.82| 73.62|  84.69|3.2|[GoogleDrive](https://drive.google.com/open?id=1FxTRhiw6_dS8X1jBBUw_bxHX6RoBJaJO)\n| hg_s2_b1_mobile_fpd|256|128|2.31m| 95.67|94.07| 86.31| 79.68| 86.00| 79.67|75.51| 85.41|3.2|[GoogleDrive](https://drive.google.com/open?id=1zFoecNCc7alND8ODh8lg3UeRaB6_gY_V)\n| hg_s2_b1_mobile_fpd_unlabeled|256|128|2.31m| 95.94|94.11| 87.18| 80.69| 87.03| 79.17|74.82| 85.69|3.2|[GoogleDrive](https://drive.google.com/open?id=1mSFD2cn8fMb1YQJPOjfU-RLVnYO1LoAl)\n\n\n## Installation\n1. Create a virtualenv\n   ```\n   virtualenv -p /usr/bin/python2.7 pose_venv\n   ```\n2. Clone the repository with submodule\n    ```\n    git clone --recursive https://github.com/yuanyuanli85/Fast_Human_Pose_Estimation_Pytorch.git\n    ```\n3. Install all dependencies in virtualenv\n    ```\n    source posevenv/bin/activate\n    pip install -r requirements.txt\n    ```\n4. Create a symbolic link to the `images` directory of the MPII dataset:\n   ```\n   ln -s PATH_TO_MPII_IMAGES_DIR data/mpii/images\n   ```\n\n5. Disable cudnn for batchnorm layer to solve bug in pytorch0.4.0\n    ```\n    sed -i \"1194s/torch\\.backends\\.cudnn\\.enabled/False/g\" ./pose_venv/lib/python2.7/site-packages/torch/nn/functional.py\n    ```\n\n## Quick Demo\n* Download pre-trained model[hg_s2_b1_mobile_fpd](https://drive.google.com/open?id=1zFoecNCc7alND8ODh8lg3UeRaB6_gY_V)) and save it to somewhere, i.e `checkpoint/mpii_hg_s2_b1_mobile_fpd/`\n* Run demo on sample image\n```buildoutcfg\npython tools/mpii_demo.py -a hg -s 2 -b 1 --mobile True --checkpoint checkpoint/mpii_hg_s2_b1_mobile_fpd/model_best.pth.tar --in_res 256 --device cuda \n```     \n* You will see the detected keypoints drawn on image on your screen\n    \n    \n## Training teacher network \n* In our experiments, we used stack=8 input resolution=256 as teacher network \n```sh\npython example/mpii.py -a hg --stacks 8 --blocks 1 --checkpoint checkpoint/hg_s8_b1/ \n```\n* Run evaluation to get val score.\n```sh\npython tools/mpii.py -a hg --stacks 8 --blocks 1 --checkpoint checkpoint/hg_s8_b1/preds_best.mat \n```\n\n## Training with Knowledge Distillation \n\n* Download teacher model's checkpoint or you can train from scratch. In our experiments, we used `hg_s8_b1` as teacher.  \n\n* Train student network with knowledge distillation from teacher \n```sh\npython example/mpii_kd.py -a hg --stacks 2 --blocks 1 --checkpoint checkpoint/hg_s2_b1_mobile/ mobile=True --teacher_stack 8 --teacher_checkpoint \ncheckpoint/hg_s8_b1/model_best.pth.tar  \n```\n\n## Evaluation\n\nRun evaluation to generate mat file\n```sh\npython example/mpii.py -a hg --stacks 2 --blocks 1 --checkpoint checkpoint/hg_s2_b1/ --resume checkpoint/hg_s2_b1/model_best.pth.tar -e\n```\n* `--resume_checkpoint` is the checkpoint want to evaluate\n\nRun `tools/eval_PCKh.py` to get val score \n\n## Export pytorch checkpoint to onnx \n```sh\npython tools/mpii_export_to_onxx.py -a hg -s 2 -b 1 --num-classes 16 --mobile True --in_res 256  --checkpoint checkpoint/model_best.pth.tar \n--out_onnx checkpoint/model_best.onnx \n```\nHere \n* `--checkpoint` is the checkpoint want to export \n* `--out_onnx` is the exported onnx file\n\n\n## Reference \n* OpenVino: https://github.com/opencv/dldt\n* Pytorch-pose: https://github.com/yuanyuanli85/pytorch-pose\n* Fast Human Pose Estimation https://github.com/yuanyuanli85/Fast_Human_Pose_Estimation_Pytorch\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuanyuanli85%2FFast_Human_Pose_Estimation_Pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuanyuanli85%2FFast_Human_Pose_Estimation_Pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuanyuanli85%2FFast_Human_Pose_Estimation_Pytorch/lists"}