Git Product home page Git Product logo

hrnet-maskrcnn-benchmark's Introduction

HRNet for Object Detection

Introduction

This is the official code of High-Resolution Representations for Object Detection. We extend the high-resolution representation (HRNet) [1] by augmenting the high-resolution representation by aggregating the (upsampled) representations from all the parallel convolutions, leading to stronger representations. We build a multi-level representation from the high resolution and apply it to the Faster R-CNN, Mask R-CNN and Cascade R-CNN framework. This proposed approach achieves superior results to existing single-model networks on COCO object detection. The code is based on maskrcnn-benchmark

Performance

ImageNet Pretrained Models

HRNetV2 ImageNet pretrained models are now available! Codes and pretrained models are in HRNets for Image Classification

All models are trained on COCO train2017 set and evaluated on COCO val2017 set. Detailed settings or configurations are in configs/hrnet.

Note: Models are trained with the newly released code and the results have minor differences with that in the paper. Current results will be updated soon and more models and results are comming. All models are trained on COCO train2017 set and evaluated on COCO val2017 set. Detailed settings or configurations are in configs/hrnet.

Faster R-CNN

Backbone lr sched mAP model
HRNetV2-W18 1x 36.0 FasterR-CNN-HR18-1x.pth
HRNetV2-W18 2x 38.4 FasterR-CNN-HR18-2x.pth
HRNetV2-W32 1x 39.6 FasterR-CNN-HR32-1x.pth
HRNetV2-W32 2x 40.9 FasterR-CNN-HR32-2x.pth
HRNetV2-W40 1x 40.4 FasterR-CNN-HR40-1x.pth
HRNetV2-W40 2x 41.4 FasterR-CNN-HR40-2x.pth
HRNetV2-W48 1x 41.3 FasterR-CNN-HR48-1x.pth
HRNetV2-W48 2x 41.8 FasterR-CNN-HR48-2x.pth

Faster R-CNN with more training iterations

Backbone lr sched mAP model
HRNetV2-W32 1x 39.6 FasterR-CNN-HR32-1x.pth
HRNetV2-W32 2x 40.9 FasterR-CNN-HR32-2x.pth
HRNetV2-W32 3x 41.4 FasterR-CNN-HR32-3x.pth
HRNetV2-W32 4x 41.6 FasterR-CNN-HR32-4x.pth

Our HRNets will obtain larger gain when training with more iterations.

Quick start

Install

  1. Install PyTorch 1.0 following the official instructions

  2. Install pycocotools

git clone https://github.com/cocodataset/cocoapi.git \
 && cd cocoapi/PythonAPI \
 && python setup.py build_ext install \
 && cd ../../
  1. Install HRNet-MaskRCNN-Benchmark
git clone https://github.com/HRNet/HRNet-MaskRCNN-Benchmark.git
cd HRNet-MaskRCNN-Benchmark
python setup.py build develop
pip install -r requirements.txt

for more details, see INSTALL.md

HRNetV2 Pretrained models

cd HRNet-MaskRCNN-Benchmark
# Download pretrained models into this folder
mkdir hrnetv2_pretrained

Train (multi-gpu training)

Please specify the configuration file in configs (learning rate should be adjusted when the number of GPUs is changed).

python -m torch.distributed.launch --nproc_per_node <GPU NUMS> tools/train_net.py --config-file <CONFIG FILE>

# example (4 gpus)
python -m torch.distributed.launch --nproc_per_node 4 tools/train_net.py --config-file configs/hrnet/e2e_faster_rcnn_hrnet_w18_1x.yaml

Test

python -m torch.distributed.launch --nproc_per_node <GPU NUMS> tools/test_net.py --config-file <CONFIG-FILE> MODEL.WEIGHT <WEIGHT>

#example (4gpus)
python -m torch.distributed.launch --nproc_per_node 4 tools/test_net.py --config-file configs/hrnet/e2e_faster_rcnn_hrnet_w18_1x.yaml MODEL.WEIGHT FasterR-CNN-HR18-1x.pth

NOTE: If you meet some problems, you may find a solution in issues of official maskrcnn-benchmark or submit a new issue in our repo.

Other applications of HRNets (codes and models):

Citation

If you find this work or code is helpful in your research, please cite:

@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}
}

Reference

[1] Deep High-Resolution Representation Learning for Visual Recognition. Jingdong Wang, Ke Sun, Tianheng Cheng, Borui Jiang, Chaorui Deng, Yang Zhao, Dong Liu, Yadong Mu, Mingkui Tan, Xinggang Wang, Wenyu Liu, Bin Xiao. Accepted by TPAMI. download

[2] Cascade R-CNN: Delving into High Quality Object Detection. Zhaowei Cai, and Nuno Vasconcetos. CVPR 2018.

hrnet-maskrcnn-benchmark's People

Contributors

bearcatt avatar welleast avatar wondervictor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hrnet-maskrcnn-benchmark's Issues

coco data load error

Hi, to test your HRNet, I change paths_catalog.py to original maskrcnn-benchmark one because it is hard-coded by your path.

And then using this command, this error occurs.

CUDA_VISIBLE_DEVICES=0, python tools/test_net.py --config-file "configs/hrnet/e2e_faster_rcnn_hrnet_w48_2x.yaml" MODEL.WEIGHT FasterR-CNN-HR48-2x.pth TEST.IMS_PER_BATCH 1

2019-08-07 10:55:33,655 maskrcnn_benchmark.inference INFO: Start evaluation on coco_2017_val dataset(5000 images).
0%| | 0/5000 [00:00<?, ?it/s$
zip file 'datasets/coco/val2017.zip' is not found
zip file 'datasets/coco/val2017.zip' is not found
zip file 'datasets/coco/val2017.zip' is not found
zip file 'datasets/coco/val2017.zip' is not found
zip file 'datasets/coco/val2017.zip' is not found
zip file 'datasets/coco/val2017.zip' is not found
Traceback (most recent call last):
File "tools/test_net.py", line 258, in
zip file 'datasets/coco/val2017.zip' is not found
main()
File "tools/test_net.py", line 217, in main
output_folder=output_folder,
File "/home/lsrock1/HRNet-MaskRCNN-Benchmark/maskrcnn_benchmark/engine/inference.py", line 76, in inference
predictions = compute_on_dataset(model, data_loader, device)
File "/home/lsrock1/HRNet-MaskRCNN-Benchmark/maskrcnn_benchmark/engine/inference.py", line 20, in compute_on_dataset
for i, batch in enumerate(tqdm(data_loader)):
File "/home/lsrock1/anaconda3/envs/pytorch1.1/lib/python3.7/site-packages/tqdm/_tqdm.py", line 1022, in iter
zip file 'datasets/coco/val2017.zip' is not found
for obj in iterable:
File "/home/lsrock1/anaconda3/envs/pytorch1.1/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 582, in next
zip file 'datasets/coco/val2017.zip' is not found
return self._process_next_batch(batch)
File "/home/lsrock1/anaconda3/envs/pytorch1.1/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 608, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
AssertionError: Traceback (most recent call last):
File "/home/lsrock1/anaconda3/envs/pytorch1.1/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 99, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/lsrock1/anaconda3/envs/pytorch1.1/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 99, in
samples = collate_fn([dataset[i] for i in batch_indices])
File "/home/lsrock1/HRNet-MaskRCNN-Benchmark/maskrcnn_benchmark/data/datasets/coco.py", line 56, in getitem
cv2.IMREAD_COLOR | cv2.IMREAD_IGNORE_ORIENTATION)
File "/home/lsrock1/HRNet-MaskRCNN-Benchmark/maskrcnn_benchmark/utils/zipreader.py", line 32, in imread
assert 0
AssertionError

Should I prepare .zip file?

In origin maskrcnn-benchmark, they only need images/annotations folders.

I can't find your coco dataset setting instructions.

undefined symbol: _ZN2at19UndefinedTensorImpl10_singletonE

ImportError: /hr/hrmask/maskrcnn_benchmark/_C.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN2at19UndefinedTensorImpl10_singletonE
Traceback (most recent call last):
File "/miniconda/envs/py36/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/miniconda/envs/py36/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/miniconda/envs/py36/lib/python3.6/site-packages/torch/distributed/launch.py", line 263, in
main()
File "/miniconda/envs/py36/lib/python3.6/site-packages/torch/distributed/launch.py", line 259, in main
cmd=cmd)
subprocess.CalledProcessError: Command '['/miniconda/envs/py36/bin/python', '-u', 'tools/train_net.py', '--local_rank=6', '--config-file', 'configs/hrnet/e2e_faster_rcnn_hrnet_w18_1x.yaml']' returned non-zero exit status 1.


Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.


Error during training

!python tools/train_net.py --config-file "/usr/local/HRNet-MaskRCNN-Benchmark/configs/hrnet/mask_rcnn_hrnet_w18_1x.yaml"

Error
/usr/local/HRNet-MaskRCNN-Benchmark
Traceback (most recent call last):
File "tools/train_net.py", line 22, in
from maskrcnn_benchmark.utils.checkpoint import DetectronCheckpointer
File "/usr/local/HRNet-MaskRCNN-Benchmark/maskrcnn_benchmark/utils/checkpoint.py", line 10, in
from maskrcnn_benchmark.utils.model_zoo import cache_url
File "/usr/local/HRNet-MaskRCNN-Benchmark/maskrcnn_benchmark/utils/model_zoo.py", line 5, in
from torch.utils.model_zoo import _download_url_to_file
ImportError: cannot import name '_download_url_to_file'

higherhrnet?

higherhrnet? the last stage featuremap aggregation???it means what??

aggregation it means add? or featuremap concate????

and tagmaps it means???? I dont konw tagmap

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.