https://github.com/idiap/model-uncertainty-for-adaptation
Code paper Uncertainty Reduction for Uncertainty Reduction for Model Adaptation in Semantic Segmentation at CVPR 2021
https://github.com/idiap/model-uncertainty-for-adaptation
Last synced: about 1 year ago
JSON representation
Code paper Uncertainty Reduction for Uncertainty Reduction for Model Adaptation in Semantic Segmentation at CVPR 2021
- Host: GitHub
- URL: https://github.com/idiap/model-uncertainty-for-adaptation
- Owner: idiap
- License: other
- Created: 2021-04-07T08:09:16.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-09-12T18:42:30.000Z (almost 4 years ago)
- Last Synced: 2025-03-23T01:01:50.164Z (about 1 year ago)
- Language: Python
- Size: 137 KB
- Stars: 51
- Watchers: 5
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Code for paper [*Uncertainty Reduction for Model Adaptation in Semantic Segmentation*](http://publications.idiap.ch/attachments/papers/2021/Sivaprasad_CVPR_2021.pdf) at CVPR 2021
In this package, we provide our PyTorch code for out CVPR 2021 paper on Model Adaptation for Segmentation. If you use our code, please cite us:
```bibtex
@inproceedings{teja2021uncertainty,
author={S, Prabhu Teja and Fleuret, François},
booktitle={2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
title={Uncertainty Reduction for Model Adaptation in Semantic Segmentation},
year={2021},
volume={},
number={},
pages={9608-9618},
doi={10.1109/CVPR46437.2021.00949}}
```
The PDF version of the paper is available [here](http://publications.idiap.ch/attachments/papers/2021/Sivaprasad_CVPR_2021.pdf).
## Requirements
We use PyTorch for the experiments. The conda environment required to run these codes can be installed by
`conda create --name ucr --file spec-file.txt`
While we aren't aware of any python version specific idiosyncracies, we tested this on Python 3.7 on Debian, with the above `spec-file.txt`. If you find any missing details, or have trouble getting it to run, please create an issue.
## Training the network
### Downloading pre-trained models
We use the pretrained models provided by [MaxSquareLoss](https://github.com/ZJULearning/MaxSquareLoss) at [https://drive.google.com/file/d/1QMpj7sPqsVwYldedZf8A5S2pT-4oENEn/view](https://drive.google.com/file/d/1QMpj7sPqsVwYldedZf8A5S2pT-4oENEn/view) into a folder named `pretrained`
### Setting up paths
First, the paths to the Cityscapes dataset has to be set in `datasets/new_datasets.py` in the dataset's constructor. The path to NTHU cities dataset can be set in `utils/argparser.py` in line 15 at `DATA_TGT_DIRECTORY` or can be added to the command line call at with `--data-tgt-dir`. The code trains the network and evaluates its performance and writes it into the log file in the `savedir` called `training_logger`.
### Running the code
Then code can be run with
```python
python do_segm.py --city {city} --no-src-data --freeze-classifier --unc-noise --lambda-ce 1 --lambda-ent 1 --save {savedir} --lambda-ssl 0.1
```
where `city` can in `Rome` or `Rio` or `Tokyo` or `Taipei`, and `savedir` is the path to save the logs and models.
## Acknowledgements
This code borrows parts from [MaxSquareLoss](https://github.com/ZJULearning/MaxSquareLoss) (the network definitions, and pretrained models) and [CRST](https://github.com/yzou2/CRST) (class balanced pseudo-label generation). The author thanks Evann Courdier for parts of the clean `datasets` code.
## License
This software is distributed with the **MIT** license which pretty much means that you can use it however you want and for whatever reason you want. All the information regarding support, copyright and the license can be found in the [`LICENSE`](./LICENSE) file in the repository.