Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

This is an official pytorch implementation of Lite-HRNet: A Lightweight High-Resolution Network.

License

NotificationsYou must be signed in to change notification settings

HRNet/Lite-HRNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This is an official pytorch implementation ofLite-HRNet: A Lightweight High-Resolution Network. In this work, we present an efficient high-resolution network, Lite-HRNet, for human pose estimation. We start by simply applying the efficient shuffle block in ShuffleNet to HRNet (high-resolution network), yielding stronger performance over popular lightweight networks, such as MobileNet, ShuffleNet, and Small HRNet. We find that the heavily-used pointwise (1x1) convolutions in shuffle blocks become the computational bottleneck. We introduce a lightweight unit, conditional channel weighting, to replace costly pointwise (1x1) convolutions in shuffle blocks. The complexity of channel weighting is linear w.r.t the number of channels and lower than the quadratic time complexity for pointwise convolutions. Our solution learns the weights from all the channels and over multiple resolutions that are readily available in the parallel branches in HRNet. It uses the weights as the bridge to exchange information across channels and resolutions, compensating the role played by the pointwise (1x1) convolution. Lite-HRNet demonstrates superior results on human pose estimation over popular lightweight networks. Moreover, Lite-HRNet can be easily applied to semantic segmentation task in the same lightweight manner.

Results and models

Results on COCO val2017 with detector having human AP of 56.4 on COCO val2017 dataset

ArchInput Size#ParamsFLOPsAPAP50AP75ARAR50ckpt
Naive Lite-HRNet-18256x1920.7M194.8M0.6280.8550.6990.6910.901GoogleDrive orOneDrive
Wider Naive Lite-HRNet-18256x1921.3M311.1M0.6600.8710.7370.7210.913GoogleDrive orOneDrive
Lite-HRNet-18256x1921.1M205.2M0.6480.8670.7300.7120.911GoogleDrive orOneDrive
Lite-HRNet-18384x2881.1M461.6M0.6760.8780.7500.7370.921GoogleDrive orOneDrive
Lite-HRNet-30256x1921.8M319.2M0.6720.8800.7500.7330.922GoogleDrive orOneDrive
Lite-HRNet-30384x2881.8M717.8M0.7040.8870.7770.7620.928GoogleDrive orOneDrive

Results on MPII val set

ArchInput Size#ParamsFLOPsMeanMean@0.1ckpt
Naive Lite-HRNet-18256x2560.7M259.6M0.8530.305GoogleDrive orOneDrive
Wider Naive Lite-HRNet-18256x2561.3M418.7M0.8680.311GoogleDrive orOneDrive
Lite-HRNet-18256x2561.1M273.4M0.8540.295GoogleDrive orOneDrive
Lite-HRNet-30256x2561.8M425.3M0.8700.313GoogleDrive orOneDrive

Enviroment

The code is developed using python 3.6 on Ubuntu 16.04. NVIDIA GPUs are needed. The code is developed and tested using 8 NVIDIA V100 GPU cards. Other platforms or GPU cards are not fully tested.

Quick Start

Requirements

  • Linux (Windows is not officially supported)
  • Python 3.6+
  • PyTorch 1.3+
  • CUDA 9.2+ (If you build PyTorch from source, CUDA 9.0 is also compatible)
  • GCC 5+
  • mmcv (Please install the latest version of mmcv-full)
  • Numpy
  • cv2
  • json_tricks
  • xtcocotools

Installation

a. Install mmcv, we recommend you to install the pre-build mmcv as below.

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html

Please replace{cu_version} and{torch_version} in the url to your desired one. For example, to install the latestmmcv-full withCUDA 11 andPyTorch 1.7.0, use the following command:

pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu110/torch1.7.0/index.html

If it compiles during installation, then please check that the cuda version and pytorch version **exactly"" matches the version in the mmcv-full installation command. For example, pytorch 1.7.0 and 1.7.1 are treated differently.Seehere for different versions of MMCV compatible to different PyTorch and CUDA versions.

Optionally you can choose to compile mmcv from source by the following command

