Giter VIP home page Giter VIP logo

hrnet / hrnet-object-detection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from open-mmlab/mmdetection

644.0 16.0 97.0 1.05 MB

Object detection with multi-level representations generated from deep high-resolution representation learning (HRNetV2h). This is an official implementation for our TPAMI paper "Deep High-Resolution Representation Learning for Visual Recognition". https://arxiv.org/abs/1908.07919

License: Apache License 2.0

Shell 0.08% Python 86.01% C++ 4.74% Cuda 9.17%
mmdetection object-detection faster-rcnn cascade-rcnn mscoco hrnets

hrnet-object-detection's Introduction

High-resolution networks (HRNets) for object detection

News

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 mmdetection

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.

Note: Pretrained HRNets can be downloaded at HRNets for Image Classification

Note: Models with * are implemented in Official mmdetection.

Faster R-CNN

Backbone #Params GFLOPs lr sched SyncBN MS train mAP model
HRNetV2-W18 26.2M 159.1 1x N N 36.1 OneDrive,BaiduDrive(y4hs)
HRNetV2-W18 26.2M 159.1 1x Y N 37.2 OneDrive,BaiduDrive(ypnu)
HRNetV2-W18 26.2M 159.1 1x Y Y(Default) 37.6 OneDrive,BaiduDrive(ekkm)
HRNetV2-W18 26.2M 159.1 1x Y Y(ResizeCrop) 37.6 OneDrive,BaiduDrive(phgo)
HRNetV2-W18 26.2M 159.1 2x N N 38.1 OneDrive,BaiduDrive(mz9y)
HRNetV2-W18 26.2M 159.1 2x Y Y(Default) 39.4 OneDrive,BaiduDrive(ocuf)
HRNetV2-W18 26.2M 159.1 2x Y Y(ResizeCrop) 39.7
HRNetV2-W32 45.0M 245.3 1x N N 39.5 OneDrive,BaiduDrive(ztwa)
HRNetV2-W32 45.0M 245.3 1x Y Y(Default) 41.0
HRNetV2-W32 45.0M 245.3 2x N N 40.8 OneDrive,BaiduDrive(hmdo)
HRNetV2-W32 45.0M 245.3 2x Y Y(Default) 42.6 OneDrive,BaiduDrive(k03x)
HRNetV2-W40 60.5M 314.9 1x N N 40.4 OneDrive,BaiduDrive(0qda)
HRNetV2-W40 60.5M 314.9 2x N N 41.4 OneDrive,BaiduDrive(xny6)
HRNetV2-W48* 79.4M 399.1 1x N N 40.9 model
HRNetV2-W48* 79.4M 399.1 1x N N 41.5 model

Mask R-CNN

Backbone lr sched Mask mAP Box mAP model
HRNetV2-W18 1x 34.2 37.3 OneDrive,BaiduDrive(vvc1)
HRNetV2-W18 2x 35.7 39.2 OneDrive,BaiduDrive(x2m7)
HRNetV2-W32 1x 36.8 40.7 OneDrive,BaiduDrive(j2ir)
HRNetV2-W32 2x 37.6 42.1 OneDrive,BaiduDrive(tzkz)
HRNetV2-W48* 1x 42.4 38.1 model
HRNetV2-W48* 2x 42.9 38.3 model

Cascade R-CNN

Note: we follow the original paper[2] and adopt 280k training iterations which is equal to 20 epochs in mmdetection.

Backbone lr sched mAP model
HRNetV2-W18* 20e 41.2 model
HRNetV2-W32 20e 43.7 OneDrive,BaiduDrive(ydd7)
HRNetV2-W48* 20e 44.6 model

Cascade Mask R-CNN

Backbone lr sched Mask mAP Box mAP model
HRNetV2-W18* 20e 36.4 41.9 model
HRNetV2-W32* 20e 38.5 44.5 model
HRNetV2-W48* 20e 39.5 46.0 model

Hybrid Task Cascade

Backbone lr sched Mask mAP Box mAP model
HRNetV2-W18* 20e 37.9 43.1 model
HRNetV2-W32* 20e 39.6 45.3 model
HRNetV2-W48* 20e 40.7 46.8 model
HRNetV2-W48* 28e 41.0 47.0 model

FCOS

Backbone GN MS train Lr schd Box mAP model
HRNetV2p-W18* Y N 1x 35.2 model
HRNetV2p-W18* Y N 2x 38.2 model
HRNetV2p-W32* Y N 1x 37.7 model
HRNetV2p-W32* Y N 2x 40.3 model
HRNetV2p-W18* Y Y 2x 38.1 model
HRNetV2p-W32* Y Y 2x 41.4 model
HRNetV2p-W48* Y Y 2x 42.9 model

Techniques about multi-scale training

Default

  • Procedure

    1. Select one scale from provided scales randomly and apply it.
    2. Pad all images in a GPU Batch(e.g. 2 images per GPU) to the same size (see pad_size, 1600*1000 or 1000*1600)
  • Code

You need to change lines below in config files

