A Pytorch Implementation for Incremental Multi-Target Domain Adaptation for Object Detection with Efficient Domain Transfer
## Introduction
Please follow [faster-rcnn](https://github.com/jwyang/faster-rcnn.pytorch/tree/pytorch-1.0) and [HTCN](https://github.com/chaoqichen/HTCN) respository to setup the environment. In this project, we use Pytorch 1.6.1 and CUDA version is 10.2
## Additional Information
- We use Sacred([link](https://sacred.readthedocs.io/en/stable/)) to run/manage our experiments. It can be installed with:
```
pip install sacred
```
- To monitor the training, we used MongoObserver of Sacred with Omniboard. However, it is disabled by default. If you want to plug in your own monitoring. It can be done in **class LoggerForSacred** of **experiments/exp_utils.py** which will be called at every 100 iteration. By default, log are printed to stdout.
- All models are expected to be saved in *all_saves* folder in repo's root. This can be changed in the code.
## Datasets
### Datasets Preparation
* **Cityscape and FoggyCityscape:** Download the [Cityscape](https://www.cityscapes-dataset.com/) dataset, see dataset preparation code in [DA-Faster RCNN](https://github.com/yuhuayc/da-faster-rcnn/tree/master/prepare_data).
* **PASCAL_VOC 07+12:** Please follow the [instruction](https://github.com/rbgirshick/py-faster-rcnn#beyond-the-demo-installation-for-training-and-testing-models) to prepare VOC dataset.
* **Clipart - Watercolor - Comic:** Please follow the [instruction](https://github.com/naoto0804/cross-domain-detection/tree/master/datasets) to download
### Datasets Format
All codes are written to fit for the **format of PASCAL_VOC**.
If you want to use this code on your own dataset, please arrange the dataset in the format of PASCAL, make dataset class in ```lib/datasets/```, and add it to ```lib/datasets/factory.py```, ```lib/datasets/config_dataset.py```. Then, add the dataset option to ```lib/model/utils/parser_func.py```.
For RainCityscape train and evaluation list you can find them here: [train](https://drive.google.com/file/d/1K9TILq7zmecvuiDNGeHnYaulXhcJaX2N/view?usp=sharing), [val](https://drive.google.com/file/d/1lTOjhGxcAsKS1HtAU-vE3eaTmqwoHF36/view?usp=sharing)
## Models
### Pre-trained Models
In our experiments, we used two pre-trained models on ImageNet, i.e., VGG16 and ResNet101. Please download these two models from:
* **VGG16:** [Dropbox](https://www.dropbox.com/s/s3brpk0bdq60nyb/vgg16_caffe.pth?dl=0) [VT Server](https://filebox.ece.vt.edu/~jw2yang/faster-rcnn/pretrained-base-models/vgg16_caffe.pth)
* **ResNet50:** Download the model (the one for BGR) from [link](https://github.com/ruotianluo/pytorch-resnet)
Download them and write the path in **__C.VGG_PATH** and **__C.RESNET50_PATH** at ```lib/model/utils/config.py```.
## Train Example
**Don't forget to install sacred**, you cannot run our code without it.
To run the first step of **Cityscape** -> **FoggyCityscape** on VGG16 with our hyper-parameters :
```
CUDA_VISIBLE_DEVICES=$GPU_ID \
python experiments/exp_traineval_htcn.py
```
If you want to do your own hyper-parameters, etc..., **exp_traineval_htcn.py** is fairly easy to understand to modify. We provided an example to modify this at the end.
To train DTM for the next incremental step, you will have to change 'load_name' inside **exp_train_dtm.py** to the model obtained from previous step:
```
CUDA_VISIBLE_DEVICES=$GPU_ID \
python experiments/exp_train_dtm.py
```
The next incremental domain adaptation, you will have to point 'dtm_load_p' to the DTM model you just trained and 'load_name' the model obtained from the first domain adaptation inside **exp_traineval_htcn_inc_ida_dtm.py**:
```
CUDA_VISIBLE_DEVICES=$GPU_ID \
python experiments/exp_traineval_htcn_inc_ida_dtm.py
```
Example of how to edit hyper-parameters etc... in **exp_traineval_htcn.py**.
Original:
```
if __name__ == "__main__":
ex.run(config_updates={'cfg_file': 'cfgs/vgg16.yml',
'lr': 0.001,
'lr_decay_step': [5],
'max_epochs': 7,
'net': 'vgg16',
'pretrained': True,
'dataset_source': 'cs',
'dataset_target': 'cs_fg',
'val_datasets': ['cs_fg']},
options={"--name": 'htcn_cs_2_cs_fg_vgg16'})
```
Edit for **PascalVOC** -> **Clipart** in **exp_traineval_htcn.py**:
```
if __name__ == "__main__":
ex.run(config_updates={'cfg_file': 'cfgs/resnet50.yml',
'lr': 0.001,
'lr_decay_step': [5],
'max_epochs': 7,
'net': 'res50',
'pretrained': True,
'dataset_source': 'voc_0712',
'dataset_target': 'clipart',
'val_datasets': ['clipart']},
options={"--name": 'NAME_OF_YOUR_EXPERIMENT'})
```
## Test
Similar to training, modify **exp_eval.py** to evaluate a model.
Edit 'val_datasets' for the dataset you want to test, it can be multiple datasets (it will return overall accuracy of all datasets on each class), 'model_pth' the path to the model:
```
CUDA_VISIBLE_DEVICES=$GPU_ID \
python experiments/exp_eval.py
```
### Trained Model
- **VGG16 Model** of **Cityscape** -> **FoggyCityscape** -> **RainCityscape**(Overall mAP = 39.1): [Link](https://drive.google.com/file/d/1jx5oiUYAPWCxMnQn6sBlWDaDr2EmbxII/view?usp=sharing)
- **ResNet50 Model** of **Pascal** -> **Clipart** -> **Watercolor**(Overall mAP = 39.8): [Link](https://drive.google.com/file/d/1nDp1bEPaDB-I5nBBjGc3TfPd5etKxVaJ/view?usp=sharing)
- **ResNet50 Model** of **Pascal** -> **Clipart** -> **Watercolor** -> **Comic**(Overall mAP = 38.1): [Link](https://drive.google.com/file/d/1R4FwIoD-mOJ8SS_awZfBgDlY6AZvN3ox/view?usp=sharing)
没有合适的资源?快使用搜索试试~ 我知道了~
域自适应,从cityscape->foggycitycscape torch代码
共461个文件
py:266个
h:37个
pyc:27个
需积分: 10 1 下载量 167 浏览量
2022-04-03
17:01:20
上传
评论 1
收藏 20.24MB ZIP 举报
温馨提示
域自适应,从cityscape->foggycitycscape torch代码
资源详情
资源评论
资源推荐
收起资源包目录
域自适应,从cityscape->foggycitycscape torch代码 (461个子文件)
_mask.c 584KB
_mask.c 584KB
_mask.c 584KB
roi_crop.c 23KB
roi_crop.c 23KB
maskApi.c 8KB
maskApi.c 8KB
maskApi.c 8KB
roi_align.c 7KB
roi_align.c 7KB
roi_crop_cuda.c 5KB
roi_crop_cuda.c 5KB
roi_pooling.c 4KB
roi_pooling.c 4KB
roi_pooling_cuda.c 3KB
roi_pooling_cuda.c 3KB
roi_align_cuda.c 2KB
roi_align_cuda.c 2KB
nms_cuda.c 608B
nms_cuda.c 608B
nms_cuda.c 608B
ROIAlign_cpu.cpp 8KB
ROIAlign_cpu.cpp 8KB
nms_cpu.cpp 2KB
nms_cpu.cpp 2KB
vision.cpp 505B
vision.cpp 505B
roi_crop_cuda_kernel.cu 17KB
roi_crop_cuda_kernel.cu 17KB
ROIAlign_cuda.cu 12KB
ROIAlign_cuda.cu 12KB
roi_pooling_kernel.cu 9KB
roi_pooling_kernel.cu 9KB
ROIPool_cuda.cu 8KB
ROIPool_cuda.cu 8KB
roi_align_kernel.cu 8KB
roi_align_kernel.cu 8KB
nms_cuda_kernel.cu 5KB
nms_cuda_kernel.cu 5KB
nms_cuda_kernel.cu 5KB
nms_kernel.cu 5KB
nms_kernel.cu 5KB
nms_kernel.cu 5KB
nms.cu 5KB
nms.cu 5KB
roi_crop_cuda_kernel.h 3KB
roi_crop_cuda_kernel.h 3KB
vision.h 2KB
vision.h 2KB
maskApi.h 2KB
maskApi.h 2KB
maskApi.h 2KB
ROIAlign.h 2KB
ROIAlign.h 2KB
ROIPool.h 2KB
ROIPool.h 2KB
roi_align_kernel.h 1KB
roi_align_kernel.h 1KB
roi_pooling_kernel.h 767B
roi_pooling_kernel.h 767B
nms.h 716B
nms.h 716B
roi_crop.h 659B
roi_crop.h 659B
vision.h 594B
vision.h 594B
roi_crop_cuda.h 481B
roi_crop_cuda.h 481B
roi_pooling_cuda.h 420B
roi_pooling_cuda.h 420B
roi_align_cuda.h 369B
roi_align_cuda.h 369B
roi_align.h 361B
roi_align.h 361B
nms_cuda.h 272B
nms_cuda.h 272B
nms_cuda.h 272B
nms_cuda_kernel.h 206B
nms_cuda_kernel.h 206B
nms_cuda_kernel.h 206B
roi_pooling.h 178B
roi_pooling.h 178B
LICENSE 1KB
voc_eval.m 1KB
voc_eval.m 1KB
voc_eval.m 1KB
xVOCap.m 258B
xVOCap.m 258B
xVOCap.m 258B
get_voc_opts.m 231B
get_voc_opts.m 231B
get_voc_opts.m 231B
README.md 6KB
README.md 5KB
README.md 2KB
roi_pooling.cu.o 119KB
roi_pooling.cu.o 94KB
roi_align_kernel.cu.o 81KB
roi_align_kernel.cu.o 81KB
roi_crop_cuda_kernel.cu.o 79KB
共 461 条
- 1
- 2
- 3
- 4
- 5
无崖子0
- 粉丝: 254
- 资源: 28
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0