git clone https://github.com/open-mmlab/mmcv.gitcd mmcvMMCV_WITH_OPS=1 pip install -e.# package mmcv-full, which contains cuda ops, will be installed after this step# OR pip install -e .  # package mmcv, which contains no cuda ops, will be installed after this stepcd ..

Or directly run

pip install mmcv-full# alternative: pip install mmcv

Important: You need to runpip uninstall mmcv first if you have mmcv installed. If mmcv and mmcv-full are both installed, there will beModuleNotFoundError.

b. Install build requirements

pip install -r requirements.txt

Prepare datasets

It is recommended to symlink the dataset root to$LITE_HRNET/data.If your folder structure is different, you may need to change the corresponding paths in config files.

For COCO data, please download fromCOCO download, 2017 Train/Val is needed for COCO keypoints training and validation.HRNet-Human-Pose-Estimation provides person detection result of COCO val2017 to reproduce our multi-person pose estimation results. Please download fromOneDriveDownload and extract them under$LITE_HRNET/data, and make them look like this:

lite_hrnet├── configs├── models├── tools`── data    │── coco        │-- annotations        │   │-- person_keypoints_train2017.json        │   |-- person_keypoints_val2017.json        |-- person_detection_results        |   |-- COCO_val2017_detections_AP_H_56_person.json        │-- train2017        │   │-- 000000000009.jpg        │   │-- 000000000025.jpg        │   │-- 000000000030.jpg        │   │-- ...        `-- val2017            │-- 000000000139.jpg            │-- 000000000285.jpg            │-- 000000000632.jpg            │-- ...

For MPII data, please download fromMPII Human Pose Dataset.We have converted the original annotation files into json format, please download them frommpii_annotations.Extract them under$LITE_HRNET/data, and make them look like this:

