GithubHelp home page GithubHelp logo

nvlabs / discobox Goto Github PK

View Code? Open in Web Editor NEW
94.0 8.0 9.0 12.21 MB

The Official PyTorch Implementation of DiscoBox.

Home Page: https://arxiv.org/abs/2105.06464

License: Other

Python 99.92% Dockerfile 0.03% Shell 0.05%
weakly-supervised-learning instance-segmentation semantic-correspondence coco object-detection auto-labeling

discobox's Introduction

NVIDIA Source Code License Python 3.8

We quit maintaining this project. Please check our new work, Mask Auto-labeler for more powerful models

DiscoBox: Weakly Supervised Instance Segmentation and Semantic Correspondence from Box Supervision

output

DiscoBox: Weakly Supervised Instance Segmentation and Semantic Correspondence from Box Supervision.
Shiyi Lan, Zhiding Yu, Chris Choy, Subhashree Radhakrishnan, Guilin Liu, Yuke Zhu, Larry Davis, Anima Anandkumar
International Conference on Computer Vision (ICCV) 2021

This repository contains the official Pytorch implementation of training & evaluation code and pretrained models for DiscoBox. DiscoBox is a state of the art framework that can jointly predict high quality instance segmentation and semantic correspondence from box annotations.

We use MMDetection v2.10.0 as the codebase.

All of our models are trained and tested using automatic mixed precision, which leverages float16 for speedup and less GPU memory consumption.

Installation

This implementation is based on PyTorch==1.9.0, mmcv==1.3.13, and mmdetection==2.10.0

Please refer to get_started.md for installation.

Or you can download the docker image from our dockerhub repository.

Models

Results on COCO val 2017

Backbone Weights AP AP@50 AP@75 AP@Small AP@Medium AP@Large
ResNet-50 download 30.7 52.6 30.6 13.3 34.1 45.6
ResNet-101-DCN download 35.3 59.1 35.4 16.9 39.2 53.0
ResNeXt-101-DCN download 37.3 60.4 39.1 17.8 41.1 55.4

Results on COCO test-dev

We also evaluate the models in the section Results on COCO val 2017 with the same weights on COCO test-dev.

Backbone Weights AP AP@50 AP@75 AP@Small AP@Medium AP@Large
ResNet-50 download 32.0 53.6 32.6 11.7 33.7 48.4
ResNet-101-DCN download 35.8 59.8 36.4 16.9 38.7 52.1
ResNeXt-101-DCN download 37.9 61.4 40.0 18.0 41.1 53.9

Training

COCO

ResNet-50 (8 GPUs):

bash tools/dist_train.sh \
     configs/discobox/discobox_solov2_r50_fpn_3x.py 8

ResNet-101-DCN (8 GPUs):

bash tools/dist_train.sh \
     configs/discobox/discobox_solov2_r101_dcn_fpn_3x.py 8

ResNeXt-101-DCN (8 GPUs):

bash tools/dist_train.sh \
     configs/discobox/discobox_solov2_x101_dcn_fpn_3x.py 8

Pascal VOC 2012

ResNet-50 (4 GPUs):

bash tools/dist_train.sh \
     configs/discobox/discobox_solov2_voc_r50_fpn_6x.py 4

ResNet-101 (4 GPUs):

bash tools/dist_train.sh \
     configs/discobox/discobox_solov2_voc_r101_fpn_6x.py 4

Testing

COCO

ResNet-50 (8 GPUs):

bash tools/dist_test.sh \
     configs/discobox/discobox_solov2_r50_fpn_3x.py \
     work_dirs/coco_r50_fpn_3x.pth 8 --eval segm

ResNet-101-DCN (8 GPUs):

bash tools/dist_test.sh \
     configs/discobox/discobox_solov2_r101_dcn_fpn_3x.py \
     work_dirs/coco_r101_dcn_fpn_3x.pth 8 --eval segm

ResNeXt-101-DCN (GPUs):

bash tools/dist_test.sh \
     configs/discobox/discobox_solov2_x101_dcn_fpn_3x_fp16.py \
     work_dirs/coco_x101_dcn_fpn_3x.pth 8 --eval segm

Box-conditioned inference

You can use DiscoBox for autolabeling given images and tight bounding boxes. We call this box-conditioned inference. Here is an example of box-conditioned inference on COCO val2017 with x101_dcn_fpn arch:

bash tools/dist_test.sh \
     config/discobox/boxcond_discobox_solov2_x101_dcn_fpn_3x.py \
     work_dirs/x101_dcn_fpn_coco_3x.pth 8 \
     --format-only \
     --options "jsonfile_prefix=work_dirs/coco_x101_dcn_fpn_results.json"

Pascal VOC 2012 (COCO API)

ResNet-50 (4 GPUs):

bash tools/dist_test.sh \
     configs/discobox/discobox_solov2_voc_r50_fpn_3x_fp16.py \
     work_dirs/voc_r50_6x.pth 4 --eval segm

ResNet-101 (4 GPUs):

bash tools/dist_test.sh \
     configs/discobox/discobox_solov2_voc_r101_fpn_3x_fp16.py \
     work_dirs/voc_r101_6x.pth 4 --eval segm

Pascal VOC 2012 (Matlab)

Step 1: generate results

ResNet-50 (4 GPUs):

bash tools/dist_test.sh \
     configs/discobox/discobox_solov2_voc_r50_fpn_3x_fp16.py \
     work_dirs/voc_r50_6x.pth 4 \
     --format-only \
     --options "jsonfile_prefix=work_dirs/voc_r50_results.json"

ResNet-101 (4 GPUs):

bash tools/dist_test.sh \
     configs/discobox/discobox_solov2_voc_r101_fpn_3x_fp16.py \
     work_dirs/voc_r101_6x.pth 4 \
     --format-only \
     --options "jsonfile_prefix=work_dirs/voc_r101_results.json"

Step 2: format conversion

ResNet-50:

python tools/json2mat.py work_dirs/voc_r50_results.json work_dirs/voc_r50_results.mat

ResNet-101:

python tools/json2mat.py work_dirs/voc_r101_results.json work_dirs/voc_r101_results.mat

Step 3: evaluation

Please visit BBTP for the evaluation code written in Matlab.

PF-Pascal

Please visit this repository.

Visualization

ResNeXt-101

python tools/test.py configs/discobox/discobox_solov2_x101_dcn_fpn_3x.py coco_x101_dcn_fpn_3x.pth --show --show-dir discobox_vis_x101

LICENSE

Please check the LICENSE file. DiscoBox may be used non-commercially, meaning for research or evaluation purposes only. For business inquiries, please contact [email protected].

Citation

@article{lan2021discobox,
  title={DiscoBox: Weakly Supervised Instance Segmentation and Semantic Correspondence from Box Supervision},
  author={Lan, Shiyi and Yu, Zhiding and Choy, Christopher and Radhakrishnan, Subhashree and Liu, Guilin and Zhu, Yuke and Davis, Larry S and Anandkumar, Anima},
  journal={arXiv preprint arXiv:2105.06464},
  year={2021}
}

discobox's People

Contributors

chrisding avatar voidrank 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discobox's Issues

About loss_ts, loss_corr

I did
bash tools/dist_train.sh
configs/discobox/discobox_solov2_r50_fpn_3x.py 2

I got message as below
2022-09-19 00:46:25,659 - mmdet - INFO - Epoch [1][50/29317] lr: 3.425e-04, eta: 35 days, 8:29:59, time: 2.894, data_time: 1.802, memory: 3714, loss_ins: 1.1359, loss_ts: 0.0000, loss_cate: 0.9793, loss_corr: 0.0000, loss: 2.1152, grad_norm: 11.1556
2022-09-19 00:47:05,600 - mmdet - INFO - Epoch [1][100/29317] lr: 5.900e-04, eta: 22 days, 13:17:57, time: 0.799, data_time: 0.058, memory: 3714, loss_ins: 1.1685, loss_ts: 0.0000, loss_cate: 0.8634, loss_corr: 0.0000, loss: 2.0319, grad_norm: 9.6288
2022-09-19 00:47:46,070 - mmdet - INFO - Epoch [1][150/29317] lr: 8.376e-04, eta: 18 days, 7:56:31, time: 0.809, data_time: 0.049, memory: 3714, loss_ins: 1.0841, loss_ts: 0.0000, loss_cate: 0.8087, loss_corr: 0.0000, loss: 1.8928, grad_norm: 9.4327
2022-09-19 00:48:24,677 - mmdet - INFO - Epoch [1][200/29317] lr: 1.085e-03, eta: 16 days, 2:30:51, time: 0.772, data_time: 0.043, memory: 3714, loss_ins: 1.1373, loss_ts: 0.0000, loss_cate: 0.8160, loss_corr: 0.0000, loss: 1.9532, grad_norm: 8.7715

loss_ts, loss_corr are 0.

It seems it is problem, I can not get any loss from loss_ts, loss_corr. What should I do?

one question about IndexError: list index out of range,i want use my coco data ,but show this question,I hope you can help me.

I only modify config about my coco data,

@DATASETS.register_module()
class CocoDataset(CustomDataset):
    CLASSES = ('air-hole', 'bite-edge', 'broken-arc', 'crack', 'hollow-bead', 'overlap',
               'slag-inclusion', 'unfused')
    # CLASSES = ('person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus',
    #            'train', 'truck', 'boat', 'traffic light', 'fire hydrant',
    #            'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog',
    #            'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe',
    #            'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
    #            'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat',
    #            'baseball glove', 'skateboard', 'surfboard', 'tennis racket',
    #            'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl',
    #            'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot',
    #            'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
    #            'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop',
    #            'mouse', 'remote', 'keyboard', 'cell phone', 'microwave',
    #            'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock',
    #            'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush')

question:

Traceback (most recent call last):
  File "tools/train.py", line 191, in <module>
    main()
  File "tools/train.py", line 187, in main
    meta=meta)
  File "/root/DiscoBox/mmdet/apis/train.py", line 172, in train_detector
    runner.run(data_loaders, cfg.workflow)
  File "/root/.local/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 125, in run
    epoch_runner(data_loaders[i], **kwargs)
  File "/root/.local/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 54, in train
    self.call_hook('after_train_epoch')
  File "/root/.local/lib/python3.7/site-packages/mmcv/runner/base_runner.py", line 307, in call_hook
    getattr(hook, fn_name)(self)
  File "/root/DiscoBox/mmdet/core/evaluation/eval_hooks.py", line 279, in after_train_epoch
    key_score = self.evaluate(runner, results)
  File "/root/DiscoBox/mmdet/core/evaluation/eval_hooks.py", line 177, in evaluate
    results, logger=runner.logger, **self.eval_kwargs)
  File "/root/DiscoBox/mmdet/datasets/coco.py", line 497, in evaluate
    cocoEval.evaluate()
  File "/root/.local/lib/python3.7/site-packages/pycocotools/cocoeval.py", line 149, in evaluate
    self._prepare()
  File "/root/.local/lib/python3.7/site-packages/pycocotools/cocoeval.py", line 110, in _prepare
    _toMask(gts, self.cocoGt)
  File "/root/.local/lib/python3.7/site-packages/pycocotools/cocoeval.py", line 95, in _toMask
    rle = coco.annToRLE(ann)
  File "/root/.local/lib/python3.7/site-packages/pycocotools/coco.py", line 497, in annToRLE
    rles = maskUtils.frPyObjects(segm, h, w)
  File "pycocotools/_mask.pyx", line 292, in pycocotools._mask.frPyObjects
IndexError: list index out of range
Traceback (most recent call last):
  File "/root/.local/conda/envs/py37/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/root/.local/conda/envs/py37/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/root/.local/conda/envs/py37/lib/python3.7/site-p

About Box-conditioned inference

I did

bash tools/dist_test.sh
configs/discobox/boxcond_discobox_solov2_x101_dcn_fpn_3x.py
work_dirs/coco_x101_dcn_fpn_3x.pth 2
--format-only
--options "jsonfile_prefix=work_dirs/coco_x101_dcn_fpn_results.json"