data = dict(
    imgs_per_gpu=4,
    workers_per_gpu=8,
    pad_size=(1600, 1024),
    train=dict(
        type=dataset_type,
        ann_file=data_root + 'annotations/instances_train2017.json',
        img_prefix=data_root + 'images/train2017.zip',
        img_scale=[(1600, 1000), (1000, 600), (1333, 800)],
        img_norm_cfg=img_norm_cfg,
        size_divisor=32,
        flip_ratio=0.5,
        with_mask=False,
        with_crowd=True,
        with_label=True),

ResizeCrop

Less memory and less time, this implementation is more efficient compared to the former one

  • Procedure

    1. Select one scale from provided scales randomly and apply it.
    2. Crop images to a fixed size randomly if they are larger than the given size.
    3. Pad all images to the same size (see pad_size).
  • Code

You need to change lines below in config files

    imgs_per_gpu=2,
    workers_per_gpu=4,
    pad_size=(1216, 800),
    train=dict(
        type=dataset_type,
        ann_file=data_root + 'annotations/instances_train2017.json',
        img_prefix=data_root + 'train2017.zip',
        img_scale=(1200, 800),
        img_norm_cfg=img_norm_cfg,
        size_divisor=1,
        extra_aug=dict(
            rand_resize_crop=dict(
                scales=[[1400, 600], [1400, 800], [1400, 1000]],
                size=[1200, 800]
            )),
        flip_ratio=0.5,
        with_mask=False,
        with_crowd=True,
        with_label=True),

Quick start

Environment

This code is developed using on Python 3.6 and PyTorch 1.0.0 on Ubuntu 16.04 with NVIDIA GPUs. Training and testing are performed using 4 NVIDIA P100 GPUs with CUDA 9.0 and cuDNN 7.0. Other platforms or GPUs are not fully tested.

Install

  1. Install PyTorch 1.0 following the official instructions
  2. Install mmcv
pip install mmcv
  1. Install pycocotools
git clone https://github.com/cocodataset/cocoapi.git \
 && cd cocoapi/PythonAPI \
 && python setup.py build_ext install \
 && cd ../../
  1. Install NVIDIA/apex to enable SyncBN
git clone https://github.com/NVIDIA/apex
cd apex
python setup install --cuda_ext
  1. Install HRNet-Object-Detection
git clone https://github.com/HRNet/HRNet-Object-Detection.git

cd HRNet-Object-Detection
# compile CUDA extensions.
chmod +x compile.sh
./compile.sh

# run setup
python setup.py install 

# or install locally
python setup.py install --user

For more details, see INSTALL.md

HRNetV2 pretrained models

cd HRNet-Object-Detection
# Download pretrained models into this folder
mkdir hrnetv2_pretrained

Datasets

Please download the COCO dataset from cocodataset. If you use zip format, please specify CocoZipDataset in config files or CocoDataset if you unzip the downloaded dataset.

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 <GPUS NUM> tools/train.py <CONFIG-FILE> --launcher pytorch
# example:
python -m torch.distributed.launch --nproc_per_node 4 tools/train.py configs/hrnet/faster_rcnn_hrnetv2p_w18_1x.py --launcher pytorch

Test

python tools/test.py <CONFIG-FILE> <MODEL WEIGHT> --gpus <GPUS NUM> --eval bbox --out result.pkl
# example:
python tools/test.py configs/hrnet/faster_rcnn_hrnetv2p_w18_1x.py work_dirs/faster_rcnn_hrnetv2p_w18_1x/model_final.pth --gpus 4 --eval bbox --out result.pkl

NOTE: If you meet some problems, you may find a solution in issues of official mmdetection repo 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

Acknowledgement

Thanks @open-mmlab for providing the easily-used code and kind help!

hrnet-object-detection's People

Contributors

donnyyou avatar hellock avatar lindahua avatar luodian avatar myownskyw7 avatar oceanpang avatar patrick-llgc avatar thangvubk avatar tjsongzw avatar welleast avatar wondervictor avatar xfguo-ucas avatar ychfan avatar yhcao6 avatar youkaichao avatar zehaos avatar zhihuagao 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hrnet-object-detection's Issues

RuntimeError: storage has wrong size:

Under windows system, my torch version 1.6, cuda version 10.1, the load is heavy "torch.load("./faster_rcnn_hrnetv2p_w18_mstrain_syncbn_2x.pth", map_location=torch.device("cuda:0"))"
Is a failure:
RuntimeError: storage has wrong size: expected 0 got 144

the first iteration, acc: 94.7188, is it normal?

2019-07-08 19:39:57,836 - INFO - Epoch [1][50/39274] lr: 0.00040, eta: 2 days, 23:25:49, time: 1.091, data_time: 0.013, memory: 4931, loss_rpn_cls: 0.6880, loss_rpn_reg: 0.0123, loss_cls: 3.2936, acc: 94.7188, loss_reg: 0.0006, loss: 3.9945
2019-07-08 19:40:50,242 - INFO - Epoch [1][100/39274] lr: 0.00047, eta: 2 days, 22:01:12, time: 1.049, data_time: 0.005, memory: 4931, loss_rpn_cls: 0.6152, loss_rpn_reg: 0.0125, loss_cls: 1.0380, acc: 99.7266, loss_reg: 0.0000, loss: 1.6657
2019-07-08 19:41:42,772 - INFO - Epoch [1][150/39274] lr: 0.00053, eta: 2 days, 21:34:41, time: 1.051, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.2101, loss_rpn_reg: 0.0120, loss_cls: 0.1034, acc: 99.7227, loss_reg: 0.0000, loss: 0.3256
2019-07-08 19:42:35,451 - INFO - Epoch [1][200/39274] lr: 0.00060, eta: 2 days, 21:23:54, time: 1.054, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.1267, loss_rpn_reg: 0.0133, loss_cls: 0.0715, acc: 99.7305, loss_reg: 0.0001, loss: 0.2116
2019-07-08 19:43:28,060 - INFO - Epoch [1][250/39274] lr: 0.00067, eta: 2 days, 21:16:00, time: 1.052, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.0997, loss_rpn_reg: 0.0096, loss_cls: 0.0475, acc: 99.7344, loss_reg: 0.0000, loss: 0.1568
2019-07-08 19:44:20,587 - INFO - Epoch [1][300/39274] lr: 0.00073, eta: 2 days, 21:09:22, time: 1.051, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.1093, loss_rpn_reg: 0.0097, loss_cls: 0.0364, acc: 99.7188, loss_reg: 0.0000, loss: 0.1554
2019-07-08 19:45:13,128 - INFO - Epoch [1][350/39274] lr: 0.00080, eta: 2 days, 21:04:31, time: 1.051, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.1045, loss_rpn_reg: 0.0087, loss_cls: 0.0325, acc: 99.7031, loss_reg: 0.0000, loss: 0.1456
2019-07-08 19:46:05,796 - INFO - Epoch [1][400/39274] lr: 0.00087, eta: 2 days, 21:01:55, time: 1.053, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.1136, loss_rpn_reg: 0.0069, loss_cls: 0.0339, acc: 99.6758, loss_reg: 0.0004, loss: 0.1547
2019-07-08 19:46:58,322 - INFO - Epoch [1][450/39274] lr: 0.00093, eta: 2 days, 20:58:28, time: 1.051, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.1078, loss_rpn_reg: 0.0074, loss_cls: 0.0314, acc: 99.7031, loss_reg: 0.0000, loss: 0.1465
2019-07-08 19:47:50,988 - INFO - Epoch [1][500/39274] lr: 0.00100, eta: 2 days, 20:56:38, time: 1.053, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.0997, loss_rpn_reg: 0.0073, loss_cls: 0.0296, acc: 99.7188, loss_reg: 0.0000, loss: 0.1366
2019-07-08 19:48:43,311 - INFO - Epoch [1][550/39274] lr: 0.00100, eta: 2 days, 20:52:31, time: 1.046, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.1149, loss_rpn_reg: 0.0110, loss_cls: 0.0291, acc: 99.7148, loss_reg: 0.0000, loss: 0.1551
2019-07-08 19:49:35,827 - INFO - Epoch [1][600/39274] lr: 0.00100, eta: 2 days, 20:50:12, time: 1.050, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.1092, loss_rpn_reg: 0.0094, loss_cls: 0.0275, acc: 99.7305, loss_reg: 0.0000, loss: 0.1461
2019-07-08 19:50:28,301 - INFO - Epoch [1][650/39274] lr: 0.00100, eta: 2 days, 20:47:52, time: 1.049, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.0997, loss_rpn_reg: 0.0084, loss_cls: 0.0271, acc: 99.7188, loss_reg: 0.0000, loss: 0.1353
2019-07-08 19:51:20,748 - INFO - Epoch [1][700/39274] lr: 0.00100, eta: 2 days, 20:45:35, time: 1.049, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.1172, loss_rpn_reg: 0.0104, loss_cls: 0.0309, acc: 99.6719, loss_reg: 0.0000, loss: 0.1585
2019-07-08 19:52:13,283 - INFO - Epoch [1][750/39274] lr: 0.00100, eta: 2 days, 20:43:57, time: 1.051, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.1072, loss_rpn_reg: 0.0108, loss_cls: 0.0262, acc: 99.7227, loss_reg: 0.0005, loss: 0.1447
2019-07-08 19:53:05,903 - INFO - Epoch [1][800/39274] lr: 0.00100, eta: 2 days, 20:42:49, time: 1.052, data_time: 0.008, memory: 4931, loss_rpn_cls: 0.0828, loss_rpn_reg: 0.0061, loss_cls: 0.0236, acc: 99.7383, loss_reg: 0.0000, loss: 0.1125
2019-07-08 19:53:58,468 - INFO - Epoch [1][850/39274] lr: 0.00100, eta: 2 days, 20:41:28, time: 1.051, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.0966, loss_rpn_reg: 0.0070, loss_cls: 0.0248, acc: 99.7266, loss_reg: 0.0000, loss: 0.1284
2019-07-08 19:54:51,062 - INFO - Epoch [1][900/39274] lr: 0.00100, eta: 2 days, 20:40:18, time: 1.052, data_time: 0.005, memory: 4931, loss_rpn_cls: 0.0997, loss_rpn_reg: 0.0058, loss_cls: 0.0253, acc: 99.7227, loss_reg: 0.0001, loss: 0.1309
2019-07-08 19:55:43,428 - INFO - Epoch [1][950/39274] lr: 0.00100, eta: 2 days, 20:38:13, time: 1.047, data_time: 0.004, memory: 4931, loss_rpn_cls: 0.0916, loss_rpn_reg: 0.0074, loss_cls: 0.0267, acc: 99.6992, loss_reg: 0.0000, loss: 0.1257

The Issue about Distributed Training

Hello!
I have a question about the Distributed Training.
What is the role of this parameter ‘coalesce’ ?
The Code is listed below:

def allreduce_grads(model, coalesce=True, bucket_size_mb=-1):
grads = [
param.grad.data for param in model.parameters()
if param.requires_grad and param.grad is not None
]
world_size = dist.get_world_size()
if coalesce:
allreduce_coalesced(grads, world_size, bucket_size_mb)
else:
for tensor in grads:
dist.all_reduce(tensor.div
(world_size))

If anybody answers, I'm grateful.

Questions on training on my own dataset

I tried to use it to train on my own VOC dataset, which has 10 classes. I modified the config files and the voc.py. However, the results was very bad. The loss decreased but stopped at around 0.5. And also, I can not use your pre-train model because the class number is different.

How could I modify the per-train model ? If it's no able to do that, did I do something wrong when use the hrnet on my own dataset? I did the followings:

  1. made the config file suitable for the VOC format dataset (as in pascal_voc)
    2)changed the class number in config file
    3)changed the classes' name in voc.py