lite_hrnet├── configs├── models├── tools`── data    │── mpii        |── annotations        |   |── mpii_gt_val.mat        |   |── mpii_test.json        |   |── mpii_train.json        |   |── mpii_trainval.json        |   `── mpii_val.json        `── images            |── 000001163.jpg            |── 000003072.jpg

Training and Testing

All outputs (log files and checkpoints) will be saved to the working directory,which is specified bywork_dir in the config file.

By default we evaluate the model on the validation set after each epoch, you can change the evaluation interval by modifying the interval argument in the training config

evaluation=dict(interval=5)# This evaluate the model per 5 epoch.

According to theLinear Scaling Rule, you need to set the learning rate proportional to the batch size if you use different GPUs or videos per GPU, e.g., lr=0.01 for 4 GPUs x 2 video/gpu and lr=0.08 for 16 GPUs x 4 video/gpu.

Training

# train with a signle GPUpython tools/train.py${CONFIG_FILE} [optional arguments]# train with multiple GPUs./tools/dist_train.sh${CONFIG_FILE}${GPU_NUM} [optional arguments]

Optional arguments are:

  • --validate (strongly recommended): Perform evaluation at every k (default value is 5 epochs during the training.
  • --work-dir ${WORK_DIR}: Override the working directory specified in the config file.
  • --resume-from ${CHECKPOINT_FILE}: Resume from a previous checkpoint file.
  • --gpus ${GPU_NUM}: Number of gpus to use, which is only applicable to non-distributed training.
  • --seed ${SEED}: Seed id for random state in python, numpy and pytorch to generate random numbers.
  • --deterministic: If specified, it will set deterministic options for CUDNN backend.
  • JOB_LAUNCHER: Items for distributed job initialization launcher. Allowed choices arenone,pytorch,slurm,mpi. Especially, if set to none, it will test in a non-distributed mode.
  • LOCAL_RANK: ID for local rank. If not specified, it will be set to 0.
  • --autoscale-lr: If specified, it will automatically scale lr with the number of gpus byLinear Scaling Rule.

Difference betweenresume-from andload-from:resume-from loads both the model weights and optimizer status, and the epoch is also inherited from the specified checkpoint. It is usually used for resuming the training process that is interrupted accidentally.load-from only loads the model weights and the training epoch starts from 0. It is usually used for finetuning.

Examples:

Training on COCO train2017 dataset

./tools/dist_train.sh configs/top_down/lite_hrnet/coco/litehrnet_18_coco_256x192.py 8

Training on MPII dataset

./tools/dist_train.sh configs/top_down/lite_hrnet/mpii/litehrnet_18_mpii_256x256.py 8

Testing

You can use the following commands to test a dataset.

# single-gpu testingpython tools/test.py${CONFIG_FILE}${CHECKPOINT_FILE} [--out${RESULT_FILE}] [--eval${EVAL_METRIC}] \    [--proc_per_gpu${NUM_PROC_PER_GPU}] [--gpu_collect] [--tmpdir${TMPDIR}] [--average_clips${AVG_TYPE}] \    [--launcher${JOB_LAUNCHER}] [--local_rank${LOCAL_RANK}]# multiple-gpu testing./tools/dist_test.py${CONFIG_FILE}${CHECKPOINT_FILE}${GPU_NUM} [--out${RESULT_FILE}] [--eval${EVAL_METRIC}] \    [--proc_per_gpu${NUM_PROC_PER_GPU}] [--gpu_collect] [--tmpdir${TMPDIR}] [--average_clips${AVG_TYPE}] \    [--launcher${JOB_LAUNCHER}] [--local_rank${LOCAL_RANK}]

Optional arguments:

  • RESULT_FILE: Filename of the output results. If not specified, the results will not be saved to a file.
  • EVAL_METRIC: Items to be evaluated on the results. Allowed values depend on the dataset.
  • NUM_PROC_PER_GPU: Number of processes per GPU. If not specified, only one process will be assigned for a single gpu.
  • --gpu_collect: If specified, recognition results will be collected using gpu communication. Otherwise, it will save the results on different gpus toTMPDIR and collect them by the rank 0 worker.
  • TMPDIR: Temporary directory used for collecting results from multiple workers, available when--gpu_collect is not specified.
  • AVG_TYPE: Items to average the test clips. If set toprob, it will apply softmax before averaging the clip scores. Otherwise, it will directly average the clip scores.
  • JOB_LAUNCHER: Items for distributed job initialization launcher. Allowed choices arenone,pytorch,slurm,mpi. Especially, if set to none, it will test in a non-distributed mode.
  • LOCAL_RANK: ID for local rank. If not specified, it will be set to 0.

Examples:

Test LiteHRNet-18 on COCO with 8 GPUS, and evaluate the mAP.

./tools/dist_test.sh configs/top_down/lite_hrnet/coco/litehrnet_18_coco_256x192.py \    checkpoints/SOME_CHECKPOINT.pth 8 \    --eval mAP

Get the compulationaly complexity

You can use the following commands to compute the complexity of one model.

python tools/summary_network.py${CONFIG_FILE} --shape${SHAPE}

Arguments:

  • SHAPE: Input size.

Examples:

Test the complexity of LiteHRNet-18 with 256x256 resolution input.

python tools/summary_network.py configs/top_down/lite_hrnet/coco/litehrnet_18_coco_256x192.py \    --shape 256 256 \

Acknowledgement

Thanks to:

Citation

If you use our code or models in your research, please cite with:

@inproceedings{Yulitehrnet21,  title={Lite-HRNet: A Lightweight High-Resolution Network},  author={Yu, Changqian and Xiao, Bin and Gao, Changxin and Yuan, Lu and Zhang, Lei and Sang, Nong and Wang, Jingdong},  booktitle={CVPR},  year={2021}}@inproceedings{SunXLW19,  title={Deep High-Resolution Representation Learning for Human Pose Estimation},  author={Ke Sun and Bin Xiao and Dong Liu and Jingdong Wang},  booktitle={CVPR},  year={2019}}@article{WangSCJDZLMTWLX19,  title={Deep High-Resolution Representation Learning for Visual Recognition},  author={Jingdong Wang and Ke Sun and Tianheng Cheng and           Borui Jiang and Chaorui Deng and Yang Zhao and Dong Liu and Yadong Mu and           Mingkui Tan and Xinggang Wang and Wenyu Liu and Bin Xiao},  journal={TPAMI}  year={2019}}

About

This is an official pytorch implementation of Lite-HRNet: A Lightweight High-Resolution Network.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp