https://github.com/fpv-iplab/da-retinanet
Official Detectron2 implementation of DA-RetinaNet, An unsupervised domain adaptation scheme for single-stage artwork recognition in cultural sites, Image and Vision Computing (IMAVIS) 2021
https://github.com/fpv-iplab/da-retinanet
cityscapes cityscapes-dataset coco-annotations cyclegan da-retinanet detectron2 domain-adaptation domain-adaptation-object-detection foggy-cityscapes google-colab object-detection pascal-voc retinanet unsupervised-domain-adaptation
Last synced: 5 months ago
JSON representation
Official Detectron2 implementation of DA-RetinaNet, An unsupervised domain adaptation scheme for single-stage artwork recognition in cultural sites, Image and Vision Computing (IMAVIS) 2021
- Host: GitHub
- URL: https://github.com/fpv-iplab/da-retinanet
- Owner: fpv-iplab
- License: mit
- Created: 2020-07-27T08:33:55.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-03T22:54:10.000Z (over 2 years ago)
- Last Synced: 2025-05-22T11:28:52.163Z (about 1 year ago)
- Topics: cityscapes, cityscapes-dataset, coco-annotations, cyclegan, da-retinanet, detectron2, domain-adaptation, domain-adaptation-object-detection, foggy-cityscapes, google-colab, object-detection, pascal-voc, retinanet, unsupervised-domain-adaptation
- Language: Python
- Homepage: https://iplab.dmi.unict.it/EGO-CH-OBJ-UDA/
- Size: 2.32 MB
- Stars: 63
- Watchers: 4
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Detectron2 implementation of DA-RetinaNet
This is the implementation of our Image and Vision Computing 2021 work 'An unsupervised domain adaptation scheme for single-stage artwork recognition in cultural sites'. The aim is to reduce the gap between source and target distribution improving the object detector performance on the target domain when training and test data belong to different distributions. The original paper can be found [here](https://www.sciencedirect.com/science/article/pii/S0262885621000032?dgcid=rss_sd_all).
If you want to use this code with your dataset, please follow the following guide.
Please leave a star ⭐ and cite the following [paper](http://www.sciencedirect.com/science/article/pii/S0262885621000032) if you use this repository for your project.
```
@article{PASQUALINO2021104098,
title = "An unsupervised domain adaptation scheme for single-stage artwork recognition in cultural sites",
journal = "Image and Vision Computing",
pages = "104098",
year = "2021",
issn = "0262-8856",
doi = "https://doi.org/10.1016/j.imavis.2021.104098",
author = "Giovanni Pasqualino and Antonino Furnari and Giovanni Signorello and Giovanni Maria Farinella",
}
```
## DA-RetinaNet Architecture

## Installation
You can use this repo following one of these three methods:
NB: Detectron2 0.6 is required, installing other versions this code will not work.
### Google Colab
Quickstart here 👉 [](https://colab.research.google.com/gist/GiovanniPasq/e8cc5e9d955ad01bf11df993ba276909/da-retinanet.ipynb)
Or load and run the ```DA-RetinaNet.ipynb``` on Google Colab following the instructions inside the notebook.
### Detectron2 on your PC
Follow the official guide to install [Detectron2 0.6](https://github.com/facebookresearch/detectron2/blob/master/INSTALL.md)
Or
Download the official Detectron2 0.6 from [here](https://github.com/facebookresearch/detectron2/archive/refs/tags/v0.6.zip)
Unzip the file and rename it in detectron2
run ```python -m pip install -e detectron2```
### Detectron2 via Dockerfile
Follow these instructions:
```
cd docker/
# Build
docker build -t detectron2:v0 .
# Launch
docker run --gpus all -it --shm-size=8gb -v /home/yourpath/:/home/yourpath --name=name_container detectron2:v0
```
If you exit from the container you can restart it using:
```
docker start name_container
docker exec -it name_container /bin/bash
```
## Dataset
Create the Cityscapes-Foggy Cityscapes dataset following the instructions available [here](https://github.com/yuhuayc/da-faster-rcnn/tree/master/prepare_data)
The UDA-CH dataset is available [here](https://iplab.dmi.unict.it/EGO-CH-OBJ-UDA/EGO-CH-OBJ-UDA.zip)
## Data Preparation
If you want to use this code with your dataset arrange the dataset in the format of COCO or PASCAL VOC.
For COCO annotations, inside the script ```uda_train.py``` register your dataset using:
```register_coco_instances("dataset_name_source_training",{},"path_annotations","path_images")```
```register_coco_instances("dataset_name_target_training",{},"path_annotations","path_images")```
```register_coco_instances("dataset_name_target_test",{},"path_annotations","path_images")```
For PASCAL VOC annotations, inside the ```cityscape_train.py``` register your dataset using:
```register_pascal_voc("city_trainS", "cityscape/VOC2007/", "train_s", 2007, ['car','person','rider','truck','bus','train','motorcycle','bicycle'])```
```register_pascal_voc("city_trainT", "cityscape/VOC2007/", "train_t", 2007, ['car','person','rider','truck','bus','train','motorcycle','bicycle'])```
```register_pascal_voc("city_testT", "cityscape/VOC2007/", "test_t", 2007, ['car','person','rider','truck','bus','train','motorcycle','bicycle'])```
You need to replace the parameters inside the ```register_pascal_voc()``` function according to your dataset name and classes.
## Training
Replace at the following path ```detectron2/modeling/meta_arch/``` the ```dense_detector.py``` script with our ```dense_detector.py```.
Do the same for the ```fpn.py``` file at the path ```detectron2/modeling/backbone/```
Run the script ```uda_train.py``` for COCO annotations or ```cityscape_train.py``` for PASCAL VOC annotations.
Trained model on Cityscapes to FoggyCityscapes is available at this link:
[DA-RetinaNet_Cityscapes](https://iplab.dmi.unict.it/EGO-CH-OBJ-UDA/DA-RetinaNet_Cityscapes.pth)
Trained models on the proposed UDA-CH dataset are available at these links:
[DA-RetinaNet](https://iplab.dmi.unict.it/EGO-CH-OBJ-UDA/DA-RetinaNet.pth)
[DA-RetinaNet-CycleGAN](https://iplab.dmi.unict.it/EGO-CH-OBJ-UDA/DA-RetinaNet-CycleGAN.pth)
## Testing
If you want to test the model load the new weights, set to 0 the number of iterations and rerun the same script used for the training.
## Results on Cityscapes -> Foggy Cityscapes
Results adaptation between Cityscapes and Foggy Cityscapes dataset. The performance scores of the methods marked with the “*” symbol are reported from the authors of their respective papers.
Model
mAP
Faster RCNN*
20.30%
DA-Faster RCNN*
27.60%
StrongWeak*
34.30%
Diversify and Match*
34.60%
DA-RetinaNet
44.87%
RetinaNet (Oracle)
53.46%
## Results on the proposed dataset Synthetic -> Real
Results of DA-Faster RCNN, Strong-Weak and the proposed DA-RetinaNet combined with image-to-image translation approach.
image to image translation (CycleGAN)
Object Detector
None
Synthetic to Real
DA-Faster RCNN
12.94%
33.20%
StrongWeak
25.12%
47.70%
DA-RetinaNet
31.04%
58.01%
## Other Works
[STMDA-RetinaNet](https://github.com/fpv-iplab/STMDA-RetinaNet)
[Detectron2 implementation of DA-Faster RCNN](https://github.com/GiovanniPasq/DA-Faster-RCNN)