Code Monkey home page Code Monkey logo

ripu's Introduction


Region Impurity and Prediction Uncertainty (CVPR Oral)

Binhui Xie, Longhui Yuan, Shuang Li, Chi Harold Liu and Xinjing Cheng

Paper   Models   Bilibili   YouTube   Slides  

This repository provides the official code for the paper Towards Fewer Annotations: Active Learning via Region Impurity and Prediction Uncertainty for Domain Adaptive Semantic Segmentation.

🥳 We are happy to announce that RIPU was accepted at CVPR 2022 Oral Presentation.

Overview

We propose a simple region-based active learning approach for semantic segmentation under a domain shift, aiming to automatically query a small partition of image regions to be labeled while maximizing segmentation performance. Our algorithm, RIPU, introduces a new acquisition strategy characterizing the spatial adjacency of image regions along with the prediction confidence. The proposed region-based selection strategy makes more efficient use of a limited budget than image-based or point-based counterparts.

image

We show some qualitative examples from the Cityscapes validation set, image

and also visualize the queried regions to annotate. image

For more information on RIPU, please check our Paper.

Usage

Prerequisites

  • Python 3.7
  • Pytorch 1.7.1
  • torchvision 0.8.2

Step-by-step installation

conda create --name ADASeg -y python=3.7
conda activate ADASeg

# this installs the right pip and dependencies for the fresh python
conda install -y ipython pip

# this installs required packages
pip install -r requirements.txt

Data Preparation

Symlink the required dataset

ln -s /path_to_cityscapes_dataset datasets/cityscapes
ln -s /path_to_gtav_dataset datasets/gtav
ln -s /path_to_synthia_dataset datasets/synthia

Generate the label static files for GTAV/SYNTHIA Datasets by running

python datasets/generate_gtav_label_info.py -d datasets/gtav -o datasets/gtav/
python datasets/generate_synthia_label_info.py -d datasets/synthia -o datasets/synthia/

The data folder should be structured as follows:

├── datasets/
│   ├── cityscapes/     
|   |   ├── gtFine/
|   |   ├── leftImg8bit/
│   ├── gtav/
|   |   ├── images/
|   |   ├── labels/
|   |   ├── gtav_label_info.p
│   └──	synthia
|   |   ├── RAND_CITYSCAPES/
|   |   ├── synthia_label_info.p
│   └──	

Model Zoo

We have put our model checkpoints here [Google Drive] [百度网盘] (提取码RIPU).

GTAV to Cityscapes

name backbone budget mIoU ckpt where in Our Paper
1 RIPU-PA V2 40 px 65.5 Google Drive / BaiDu  Table 1
2 RIPU-RA V2 2.2% 69.6 Google Drive / BaiDu  Table 1
3 RIPU-RA V3+ 5.0% 71.2 Google Drive / BaiDu  Table 1

SYNTHIA to Cityscapes

name backbone budget mIoU ckpt where in Our Paper
1 RIPU-PA V2 40 px 66.1 Google Drive / BaiDu  Table 2
2 RIPU-RA V2 2.2% 70.1 Google Drive / BaiDu  Table 2
3 RIPU-RA V3+ 5.0% 71.4 Google Drive / BaiDu  Table 2

Source-free scenarios

task budget mIoU source pre-trained ckpt adapted ckpt Where in Our Paper
1 GTAV to Cityscapes 2.2% 67.1 Google Drive / BaiDu  Google Drive / BaiDu  Table 12
2 SYNTHIA to Cityscapes 2.2% 68.7 Google Drive / BaiDu  Google Drive / BaiDu  Table 13

RIPU Training

We provide the training scripts in scripts/ using a single GPU.

# training for GTAV to Cityscapes
sh gtav_to_cityscapes.sh

# training for SYNTHIA to Cityscapes
sh synthia_to_cityscapes.sh

RIPU Testing

To evaluate RIPU e.g. GTAV to Cityscapes (v3+, 5.0%), use the following command:

python test.py -cfg configs/gtav/deeplabv3plus_r101_RA.yaml resume checkpint/v3plus_gtav_ra_5.0_precent/model_last.pth OUTPUT_DIR checkpint/v3plus_gtav_ra_5.0_precent

Acknowledgements

This project is based on the following open-source projects: FADA and SDCA. We thank their authors for making the source code publically available.

Citation

If you find this project useful in your research, please consider citing:

@InProceedings{xie2022ripu,
    author    = {Xie, Binhui and Yuan, Longhui and Li, Shuang and Liu, Chi Harold and Cheng, Xinjing},
    title     = {Towards Fewer Annotations: Active Learning via Region Impurity and Prediction Uncertainty for Domain Adaptive Semantic Segmentation},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2022},
    pages     = {8068-8078}
}

Contact

If you have any problem about our code, feel free to contact

or describe your problem in Issues.

ripu's People

Contributors

binhuixie avatar yuanlonghui 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

ripu's Issues

RuntimeError: Error(s) in loading state_dict for ASPP_Classifier_V2

python test.py -cfg configs/synthia/deeplabv2_r101_RA_source_free.yaml OUTPUT_DIR results/v2_synthia_ra_2.2_precent_source_free resume results/v2_gtav_ra_2.2_precent_source_free/model_iter020000.pth

I got this error :
2023-08-16 11:29:04,895 AL-RIPU.tester INFO: Loading checkpoint from results/v2_gtav_ra_2.2_precent_source_free/model_iter020000.pth
Traceback (most recent call last):
File "test.py", line 192, in
main()
File "test.py", line 188, in main
test(cfg)
File "test.py", line 93, in test
classifier.load_state_dict(classifier_weights)
File "/home/zmz/miniconda3/envs/py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1482, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for ASPP_Classifier_V2:
size mismatch for conv2d_list.0.weight: copying a param with shape torch.Size([19, 2048, 3, 3]) from checkpoint, the shape in current model is torch.Size([16, 2048, 3, 3]).
size mismatch for conv2d_list.0.bias: copying a param with shape torch.Size([19]) from checkpoint, the shape in current model is torch.Size([16]).
size mismatch for conv2d_list.1.weight: copying a param with shape torch.Size([19, 2048, 3, 3]) from checkpoint, the shape in current model is torch.Size([16, 2048, 3, 3]).
size mismatch for conv2d_list.1.bias: copying a param with shape torch.Size([19]) from checkpoint, the shape in current model is torch.Size([16]).
size mismatch for conv2d_list.2.weight: copying a param with shape torch.Size([19, 2048, 3, 3]) from checkpoint, the shape in current model is torch.Size([16, 2048, 3, 3]).
size mismatch for conv2d_list.2.bias: copying a param with shape torch.Size([19]) from checkpoint, the shape in current model is torch.Size([16]).
size mismatch for conv2d_list.3.weight: copying a param with shape torch.Size([19, 2048, 3, 3]) from checkpoint, the shape in current model is torch.Size([16, 2048, 3, 3]).
size mismatch for conv2d_list.3.bias: copying a param with shape torch.Size([19]) from checkpoint, the shape in current model is torch.Size([16]).

RuntimeError: CUDA error: no kernel image is available for execution on the device

File "/home/tl/.conda/envs/grp03/lib/python3.7/site-packages/torch/_tensor_str.py", line 372, in _str
return _str_intern(self)
File "/home/tl/.conda/envs/grp03/lib/python3.7/site-packages/torch/_tensor_str.py", line 352, in _str_intern
tensor_str = _tensor_str(self, indent)
File "/home/tl/.conda/envs/grp03/lib/python3.7/site-packages/torch/_tensor_str.py", line 241, in _tensor_str
formatter = _Formatter(get_summarized_data(self) if summarize else self)
File "/home/tl/.conda/envs/grp03/lib/python3.7/site-packages/torch/_tensor_str.py", line 275, in get_summarized_data
return torch.stack([get_summarized_data(x) for x in self])
File "/home/tl/.conda/envs/grp03/lib/python3.7/site-packages/torch/_tensor_str.py", line 275, in
return torch.stack([get_summarized_data(x) for x in self])
File "/home/tl/.conda/envs/grp03/lib/python3.7/site-packages/torch/_tensor_str.py", line 275, in get_summarized_data
return torch.stack([get_summarized_data(x) for x in self])
File "/home/tl/.conda/envs/grp03/lib/python3.7/site-packages/torch/_tensor_str.py", line 275, in
return torch.stack([get_summarized_data(x) for x in self])
File "/home/tl/.conda/envs/grp03/lib/python3.7/site-packages/torch/_tensor_str.py", line 273, in get_summarized_data
return torch.stack([get_summarized_data(x) for x in (start + end)])
File "/home/tl/.conda/envs/grp03/lib/python3.7/site-packages/torch/_tensor_str.py", line 273, in
return torch.stack([get_summarized_data(x) for x in (start + end)])
File "/home/tl/.conda/envs/grp03/lib/python3.7/site-packages/torch/_tensor_str.py", line 266, in get_summarized_data
return torch.cat((self[:PRINT_OPTS.edgeitems], self[-PRINT_OPTS.edgeitems:]))
RuntimeError: CUDA error: no kernel image is available for execution on the device

Which SYNTHIA dataset have you used?

Hi, trying your code with SYNHIA, there are lots of different types of SYNTHIA datasets. Your paper mentioned that training data has 9400 images with 16 classes but I am afraid I still cannot judge which data is what you used.

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.