{"id":18638841,"url":"https://github.com/stefanopini/simple-hrnet","last_synced_at":"2025-04-05T03:10:19.528Z","repository":{"id":54194741,"uuid":"185399952","full_name":"stefanopini/simple-HRNet","owner":"stefanopini","description":"Multi-person Human Pose Estimation with HRNet in Pytorch","archived":false,"fork":false,"pushed_at":"2022-12-29T18:17:05.000Z","size":79981,"stargazers_count":589,"open_issues_count":7,"forks_count":110,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T02:06:48.257Z","etag":null,"topics":["coco-dataset","computer-vision","deep-learning","hrnet","human-pose-estimation","keypoint-detection","machine-learning","pytorch","yolov3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stefanopini.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-05-07T12:43:37.000Z","updated_at":"2025-03-18T11:10:47.000Z","dependencies_parsed_at":"2023-01-31T09:31:35.592Z","dependency_job_id":null,"html_url":"https://github.com/stefanopini/simple-HRNet","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/stefanopini%2Fsimple-HRNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanopini%2Fsimple-HRNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanopini%2Fsimple-HRNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanopini%2Fsimple-HRNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefanopini","download_url":"https://codeload.github.com/stefanopini/simple-HRNet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280272,"owners_count":20912967,"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":["coco-dataset","computer-vision","deep-learning","hrnet","human-pose-estimation","keypoint-detection","machine-learning","pytorch","yolov3"],"created_at":"2024-11-07T05:43:57.552Z","updated_at":"2025-04-05T03:10:19.505Z","avatar_url":"https://github.com/stefanopini.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Multi-person Human Pose Estimation with HRNet in PyTorch\n\nThis is an unofficial implementation of the paper\n [*Deep High-Resolution Representation Learning for Human Pose Estimation*](https://arxiv.org/abs/1902.09212).  \nThe code is a simplified version of the [official code](https://github.com/leoxiaobin/deep-high-resolution-net.pytorch)\n with the ease-of-use in mind.\n\nThe code is fully compatible with the\n [official pre-trained weights](https://github.com/leoxiaobin/deep-high-resolution-net.pytorch) and the results are the\n same of the original implementation (only slight differences on gpu due to CUDA).\n It supports both Windows and Linux.\n\n\nThis repository provides:\n- A simple ``HRNet`` implementation in PyTorch (\u003e=1.0) - compatible with official weights (``pose_hrnet_*``).\n- A simple class (``SimpleHRNet``) that loads the HRNet network for the human pose estimation, loads the pre-trained weights,\n and make human predictions on a single image or a batch of images.\n- Support for \"SimpleBaselines\" model based on ResNet - compatible with official weights (``pose_resnet_*``).\n- Support for multi-GPU inference.\n- Add options for retrieving yolo bounding boxes and HRNet heatmaps.\n- **NEW** Multi-person support with\n [YOLOv3](https://github.com/eriklindernoren/PyTorch-YOLOv3/tree/47b7c912877ca69db35b8af3a38d6522681b3bb3) \n (enabled by default), YOLOv3-tiny, or [YOLOv5](https://github.com/ultralytics/yolov5) by Ultralytics.\n- A reference code that runs a live demo reading frames from a webcam or a video file.\n- A relatively-simple code for training and testing the HRNet network.\n- A specific script for training the network on the COCO dataset. \n- **NEW** An updated [Jupyter Notebook](https://github.com/stefanopini/simple-HRNet/blob/master/SimpleHRNet_notebook.ipynb) compatible with Google Colab showcasing how to use this repository.\n    - \u003ca href=\"https://colab.research.google.com/github/stefanopini/simple-HRNet/blob/master/SimpleHRNet_notebook.ipynb\"\u003e\u003cimg src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"\u003e\u003c/a\u003e [Click here](https://colab.research.google.com/github/stefanopini/simple-HRNet/blob/master/SimpleHRNet_notebook.ipynb) to open the notebook on Colab!\n    - Thanks to [@basicvisual](https://github.com/basicvisual) and [@wuyenlin](https://github.com/wuyenlin) for the initial notebook.\n- **NEW** Support for TensorRT (thanks to [@gpastal24](https://github.com/gpastal24), see [#99](https://github.com/stefanopini/simple-HRNet/pull/99) and [#100](https://github.com/stefanopini/simple-HRNet/pull/100)).\n\n\nIf you are interested in **HigherHRNet**, please look at [*simple-HigherHRNet*](https://github.com/stefanopini/simple-HigherHRNet) \n \n### Examples\n\n\u003ctable\u003e\n \u003ctr\u003e\n  \u003ctd align=\"center\"\u003e\u003cimg src=\"./gifs/gif-01-output.gif\" width=\"100%\" height=\"auto\" /\u003e\u003c/td\u003e\n  \u003ctd align=\"center\"\u003e\u003cimg src=\"./gifs/gif-02-output.gif\" width=\"100%\" height=\"auto\" /\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/table\u003e\n\n### Class usage\n\n```\nimport cv2\nfrom SimpleHRNet import SimpleHRNet\n\nmodel = SimpleHRNet(48, 17, \"./weights/pose_hrnet_w48_384x288.pth\")\nimage = cv2.imread(\"image.png\", cv2.IMREAD_COLOR)\n\njoints = model.predict(image)\n```\n\nThe most useful parameters of the `__init__` function are:\n\u003ctable\u003e\n \u003ctr\u003e\n  \u003ctd\u003ec\u003c/td\u003e\u003ctd\u003enumber of channels (HRNet: 32, 48; PoseResNet: resnet size)\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003enof_joints\u003c/td\u003e\u003ctd\u003enumber of joints (COCO: 17, MPII: 16)\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003echeckpoint_path\u003c/td\u003e\u003ctd\u003epath of the (official) weights to be loaded\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003emodel_name\u003c/td\u003e\u003ctd\u003e'HRNet' or 'PoseResNet'\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003eresolution\u003c/td\u003e\u003ctd\u003eimage resolution, it depends on the loaded weights\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003emultiperson\u003c/td\u003e\u003ctd\u003eenable multiperson prediction\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003ereturn_heatmaps\u003c/td\u003e\u003ctd\u003ethe `predict` method returns also the heatmaps\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003ereturn_bounding_boxes\u003c/td\u003e\u003ctd\u003ethe `predict` method returns also the bounding boxes (useful in conjunction with \n  `multiperson`)\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003emax_batch_size\u003c/td\u003e\u003ctd\u003emaximum batch size used in hrnet inference\u003c/td\u003e\n \u003c/tr\u003e\n \u003ctr\u003e\n  \u003ctd\u003edevice\u003c/td\u003e\u003ctd\u003edevice (cpu or cuda)\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/table\u003e\n\n### Running the live demo\n\nFrom a connected camera:\n```\npython scripts/live-demo.py --camera_id 0\n```\nFrom a saved video:\n```\npython scripts/live-demo.py --filename video.mp4\n```\n\nFor help:\n```\npython scripts/live-demo.py --help\n```\n\n### Extracting keypoints:\n\nFrom a saved video:\n```\npython scripts/extract-keypoints.py --format csv --filename video.mp4\n```\n\nFor help:\n```\npython scripts/extract-keypoints.py --help\n```\n\n### Converting the model to TensorRT:\n\nWarning: require the installation of TensorRT (see Nvidia website) and onnx.\nOn some platforms, they can be installed with\n```\npip install tensorrt onnx\n```\n\nConverting in FP16:\n```\npython scripts/export-tensorrt-model.py --device 0 --half\n```\n\nFor help:\n```\npython scripts/export-tensorrt-model.py --help\n```\n\n### Running the training script\n\n```\npython scripts/train_coco.py\n```\n\nFor help:\n```\npython scripts/train_coco.py --help\n```\n\n### Installation instructions\n\n- Clone the repository  \n ``git clone https://github.com/stefanopini/simple-HRNet.git``\n- Install the required packages  \n ``pip install -r requirements.txt``\n- Download the official pre-trained weights from \n[https://github.com/leoxiaobin/deep-high-resolution-net.pytorch](https://github.com/leoxiaobin/deep-high-resolution-net.pytorch)  \n  Direct links ([official Drive folder](https://drive.google.com/drive/folders/1hOTihvbyIxsm5ygDpbUuJ7O_tzv4oXjC), [official OneDrive folder](https://1drv.ms/f/s!AhIXJn_J-blW231MH2krnmLq5kkQ)):\n  - COCO w48 384x288 (more accurate, but slower) - Used as default in `live_demo.py` and the other scripts  \n    [pose_hrnet_w48_384x288.pth](https://drive.google.com/open?id=1UoJhTtjHNByZSm96W3yFTfU5upJnsKiS)\n  - COCO w32 256x192 (less accurate, but faster)  \n    [pose_hrnet_w32_256x192.pth](https://drive.google.com/open?id=1zYC7go9EV0XaSlSBjMaiyE_4TcHc_S38)\n  - MPII w32 256x256 (MPII human joints)  \n    [pose_hrnet_w32_256x256.pth](https://drive.google.com/open?id=1_wn2ifmoQprBrFvUCDedjPON4Y6jsN-v)\n\n  Remember to set the parameters of SimpleHRNet accordingly (in particular `c`, `nof_joints`, and `resolution`).\n- For multi-person support:\n    - Get YOLOv3:\n        - Clone [YOLOv3](https://github.com/eriklindernoren/PyTorch-YOLOv3/tree/47b7c912877ca69db35b8af3a38d6522681b3bb3) \nin the folder ``./models/detectors`` and change the folder name from ``PyTorch-YOLOv3`` to ``yolo``  \n          OR\n        - Update git submodules  \n        ``git submodule update --init --recursive``\n    - Install YOLOv3 required packages  \n       ``pip install -r requirements.txt`` (from folder `./models/detectors/yolo`)\n    - Download the pre-trained weights running the script ``download_weights.sh`` from the ``weights`` folder\n- (Optional) Download the [COCO dataset](http://cocodataset.org/#download) and save it in ``./datasets/COCO``\n- Your folders should look like:\n    ```\n    simple-HRNet\n    ├── datasets                (datasets - for training only)\n    │  └── COCO                 (COCO dataset)\n    ├── losses                  (loss functions)\n    ├── misc                    (misc)\n    │  └── nms                  (CUDA nms module - for training only)\n    ├── models                  (pytorch models)\n    │  └── detectors            (people detectors)\n    │    └── yolo               (PyTorch-YOLOv3 repository)\n    │      ├── ...\n    │      └── weights          (YOLOv3 weights)\n    ├── scripts                 (scripts)\n    ├── testing                 (testing code)\n    ├── training                (training code)\n    └── weights                 (HRnet weights)\n    ```\n- If you want to run the training script on COCO `scripts/train_coco.py`, you have to build the `nms` module first.  \n  Please note that a linux machine with CUDA is currently required. \n  Build it with either: \n  - `cd misc; make` or\n  - `cd misc/nms; python setup_linux.py build_ext --inplace`  \n  \n  You may need to add the `./misc/nms` directory in the `PYTHONPATH` variable:  \n  `export PYTHONPATH=\"\u003cpath-to-simple-HRNet\u003e/misc/nms:$PYTHONPATH\"`\n\n### Google Colab notebook\nThanks to the great work of [@basicvisual](https://github.com/basicvisual) and [@wuyenlin](https://github.com/wuyenlin), you can also try this repository online on Google Colab.\nMore details and the notebook URL are available in [this issue](https://github.com/stefanopini/simple-HRNet/issues/84#issuecomment-908199736).  \nPlease make sure to make a copy on your own Google Drive and to change the Colab \"Runtime type\" from CPU to GPU or TPU.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanopini%2Fsimple-hrnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanopini%2Fsimple-hrnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanopini%2Fsimple-hrnet/lists"}