thank you for reading my question. I'm new in CV and please forgive me if the quetion is stupid

many bugs

actually there are many bugs and there is no code for predicting as far as I see...

Question about SyncBN of Mutil-GPU

Hello!
Did you use syncBN during training this HRNet?
I find that the mmdetection had not achieved the function of syncBN in the version you are using.

training suddenly get slower and slower

Hi, I have met a problem when I tried to train on 2 RTX 8000 GPU card. The first epoch is normal and it prints the log about every 1 minutes. But when it comes to the 2 or 3 epoch, the time becomes 4~5 minutes and the extra presented training time is getting longer. I killed it and then train with 'resume'. It's normal again but after 1 epoch and some iterations, it again gets slower and slower. I'm confused and grateful to get some help !

CUDA out of memory

The size of image of mmdetection is (1333, 800), but my own data is (2048, 1080). what can I do and the action will not hve bad effects?

Upsample: differences in paper from implementation

In the _make_fuse_layers, the upsampling is done after the 1x1 convolution. However, in the paper the upsampling is done before.

If x > r, f_{xr}(R) upsamples the input representation R through the bilinear upsampling followed by a 1 × 1 convolution for aligning the number of channels.

Moreover, the paper is using bilinear upsampling while the implementation uses with mode='nearest'.

Is there any reasons for these two differences ?