I got error as below
Traceback (most recent call last):
File "tools/test.py", line 226, in
main()
File "tools/test.py", line 202, in main
outputs = single_gpu_test(model, data_loader, args.show, args.show_dir,
File "/home/user/workdir/mmdet/apis/test.py", line 30, in single_gpu_test
result = model(return_loss=False, rescale=True, **data)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/mmcv/parallel/data_parallel.py", line 42, in forward
return super().forward(*inputs, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 165, in forward
return self.module(*inputs[0], **kwargs[0])
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/opt/conda/lib/python3.8/site-packages/mmcv/runner/fp16_utils.py", line 128, in new_func
output = old_func(*new_args, **new_kwargs)
File "/home/user/workdir/mmdet/models/detectors/single_stage_wsis.py", line 251, in forward
return self.forward_test(img, img_metas, **kwargs)
File "/home/user/workdir/mmdet/models/detectors/base.py", line 164, in forward_test
return self.simple_test(imgs[0], img_metas[0], **kwargs)
File "/home/user/workdir/mmdet/models/detectors/single_stage_wsis.py", line 262, in simple_test
results = self.bbox_head.get_seg(*seg_inputs, img=img, gt_bboxes=gt_bboxes, gt_labels=gt_labels, gt_masks=gt_masks)
TypeError: get_seg() got an unexpected keyword argument 'gt_bboxes'

How can I solve this error? If I changed
from results = self.bbox_head.get_seg(*seg_inputs, img=img, gt_bboxes=gt_bboxes, gt_labels=gt_labels, gt_masks=gt_masks)
to results = self.bbox_head.get_seg(*seg_inputs, img=img)

Error has disappeared.

ERROR

ImportError: /home/user/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/mmcv/_ext.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZNK3c1010TensorImpl36is_contiguous_nondefault_policy_implENS_12MemoryFormatE

KeyError: 'DiscoBoxSOLOv2 is not in the models registry' running visualization

I am able to run the COCO (ResNeXt-101-DCN) test successfully, but when I try to run your visualization example:

python tools/test.py configs/discobox/discobox_solov2_x101_dcn_fpn_3x.py coco_x101_dcn_fpn_3x.pth --show --show-dir discobox_vis_x101

I get the following errors:

root@mymachine:~/src/github/DiscoBox# python tools/test.py configs/discobox/discobox_solov2_x101_dcn_fpn_3x.py coco_x101_dcn_fpn_3x.pth --show --show-dir discobox_vis_x101
/root/src/github/mmdetection/mmdet/datasets/api_wrappers/coco_api.py:20: UserWarning: mmpycocotools is deprecated. Please install official pycocotools by "pip install pycocotools"
  warnings.warn(
loading annotations into memory...
Done (t=0.51s)
creating index...
index created!
Traceback (most recent call last):
  File "tools/test.py", line 222, in <module>
    main()
  File "tools/test.py", line 175, in main
    model = build_detector(cfg.model, test_cfg=cfg.get('test_cfg'))
  File "/root/src/github/mmdetection/mmdet/models/builder.py", line 58, in build_detector
    return DETECTORS.build(
  File "/opt/conda/lib/python3.8/site-packages/mmcv/utils/registry.py", line 212, in build
    return self.build_func(*args, **kwargs, registry=self)
  File "/opt/conda/lib/python3.8/site-packages/mmcv/cnn/builder.py", line 27, in build_model_from_cfg
    return build_from_cfg(cfg, registry, default_args)
  File "/opt/conda/lib/python3.8/site-packages/mmcv/utils/registry.py", line 44, in build_from_cfg
    raise KeyError(
KeyError: 'DiscoBoxSOLOv2 is not in the models registry'

How do I add the DiscoBox models to mmcv's registry?

My build info:
I am using your Docker container (on Ubuntu 20.04 with CUDA 11.4), with mmcv-full version 1.3.17 and latest (as of July 15, 2022) master of mmdetection.

The pretrained models on VOC.

Hello, thanks for your promising work! Is it convenient to share the pretrained models for the Pascal VOC?
Thank you in advance.

I met an error while training my own dataset: IndexError: index 0 is out of bounds for dimension 0 with size 0

Thanks for your nice implementation.
I have tried DiscoBox to train my own dataset and met the following error.
I used this config file, with changing dataset path and classes info.

Traceback (most recent call last):
  File "tools/train.py", line 191, in <module>
    main()
  File "tools/train.py", line 180, in main
    train_detector(
  File "/workspace/mmdet/apis/train.py", line 172, in train_detector
    runner.run(data_loaders, cfg.workflow)
  File "/opt/conda/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 127, in run
    epoch_runner(data_loaders[i], **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 50, in train
    self.run_iter(data_batch, train_mode=True, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 29, in run_iter
    outputs = self.model.train_step(data_batch, self.optimizer,
  File "/opt/conda/lib/python3.8/site-packages/mmcv/parallel/data_parallel.py", line 67, in train_step
    return self.module.train_step(*inputs[0], **kwargs[0])
  File "/workspace/mmdet/models/detectors/base.py", line 251, in train_step
    losses = self(**data)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/mmcv/runner/fp16_utils.py", line 128, in new_func
    output = old_func(*new_args, **new_kwargs)
  File "/workspace/mmdet/models/detectors/base.py", line 185, in forward
    return self.forward_train(img, img_metas, **kwargs)
  File "/workspace/mmdet/models/detectors/single_stage_wsis.py", line 206, in forward_train
    losses = self.bbox_head.loss(
  File "/opt/conda/lib/python3.8/site-packages/torch/cuda/amp/autocast_mode.py", line 140, in decorate_autocast
    return func(*args, **kwargs)
  File "/workspace/mmdet/models/dense_heads/discobox_solov2_head.py", line 1329, in loss
    ins_label_list, cate_label_list, ins_ind_label_list, grid_order_list = multi_apply(
  File "/workspace/mmdet/core/utils/misc.py", line 29, in multi_apply
    return tuple(map(list, zip(*map_results)))
  File "/workspace/mmdet/models/dense_heads/discobox_solov2_head.py", line 1620, in solov2_target_single
    device = gt_labels_raw[0].device
IndexError: index 0 is out of bounds for dimension 0 with size 0

This error seems gt_labels_raw is empty. But images in my dataset have at least one bbox.
Could you suggest some clues to solve this problem?
Thanks.

Question regarding box-conditioned inference

Hi,
I'm new to MMDet and DiscoBox, and I'm trying to train a model to convert bounding boxs to polygons on my own dataset.
So I use this command: python ./tools/train.py configs/Andy_self/Discobox/boxcond_discobox_solov2_x101_dcn_fpn_3x.py --work-dir ./Disco_work_dirs --load-from ./checkpoints/Disco_coco_x101_dcn_fpn_3x.pth
and I get the following error:

File "./tools/train.py", line 191, in
main()
File "./tools/train.py", line 187, in main
meta=meta)
File "/home/yuecao/project/terrasense/DiscoBox/mmdet/apis/train.py", line 172, in train_detector
runner.run(data_loaders, cfg.workflow)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 127, in run
epoch_runner(data_loaders[i], **kwargs)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 50, in train
self.run_iter(data_batch, train_mode=True, **kwargs)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 30, in run_iter
**kwargs)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/mmcv/parallel/data_parallel.py", line 67, in train_step
return self.module.train_step(*inputs[0], **kwargs[0])
File "/home/yuecao/project/terrasense/DiscoBox/mmdet/models/detectors/base.py", line 251, in train_step
losses = self(**data)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 128, in new_func
output = old_func(*new_args, **new_kwargs)
File "/home/yuecao/project/terrasense/DiscoBox/mmdet/models/detectors/single_stage_wsis.py", line 249, in forward
return self.forward_train(img, img_metas, **kwargs)
File "/home/yuecao/project/terrasense/DiscoBox/mmdet/models/detectors/single_stage_wsis.py", line 86, in forward_train
use_ts_loss=self.avg_loss_ins<0.4)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/torch/cuda/amp/autocast_mode.py", line 141, in decorate_autocast
return func(*args, **kwargs)
TypeError: loss() got an unexpected keyword argument 'use_ts_loss'

After I checked the source code from single_stage_wsis.py I changed the argument name to "use_loss_ts" and the error disappeared.
Bet another error occurred:

Traceback (most recent call last):
File "./tools/train.py", line 191, in
main()
File "./tools/train.py", line 187, in main
meta=meta)
File "/home/yuecao/project/terrasense/DiscoBox/mmdet/apis/train.py", line 172, in train_detector
runner.run(data_loaders, cfg.workflow)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 127, in run
epoch_runner(data_loaders[i], **kwargs)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 50, in train
self.run_iter(data_batch, train_mode=True, **kwargs)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/mmcv/runner/epoch_based_runner.py", line 30, in run_iter
**kwargs)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/mmcv/parallel/data_parallel.py", line 67, in train_step
return self.module.train_step(*inputs[0], **kwargs[0])
File "/home/yuecao/project/terrasense/DiscoBox/mmdet/models/detectors/base.py", line 251, in train_step
losses = self(**data)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 128, in new_func
output = old_func(*new_args, **new_kwargs)
File "/home/yuecao/project/terrasense/DiscoBox/mmdet/models/detectors/single_stage_wsis.py", line 249, in forward
return self.forward_train(img, img_metas, **kwargs)
File "/home/yuecao/project/terrasense/DiscoBox/mmdet/models/detectors/single_stage_wsis.py", line 86, in forward_train
use_loss_ts=self.avg_loss_ins<0.4)
File "/home/yuecao/anaconda3/envs/discobox/lib/python3.7/site-packages/torch/cuda/amp/autocast_mode.py", line 141, in decorate_autocast
return func(*args, **kwargs)
TypeError: loss() missing 2 required positional arguments: 'img_metas' and 'cfg'

Did I do anything wrong? How should I fix this problem?

Thank you very much for your help

Question about the BoxInst Mentioned in the paper

Greetings! Thanks for supporting your code for your awesome work!

I noticed that you have listed the result of BoxInst in your paper, would you have try to re-implement BoxInst in your mmdet code?

error

one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [2, 128, 80, 88]], which is output 0 of ReluBackward0, is at version 3; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

Why the mask_gt still in the code?

In the disco_solo_head the input of loss has a maks_gt_list, and it is used in the code. It is may our my fault understanding. Thanks for the good work.

Discobox evaluation failed with custom dataset

Thanks to the authors for making DiscoBox code public.
I am trying to finetune the COCO checkpoint on my custom COCO style dataset.
My training seems to be running fine, but as soon as the scripts gets into evaluation (during train), it gets stuck and after a minutes wait, process is terminated abruptly.
Here is the train command I use:

bash tools/dist_train.sh configs/discobox/custom_discobox_solov2_r50_fpn_3x.py 2

Error I get -

  [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>                     ] 166/279, 1.3 task/s, elapsed: 124s, ETA:    85sTraceback (most recent call last):
  File "/opt/conda/envs/open-mmlab/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/opt/conda/envs/open-mmlab/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/conda/envs/open-mmlab/lib/python3.7/site-packages/torch/distributed/launch.py", line 261, in <module>
    main()
  File "/opt/conda/envs/open-mmlab/lib/python3.7/site-packages/torch/distributed/launch.py", line 257, in main
    cmd=cmd)
subprocess.CalledProcessError: Command '['/opt/conda/envs/open-mmlab/bin/python', '-u', 'tools/test.py', '--local_rank=0', 'configs/discobox/custom_solov2_r50_fpn_3x.py', 'work_dirs/roboflow_data/epoch_1.pth', '--launcher', 'pytorch', '--eval', 'bbox', 'segm']' died with <Signals.SIGKILL: 9>.

To further investigate this, I also tried running training on 1 GPU,

bash tools/dist_train.sh configs/discobox/custom_discobox_solov2_r50_fpn_3x.py 1

This failed too with the same error.

Another thing I thought is wroth trying is to run a separate eval -

bash tools/dist_test.sh configs/discobox/custom_solov2_r50_fpn_3x.py work_dirs/roboflow_data/epoch_1.pth 1 --eval bbox segm

Again, resulted into the same error.

Has anyone come across this error? Please help, thanks!

Error. Can you help?

I work in PyCharm on Windows-10-x64, CUDA=11.1, RTX-3060

#pip install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html

#pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9/index.html

#git clone https://github.com/NVlabs/DiscoBox.git
#cd DiscoBox
#pip install -r requirements/build.txt

#git clone https://github.com/open-mmlab/mmdetection.git
#cd mmdetection
#pip install -r requirements/build.txt
# pip install -v -e .

from mmdetection.mmdet.apis import init_detector, inference_detector

config_file = 'mmdetection/configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
# init a detector
model = init_detector(config_file, checkpoint_file, device=device)
# inference the demo image
inference_detector(model, 'mmdetection/demo/demo.jpg')

ERROR

D:\NVLabs_2.0\venv\Scripts\python.exe D:/NVLabs_2.0/main.py
load checkpoint from local path: faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
d:\nvlabs_2.0\mmdetection\mmdet\datasets\utils.py:70: UserWarning: "ImageToTensor" pipeline is replaced by "DefaultFormatBundle" for batch inference. It is recommended to manually replace it in the test data pipeline in your config file.
  'data pipeline in your config file.', UserWarning)
Traceback (most recent call last):
  File "D:/NVLabs_2.0/main.py", line 26, in <module>
    inference_detector(model, 'mmdetection/demo/demo.jpg')
  File "D:\NVLabs_2.0\mmdetection\mmdet\apis\inference.py", line 157, in inference_detector
    results = model(return_loss=False, rescale=True, **data)
  File "D:\NVLabs_2.0\venv\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\NVLabs_2.0\venv\lib\site-packages\mmcv\runner\fp16_utils.py", line 98, in new_func
    return old_func(*args, **kwargs)
  File "d:\nvlabs_2.0\mmdetection\mmdet\models\detectors\base.py", line 174, in forward
    return self.forward_test(img, img_metas, **kwargs)
  File "d:\nvlabs_2.0\mmdetection\mmdet\models\detectors\base.py", line 147, in forward_test
    return self.simple_test(imgs[0], img_metas[0], **kwargs)
  File "d:\nvlabs_2.0\mmdetection\mmdet\models\detectors\two_stage.py", line 179, in simple_test
    proposal_list = self.rpn_head.simple_test_rpn(x, img_metas)
  File "d:\nvlabs_2.0\mmdetection\mmdet\models\dense_heads\dense_test_mixins.py", line 130, in simple_test_rpn
    proposal_list = self.get_bboxes(*rpn_outs, img_metas=img_metas)
  File "D:\NVLabs_2.0\venv\lib\site-packages\mmcv\runner\fp16_utils.py", line 186, in new_func
    return old_func(*args, **kwargs)
  File "d:\nvlabs_2.0\mmdetection\mmdet\models\dense_heads\base_dense_head.py", line 105, in get_bboxes
    **kwargs)
  File "d:\nvlabs_2.0\mmdetection\mmdet\models\dense_heads\rpn_head.py", line 187, in _get_bboxes_single
    img_shape)
  File "d:\nvlabs_2.0\mmdetection\mmdet\models\dense_heads\rpn_head.py", line 231, in _bbox_post_process
    dets, _ = batched_nms(proposals, scores, ids, cfg.nms)
  File "D:\NVLabs_2.0\venv\lib\site-packages\mmcv\ops\nms.py", line 307, in batched_nms
    dets, keep = nms_op(boxes_for_nms, scores, **nms_cfg_)
  File "D:\NVLabs_2.0\venv\lib\site-packages\mmcv\utils\misc.py", line 340, in new_func
    output = old_func(*args, **kwargs)
  File "D:\NVLabs_2.0\venv\lib\site-packages\mmcv\ops\nms.py", line 172, in nms
    score_threshold, max_num)
  File "D:\NVLabs_2.0\venv\lib\site-packages\mmcv\ops\nms.py", line 27, in forward
    bboxes, scores, iou_threshold=float(iou_threshold), offset=offset)
RuntimeError: CUDA error: no kernel image is available for execution on the device
CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1.

Process finished with exit code 1

Does the code use the same hyper parameters as the paper described?

Thanks for great work!

I read the code in MeanField class. It seems that it is inconsistent with the paper.

屏幕快照 2021-10-24 15 18 19

class MeanField(nn.Module):
# feature map (RGB)
# B = #num of object
# shape of [N 3 H W]
#@autocast(enabled=False)
def __init__(self, feature_map, kernel_size=3, require_grad=False, theta0=0.5, theta1=30, theta2=10, alpha0=3,
iter=20, base=0.45, gamma=0.01):
super(MeanField, self).__init__()
self.require_grad = require_grad
self.kernel_size = kernel_size
with torch.no_grad():
self.unfold = torch.nn.Unfold(kernel_size, stride=1, padding=kernel_size//2)
feature_map = feature_map + 10
unfold_feature_map = self.unfold(feature_map).view(feature_map.size(0), feature_map.size(1), kernel_size**2, -1)
self.feature_map = feature_map
self.theta0 = theta0
self.theta1 = theta1
self.theta2 = theta2
self.alpha0 = alpha0
self.gamma = gamma
self.base = base
self.spatial = torch.tensor((np.arange(kernel_size**2)//kernel_size - kernel_size//2) ** 2 +\
(np.arange(kernel_size**2) % kernel_size - kernel_size//2) ** 2).to(feature_map.device).float()
self.kernel = alpha0 * torch.exp((-(unfold_feature_map - feature_map.view(feature_map.size(0), feature_map.size(1), 1, -1)) ** 2).sum(1) / (2 * self.theta0 ** 2) + (-(self.spatial.view(1, -1, 1) / (2 * self.theta1 ** 2))))
self.kernel = self.kernel.unsqueeze(1)
self.iter = iter
# input x
# shape of [N H W]
#@autocast(enabled=False)
def forward(self, x, targets, inter_img_mask=None):
with torch.no_grad():
x = x * targets
x = (x > 0.5).float() * (1 - self.base*2) + self.base
U = torch.cat([1-x, x], 1)
U = U.view(-1, 1, U.size(2), U.size(3))
if inter_img_mask is not None:
inter_img_mask.reshape(-1, 1, inter_img_mask.shape[2], inter_img_mask.shape[3])
ret = U
for _ in range(self.iter):
nret = self.simple_forward(ret, targets, inter_img_mask)
ret = nret
ret = ret.view(-1, 2, ret.size(2), ret.size(3))
ret = ret[:,1:]
ret = (ret > 0.5).float()
count = ret.reshape(ret.shape[0], -1).sum(1)
valid = (count >= ret.shape[2] * ret.shape[3] * 0.05) * (count <= ret.shape[2] * ret.shape[3] * 0.95)
valid = valid.float()
return ret, valid
#@autocast(enabled=False)
def simple_forward(self, x, targets, inter_img_mask):
h, w = x.size(2), x.size(3)
unfold_x = self.unfold(-torch.log(x)).view(x.size(0)//2, 2, self.kernel_size**2, -1)
aggre = (unfold_x * self.kernel).sum(2)
aggre = aggre.view(-1, 1, h, w)
f = torch.exp(-aggre)
f = f.view(-1, 2, h, w)
if inter_img_mask is not None:
f += inter_img_mask * self.gamma
f[:, 1:] *= targets
f = f + 1e-6
f = f / f.sum(1, keepdim=True)
f = (f > 0.5).float() * (1 - self.base*2) + self.base
f = f.view(-1, 1, h, w)
return f

Results of model with 1x r50 on COCO.

Hello, thanks for your promising work.
Due to the long training time of 3x on COCO, can you provide the AP resutls of COCO with 1x training schedule as a performance reference.

Some questions regarding the DiscoBox paper

Thanks for the nice work and it runs smoothly with Docker. I have some questions with paper and hope you can give me some help.

  1. You mention both YOLACT++ and SOLO V2, but it is not clear which one you use in Figure 2, does it mean Discobox can use either of them as long as it has mask head?
  2. In section 3.2, fi and fk represent the ROI features of pixel i, could you please clarify what ROI means? Is the mask area within the bounding box? Also what the features are? RGB values and spatial information?
  3. For the Structured teach, Tc is the cross image potentials, does it mean the comparison of one boxing box with all other bboxes in other images with the same label?
  4. For the self-ensembling loss, you mentioned self consistency between our task and teach networks were calculated, but I am not clear how the Lnce? Does it compare the the masks features within bounding boxes across the teacher and task network?
  5. In structure teacher, Gibbs energy was defined with unary potentials, pair potentials and cross-image pair potentials, but in the learning section, the loss function does not have them. So question is how the learning can correlate with it and minimise the energy? Apology I am not very familiar with standard mean field.

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.