A Comparative Analysis of Multi-Task Learning Approaches in the Context of Multi-Label Remote Sensing Image Retrieval
This project aims to compare the performance of multi-task approaches in content-based remote sensing image re-trieval (CBIR). The goal of all the methods in this work isto learn a metric for multi-label images, such that sampleswith maximum overlap in label sets are close. The three multi-task methods we compared are:
- Diverse Visual Feature Aggregation for Deep MetricLearning (Diva) git pdf
- Divide and Conquer the Embedding Space for MetricLearning (D&C) git pdf
- Deep Metric Learning with BIER: Boosting Indepen-dent Embedding Robustly (Bier) git pdf
One single-task approach for further comparisons:
- Graph Relation Network: Modeling Relations Between Scenes for Multilabel Remote-Sensing Image Classification and Retrieval (SNDL) pdf
Data for:
Downloaded data should be placed in a folder named Dataset and keep the original structure:
Dataset
└───BigEarthNet
| └───S2A_MSIL2A_20170613T101031_0_48
| │ S2A_MSIL2A_20170613T101031_0_48_B0
| │ ...
| ...
|
└───MLRSNet
| | Categories_names.xlsx
| └───Images
| | └───airplane
| | │ airplane_00001.jpg
| | │ ...
| |
| └───labels
| | └───airplane.csv
| ...
Assuming your folder is placed in e.g. <$path/Dataset/BigEarthNet>
, pass $path/Dataset
as input to --source_path
- python==3.6
- torch==1.7.0
- torchvision==0.8.1
- faiss-gpu==1.6.5
- hypia==0.0.3
- GDAL==3.0.4
- pretrainedmodels==0.7.4
- wandb==0.10.20
- vaex==4.0.0
An exemplary setup of a virtual environment containing everything needed:
(1) wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
(2) bash Miniconda3-latest-Linux-x86_64.sh (say yes to append path to bashrc)
(3) source .bashrc
(4) conda create -n DL python=3.6
(5) conda activate DL
(6) conda install matplotlib scipy scikit-learn scikit-image tqdm vaex pillow xlrd
(7) conda install pytorch torchvision faiss-gpu cudatoolkit=10.0 -c pytorch
(8) pip install wandb pretrainedmodels hypia
(9) Run the scripts!
Training is done by using train_baseline.py
or train_bier.py
or train_dac.py
ortrain_sndl.py
and setting the respective flags, all of which are listed and explained in parameters.py
. A set of exemplary runs is provided in SampleRun.sh
.
[I.] A basic sample run using default parameters would like this:
python train_diva.py --log_online \
--dataset MLRSNet \
--source_path ".../Dataset" \
--save_path "../Training_Results" \
--project MLRSNet --group bier --savename 'bier' \
--num_samples_per_class 2 --use_npmem --eval_epoch 10 --nb_epochs 120
- During training, metrics listed in
--eval_metric
will be logged for validation/test set. If you also want to log the overlap of embedding distance from intra and inter group, simply set the flag--is_plot_dist
. A checkpoint is saved for improvements on recall@1 on validation set. The default metrics supported are Recall@K, R-Precision@K, MAP@K. - If the training is stopped accidentally, you can resume the training by set the flag
--load_from_checkpoint
, the training will be restarted from the last checkpoint epoch, and the training results will be written to the original checkpoint folder.
- Create an account here (free): https://wandb.ai
- After the account is set, make sure to include your API key in
parameters.py
under--wandb_key
. - Set the flag
--log_online
to use wandb logging, if the network is unavailable in your training environment, set the flag--wandb_dryrun
to make wandb store the data locally, and you can upload the data with the commandwandb sync <$path/wandb/offline..>
Evaluation is done by using evaluate_model.py
and setting the respective flags, all of which are listed and explained in evaluate_model.py
. A set of exemplary runs is provided in SampleRun.sh
. The evaluation results will include a summary of metric scores, png files of retrieved samples, distance density plot of intra and inter group if the flag --is_plot_dist
is set.
- Margin loss [Sampling Matters in Deep Embeddings Learning]
- Binominal loss(boosted)
- NCA loss [Improving Generalization via Scalable Neighborhood Component Analysis]
- Fast MOCO Momentum Contrast Loss
- Adversarial loss
- Semihard [Facenet: A unified embedding for face recognition and clustering]
- MultiLabelSemihard [A variation of semihard, take embedding vectors and multi-hot labels as input]
- Distance [Sampling Matters in Deep Embeddings Learning]
- ResNet50 [Deep Residual Learning for Image Recognition]
Metrics based on samples
- Recall@K
- R-Precision@K
- MAP@K
Created by Jun Xiang, email: [email protected] - feel free to contact me!