shape problem

when I use your hrnet, it caused a problem about shape mismatch
I found that it is because upsample mismatch with convolution_stride2,
in others words, convolution_stride2 is not absolutely 2 size downsample

so the fuse layer got shape mismatch.
how to solve it

RuntimeError: The expanded size of the tensor (0) must match the existing size (4) at non-singleton dimension 0. Target sizes: [0]. Tensor sizes: [4]

Excuse me, I have met this error when I try to train my own data, but I don't know how to solve this error, help,help!!!Thanks!!!

"See the documentation of nn.Upsample for details.".format(mode))
Traceback (most recent call last):
File "/home/cartur/HRNet-Object-Detection-master/tools/train.py", line 97, in
main()
File "/home/cartur/HRNet-Object-Detection-master/tools/train.py", line 93, in main
logger=logger)
File "/home/cartur/HRNet-Object-Detection-master/mmdet/apis/train.py", line 59, in train_detector
_non_dist_train(model, dataset, cfg, validate=validate)
File "/home/cartur/HRNet-Object-Detection-master/mmdet/apis/train.py", line 127, in _non_dist_train
runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
File "/home/cartur/.conda/envs/CornerNet_Lite/lib/python3.7/site-packages/mmcv-0.2.13-py3.7-linux-x86_64.egg/mmcv/runner/runner.py", line 358, in run
epoch_runner(data_loaders[i], **kwargs)
File "/home/cartur/.conda/envs/CornerNet_Lite/lib/python3.7/site-packages/mmcv-0.2.13-py3.7-linux-x86_64.egg/mmcv/runner/runner.py", line 264, in train
self.model, data_batch, train_mode=True, **kwargs)
File "/home/cartur/HRNet-Object-Detection-master/mmdet/apis/train.py", line 37, in batch_processor
losses = model(**data)
File "/home/cartur/.conda/envs/CornerNet_Lite/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "/home/cartur/.conda/envs/CornerNet_Lite/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 141, in forward
return self.module(*inputs[0], **kwargs[0])
File "/home/cartur/.conda/envs/CornerNet_Lite/lib/python3.7/site-packages/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "/home/cartur/HRNet-Object-Detection-master/mmdet/models/detectors/base.py", line 80, in forward
return self.forward_train(img, img_meta, **kwargs)
File "/home/cartur/HRNet-Object-Detection-master/mmdet/models/detectors/two_stage.py", line 136, in forward_train
sampling_results, gt_bboxes, gt_labels, self.train_cfg.rcnn)
File "/home/cartur/HRNet-Object-Detection-master/mmdet/models/bbox_heads/bbox_head.py", line 80, in get_target
target_stds=self.target_stds)
File "/home/cartur/HRNet-Object-Detection-master/mmdet/core/bbox/bbox_target.py", line 25, in bbox_target
target_stds=target_stds)
File "/home/cartur/HRNet-Object-Detection-master/mmdet/core/utils/misc.py", line 24, in multi_apply
return tuple(map(list, zip(*map_results)))
File "/home/cartur/HRNet-Object-Detection-master/mmdet/core/bbox/bbox_target.py", line 62, in bbox_target_single
labels, reg_classes)
File "/home/cartur/HRNet-Object-Detection-master/mmdet/core/bbox/bbox_target.py", line 74, in expand_target
bbox_targets_expand[i, start:end] = bbox_targets[i, :]
RuntimeError: The expanded size of the tensor (0) must match the existing size (4) at non-singleton dimension 0. Target sizes: [0]. Tensor sizes: [4]

Process finished with exit code 1

zipfile.BadZipFile: File is not a zip file

File "/home/li.ye/anaconda3/lib/python3.6/site-packages/mmdet-0.6rc0+unknown-py3.6.egg/mmdet/datasets/zip_dataset.py", line 305, in prepare_test_img img = load_img(img_info['filename'], self.img_prefix) File "/home/li.ye/anaconda3/lib/python3.6/site-packages/mmdet-0.6rc0+unknown-py3.6.egg/mmdet/datasets/zip_dataset.py", line 56, in load_img with zipfile.ZipFile(zipfilename, 'r') as f: File "/home/li.ye/anaconda3/lib/python3.6/zipfile.py", line 1108, in __init__ self._RealGetContents() File "/home/li.ye/anaconda3/lib/python3.6/zipfile.py", line 1175, in _RealGetContents raise BadZipFile("File is not a zip file") zipfile.BadZipFile: File is not a zip file
When I tried to use pretrained model to test, I met ZIP ERROR, but I made the COCOZIP dataset well, how can I fix it? Thanks!
@leoxiaobin @sunke123 @bearcatt

Inconsistent with paper presentation

很棒!但是在看了源码以后, 发现好像代码和文章配图的网络结构不符?我画了一个简图,在生成一个分辨率更低的branch的时候只使用了上一个stage分辨率最接近的feature maps?
HRNet

期待您的回复

train error

When I use the coco2017 datasets to train this net, I get a problem "json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 4521979 (char 4521978)". How can I solve it?

some problem about torch

When I comile the ./compile.sh, I meet with those problems. My torch version is 0.4.1, CUDA is 9.0, and CUDNN is 7.0. And I don;t know how to solve it. Those four similar problems.
src/roi_align_cuda.cpp:1:29: fatal error: torch/extension.h: No such file or directory
..
..
src/deform_conv_cuda.cpp:4:29: fatal error: torch/extension.h: No such file or directory

train error

When i complete the installation ,i meet with those problems. my environment is CUDA10.0 Pytorch 1.2.0
ImportError: cannot import name 'functional'
subprocess.CalledProcessError: Command [python -m torch.distributed.launch --nproc_per_node 4 tools/train.py configs/hrnet/faster_rcnn_hrnetv2p_w18_1x.py --launcher pytorch ]'returned non-zero exit status 1.
I don't know why i would see this error

A issues about cuda

my cuda's version is 10.0, does this project suit for cuda10.0. Or it must use cuda9.0 and torch 1.0

Question on Upsample

Hi, thanks for the great work. I do have a question on the upsample method. In the paper on mult-scale feature fusion, the upsample is "bilinear" followed by the 1x1 conv, but in the implementation I saw the Upsample kwarg is "nearest". Do I miss or miss-understand anything here? Btw, will it influence the feature representation much (based on your intuition or experiments).

KeyError: 'HRNet is not in the backbone registry'

I meet an error and I don't know how to solve it, could you help me?
2019-09-25 08:15:32,758 - INFO - Distributed training: True
Traceback (most recent call last):
File "tools/train.py", line 95, in
main()
File "tools/train.py", line 82, in main
cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg)
File "/home/cartur/.local/lib/python3.7/site-packages/mmdet-0.6rc0+unknown-py3.7.egg/mmdet/models/builder.py", line 51, in build_detector
return build(cfg, DETECTORS, dict(train_cfg=train_cfg, test_cfg=test_cfg))
File "/home/cartur/.local/lib/python3.7/site-packages/mmdet-0.6rc0+unknown-py3.7.egg/mmdet/models/builder.py", line 31, in build
return _build_module(cfg, registry, default_args)
File "/home/cartur/.local/lib/python3.7/site-packages/mmdet-0.6rc0+unknown-py3.7.egg/mmdet/models/builder.py", line 23, in _build_module
return obj_type(**args)
File "/home/cartur/.local/lib/python3.7/site-packages/mmdet-0.6rc0+unknown-py3.7.egg/mmdet/models/detectors/faster_rcnn.py", line 25, in init
pretrained=pretrained)
File "/home/cartur/.local/lib/python3.7/site-packages/mmdet-0.6rc0+unknown-py3.7.egg/mmdet/models/detectors/two_stage.py", line 27, in init
self.backbone = builder.build_backbone(backbone)
File "/home/cartur/.local/lib/python3.7/site-packages/mmdet-0.6rc0+unknown-py3.7.egg/mmdet/models/builder.py", line 35, in build_backbone
return build(cfg, BACKBONES)
File "/home/cartur/.local/lib/python3.7/site-packages/mmdet-0.6rc0+unknown-py3.7.egg/mmdet/models/builder.py", line 31, in build
return _build_module(cfg, registry, default_args)
File "/home/cartur/.local/lib/python3.7/site-packages/mmdet-0.6rc0+unknown-py3.7.egg/mmdet/models/builder.py", line 15, in _build_module
obj_type, registry.name))
KeyError: 'HRNet is not in the backbone registry'

About imput images

Hi, in configs of this repo, the to_rgb is set to False but in mmdetection, the to_rgb is set to True. I wonder which is right?

WARNING - The model and loaded state dict do not match exactly,

When I am training my own dataset, it doesn't occur any error, but it can't run successfully, can you help me? Thanks very much!!!!
python -m torch.distributed.launch --nproc_per_node 2 to
ols/train.py configs/hrnet/potsdam.py --launcher pytorch
2019-09-29 14:00:51,640 - INFO - Distributed training: True
2019-09-29 14:00:52,039 - INFO - load model from: hrnetv2_pretrained/hrnetv2_w18.pth
2019-09-29 14:00:52,171 - WARNING - The model and loaded state dict do not match exactly

unexpected key in source state_dict: incre_modules.0.0.conv1.weight, incre_modules.0.0.bn1.weight, incre_modules.0.0.bn1.bias, incre_modules.0.0.bn1.running_mean, incre_modules.0.0.bn1.running_var, incre_modules.0.0.bn1.num_batches_tracked, incre_modules.0.0.conv2.weight, incre_modules.0.0.bn2.weight, incre_modules.0.0.bn2.bias, incre_modules.0.0.bn2.running_mean, incre_modules.0.0.bn2.running_var, incre_modules.0.0.bn2.num_batches_tracked, incre_modules.0.0.conv3.weight, incre_modules.0.0.bn3.weight, incre_modules.0.0.bn3.bias, incre_modules.0.0.bn3.running_mean, incre_modules.0.0.bn3.running_var, incre_modules.0.0.bn3.num_batches_tracked, incre_modules.0.0.downsample.0.weight, incre_modules.0.0.downsample.1.weight, incre_modules.0.0.downsample.1.bias, incre_modules.0.0.downsample.1.running_mean, incre_modules.0.0.downsample.1.running_var, incre_modules.0.0.downsample.1.num_batches_tracked, incre_modules.1.0.conv1.weight, incre_modules.1.0.bn1.weight, incre_modules.1.0.bn1.bias, incre_modules.1.0.bn1.running_mean, incre_modules.1.0.bn1.running_var, incre_modules.1.0.bn1.num_batches_tracked, incre_modules.1.0.conv2.weight, incre_modules.1.0.bn2.weight, incre_modules.1.0.bn2.bias, incre_modules.1.0.bn2.running_mean, incre_modules.1.0.bn2.running_var, incre_modules.1.0.bn2.num_batches_tracked, incre_modules.1.0.conv3.weight, incre_modules.1.0.bn3.weight, incre_modules.1.0.bn3.bias, incre_modules.1.0.bn3.running_mean, incre_modules.1.0.bn3.running_var, incre_modules.1.0.bn3.num_batches_tracked, incre_modules.1.0.downsample.0.weight, incre_modules.1.0.downsample.1.weight, incre_modules.1.0.downsample.1.bias, incre_modules.1.0.downsample.1.running_mean, incre_modules.1.0.downsample.1.running_var, incre_modules.1.0.downsample.1.num_batches_tracked, incre_modules.2.0.conv1.weight, incre_modules.2.0.bn1.weight, incre_modules.2.0.bn1.bias, incre_modules.2.0.bn1.running_mean, incre_modules.2.0.bn1.running_var, incre_modules.2.0.bn1.num_batches_tracked, incre_modules.2.0.conv2.weight, incre_modules.2.0.bn2.weight, incre_modules.2.0.bn2.bias, incre_modules.2.0.bn2.running_mean, incre_modules.2.0.bn2.running_var, incre_modules.2.0.bn2.num_batches_tracked, incre_modules.2.0.conv3.weight, incre_modules.2.0.bn3.weight, incre_modules.2.0.bn3.bias, incre_modules.2.0.bn3.running_mean, incre_modules.2.0.bn3.running_var, incre_modules.2.0.bn3.num_batches_tracked, incre_modules.2.0.downsample.0.weight, incre_modules.2.0.downsample.1.weight, incre_modules.2.0.downsample.1.bias, incre_modules.2.0.downsample.1.running_mean, incre_modules.2.0.downsample.1.running_var, incre_modules.2.0.downsample.1.num_batches_tracked, incre_modules.3.0.conv1.weight, incre_modules.3.0.bn1.weight, incre_modules.3.0.bn1.bias, incre_modules.3.0.bn1.running_mean, incre_modules.3.0.bn1.running_var, incre_modules.3.0.bn1.num_batches_tracked, incre_modules.3.0.conv2.weight, incre_modules.3.0.bn2.weight, incre_modules.3.0.bn2.bias, incre_modules.3.0.bn2.running_mean, incre_modules.3.0.bn2.running_var, incre_modules.3.0.bn2.num_batches_tracked, incre_modules.3.0.conv3.weight, incre_modules.3.0.bn3.weight, incre_modules.3.0.bn3.bias, incre_modules.3.0.bn3.running_mean, incre_modules.3.0.bn3.running_var, incre_modules.3.0.bn3.num_batches_tracked, incre_modules.3.0.downsample.0.weight, incre_modules.3.0.downsample.1.weight, incre_modules.3.0.downsample.1.bias, incre_modules.3.0.downsample.1.running_mean, incre_modules.3.0.downsample.1.running_var, incre_modules.3.0.downsample.1.num_batches_tracked, downsamp_modules.0.0.weight, downsamp_modules.0.0.bias, downsamp_modules.0.1.weight, downsamp_modules.0.1.bias, downsamp_modules.0.1.running_mean, downsamp_modules.0.1.running_var, downsamp_modules.0.1.num_batches_tracked, downsamp_modules.1.0.weight, downsamp_modules.1.0.bias, downsamp_modules.1.1.weight, downsamp_modules.1.1.bias, downsamp_modules.1.1.running_mean, downsamp_modules.1.1.running_var, downsamp_modules.1.1.num_batches_tracked, downsamp_modules.2.0.weight, downsamp_modules.2.0.bias, downsamp_modules.2.1.weight, downsamp_modules.2.1.bias, downsamp_modules.2.1.running_mean, downsamp_modules.2.1.running_var, downsamp_modules.2.1.num_batches_tracked, final_layer.0.weight, final_layer.0.bias, final_layer.1.weight, final_layer.1.bias, final_layer.1.running_mean, final_layer.1.running_var, final_layer.1.num_batches_tracked, classifier.weight, classifier.bias

loading annotations into memory...
Done (t=0.01s)
creating index...
index created!
loading annotations into memory...
Done (t=0.02s)
creating index...
index created!
loading annotations into memory...
loading annotations into memory...
Done (t=0.01s)
creating index...
Done (t=0.01s)
index created!creating index...

index created!
2019-09-29 14:00:57,339 - INFO - Start running, host: eagle2019@yang-Precision-Tower-7910, work_dir: /server_space/liuyj/apex/HRNet-Object-Detection/work_dirs/faster_rcnn_hrnetv2p_w18_1x
2019-09-29 14:00:57,339 - INFO - workflow: [('train', 1)], max: 12 epochs
/home/eagle2019/.conda/envs/HRNet_object_detec/lib/python3.7/site-packages/torch/nn/modules/upsampling.py:129: UserWarning: nn.Upsample is deprecated. Use nn.functional.interpolate instead.
warnings.warn("nn.{} is deprecated. Use nn.functional.interpolate instead.".format(self.name))
/home/eagle2019/.conda/envs/HRNet_object_detec/lib/python3.7/site-packages/torch/nn/modules/upsampling.py:129: UserWarning: nn.Upsample is deprecated. Use nn.functional.interpolate instead.
warnings.warn("nn.{} is deprecated. Use nn.functional.interpolate instead.".format(self.name))
/home/eagle2019/.conda/envs/HRNet_object_detec/lib/python3.7/site-packages/torch/nn/functional.py:2423: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
"See the documentation of nn.Upsample for details.".format(mode))
/home/eagle2019/.conda/envs/HRNet_object_detec/lib/python3.7/site-packages/torch/nn/functional.py:2423: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
"See the documentation of nn.Upsample for details.".format(mode))

Multi-GPU training error

When I use multi-gpu training(num_gpus>=2), error is "RuntimeError: all tensors must be on devices[0] ". Please help me if you guys can fix it!

Traceback (most recent call last):
File "tools/train.py", line 98, in
Traceback (most recent call last):
File "tools/train.py", line 98, in
main()
File "tools/train.py", line 94, in main
logger=logger)
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/mmdet-0.6rc0+3493751-py3.6.egg/mmdet/apis/train.py", line 57, in train_detector
_dist_train(model, dataset, cfg, validate=validate)
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/mmdet-0.6rc0+3493751-py3.6.egg/mmdet/apis/train.py", line 78, in _dist_train
main()
File "tools/train.py", line 94, in main
model = MMDistributedDataParallel(model.cuda())
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/torch/nn/parallel/distributed.py", line 217, in init
logger=logger)
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/mmdet-0.6rc0+3493751-py3.6.egg/mmdet/apis/train.py", line 57, in train_detector
_dist_train(model, dataset, cfg, validate=validate)
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/mmdet-0.6rc0+3493751-py3.6.egg/mmdet/apis/train.py", line 78, in _dist_train
self._ddp_init_helper()
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/torch/nn/parallel/distributed.py", line 232, in _ddp_init_helper
model = MMDistributedDataParallel(model.cuda())
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/torch/nn/parallel/distributed.py", line 217, in init
self._module_copies = replicate(self.module, self.device_ids, detach=True)
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/torch/nn/parallel/replicate.py", line 13, in replicate
param_copies = Broadcast.apply(devices, *params)
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/torch/nn/parallel/_functions.py", line 21, in forward
self._ddp_init_helper()
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/torch/nn/parallel/distributed.py", line 232, in _ddp_init_helper
outputs = comm.broadcast_coalesced(inputs, ctx.target_gpus)
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/torch/cuda/comm.py", line 40, in broadcast_coalesced
self._module_copies = replicate(self.module, self.device_ids, detach=True)
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/torch/nn/parallel/replicate.py", line 13, in replicate
return torch._C._broadcast_coalesced(tensors, devices, buffer_size)
RuntimeError: all tensors must be on devices[0]
param_copies = Broadcast.apply(devices, *params)
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/torch/nn/parallel/_functions.py", line 21, in forward
outputs = comm.broadcast_coalesced(inputs, ctx.target_gpus)
File "/home/by/APP/anaconda2/envs/hrnet-det/lib/python3.6/site-packages/torch/cuda/comm.py", line 40, in broadcast_coalesced
return torch._C._broadcast_coalesced(tensors, devices, buffer_size)
RuntimeError: all tensors must be on devices[0]

When I follow your instruction to run the train.py, the problem happened.Can you give me some advice to resolve it?

Traceback (most recent call last):
File "tools/train.py", line 95, in
main()
File "tools/train.py", line 47, in main
cfg = Config.fromfile(args.config)
File "/root/virtualenv/anaconda3/lib/python3.6/site-packages/mmcv/utils/config.py", line 152, in fromfile
cfg_dict, cfg_text = Config._file2dict(filename)
File "/root/virtualenv/anaconda3/lib/python3.6/site-packages/mmcv/utils/config.py", line 91, in _file2dict
mod = import_module('_tempconfig')
File "/root/virtualenv/anaconda3/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 665, in _load_unlocked
File "", line 674, in exec_module
File "", line 781, in get_code
File "", line 741, in source_to_code
File "", line 219, in _call_with_frames_removed
File "/tmp/tmpfnqvr765/_tempconfig.py", line 6
backbone=dict(
^
SyntaxError: invalid syntax

compile cuda error

Mmdetection has been successfully installed in my environment.
But, an error occurred while running ./compile.sh.
I know the problem of the environment is more metaphysical.
Do you have any Suggestions?
Thank you!

The visualization of bounding box

I've finished the training process.

I ran the test.py to obtain the AP, Precision and other metrics.

I'm wondering how I can visualize the bounding box in the test set.

Are there any .py to achieve it ?

Image size!

I use the config of cascade and hrnet! But it seems that this network occupies too many memories so that the dataset I make (2048, 1080) results in out of memory! If I crop the dataset (1333, 800), that will cause low map! So what should I do now? Please!

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

How to solve the fuse dimension mismatch problem when feature map is from an odd side length one by stride 2 Convs?

@leoxiaobin @sunke123 @bearcatt @wondervictor @bowenc0221 Hi, thanks for your work. I meet a problem when I try implementing HRNet backbone on Faster R-CNN with Detectron2. It's about "_make_fuse_layers(self)". When feature map is from an odd side length one by stride 2 Convs, then we upsample it by "nn.Upsample(scale_factor=2**(j-i), mode='nearest')))" to make fuse, it will cause dimension mismatch problem. This problem can easily occur in object detection tasks due to the wide variety of resolutions. Do you solve this problem by preprocessing which may be detrimental to performance, or something else? And do you have any better solutions? Thank you very much and I am looking forward to your reply.

KeyError: "There is no item named \'000000201722.jpg\' in the archive"\n'

To start the training,
python -m torch.distributed.launch --nproc_per_node 4 tools/train.py configs/hrnet/faster_rcnn_hrnetv2p_w32_syncbn_mstrain_1x.py --launcher pytorch
But i got the error:
`KeyError: 'Traceback (most recent call last):\n File "/home/yyf/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 138, in _worker_loop\n samples = collate_fn([dataset[i] for i in batch_indices])\n File "/home/yyf/anaconda3/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 138, in \n samples = collate_fn([dataset[i] for i in batch_indices])\n File "/home/yyf/anaconda3/envs/pytorch/lib/python3.6/site-packages/mmdet-0.6rc0+8ccdbf2-py3.6.egg/mmdet/datasets/zip_dataset.py", line 209, in getitem\n data = self.prepare_train_img(idx)\n File "/home/yyf/anaconda3/envs/pytorch/lib/python3.6/site-packages/mmdet-0.6rc0+8ccdbf2-py3.6.egg/mmdet/datasets/zip_dataset.py", line 218, in prepare_train_img\n img = load_img(img_info['filename'], self.img_prefix)\n File "/home/yyf/anaconda3/envs/pytorch/lib/python3.6/site-packages/mmdet-0.6rc0+8ccdbf2-py3.6.egg/mmdet/datasets/zip_dataset.py", line 57, in load_img\n data = io.BytesIO(f.read(filename))\n File "/usr/lib/python3.6/zipfile.py", line 1337, in read\n with self.open(name, "r", pwd) as fp:\n File "/usr/lib/python3.6/zipfile.py", line 1375, in open\n zinfo = self.getinfo(name)\n File "/usr/lib/python3.6/zipfile.py", line 1304, in getinfo\n 'There is no item named %r in the archive' % name)\nKeyError: "There is no item named '000000201722.jpg' in the archive"\n'

`

I've re-downloaded the train2017.zip, test2017.zip, val2017.zip and annotations_trainval2017.zip from the official website but it didn't work.

What's the problem???

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.