@@ -11,9 +11,9 @@ This repository contains (in parts) code that has been adapted from:
Remote sensing (RS) images are usually stored in compressed format to reduce the storage size of the archives. Thus, existing content-based image retrieval (CBIR) systems in RS require decoding images before applying CBIR (which is computationally demanding in the case of large-scale CBIR problems). To address this problem, in this paper, we present a joint framework that simultaneously learns RS image compression and indexing, eliminating the need for decoding RS images before applying CBIR. The proposed framework is made up of two modules. The first module aims at effectively compressing RS images. It is achieved based on an auto-encoder architecture. The second module aims at producing hash codes with a high discrimination capability. It is achieved based on a deep hashing method that exploits soft pairwise, bit-balancing and classification loss functions. We also propose a two stage learning strategy with gradient manipulation techniques to obtain image representations that are compatible with both RS image indexing and compression.
## Prerequisites
The code in this repository requires Python 3.7.6, pytorch 1.7.0 and ranger coder.
The code in this repository requires Python 3.10.4, pytorch 1.12.1.
The code is tested in Ubuntu 20.04.
The code is tested in Ubuntu 18.04.
An exemplary setup which contains everything needed:
```
...
...
@@ -24,129 +24,33 @@ An exemplary setup which contains everything needed:
Downloaded data should be placed in a folder named `Dataset` and keep the original structure as following:
Dataset
└───BigEarthNet
| └───S2A_MSIL2A_20170613T101031_0_48
| │ S2A_MSIL2A_20170613T101031_0_48_B0
| │ ...
| ...
|
└───...
> **Note**:
> The train/val/test splits of the dataset and its subsets are placed in ./hashing-and-compression/datasets.
>
> To load the data from `memory-map` files for fast processing, set the flag `--flag_npmem` to create and load binary files.
>
> To use the subset data, set the flag `--flag_subset`.
### Logging results with W&B
* 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 the training environment, set the flag `--wandb_dryrun` to make wandb store the data locally, and upload the data with the command `wandb sync <$path/wandb/offline..>`
* Set `--project`, `--group` and `--savename` during the training.
## Training
The training of the joint model is divided into two stages, the first stage is done by `train_compression.py`, and the second stage is done by `train.py`.
The training of the hashing baseline is done by `train_hashing.py`.
All the parameters are listed and explained in `parameters.py`.
A set of exemplary runs is provided in `./hashing-and-compression/sample_run`.
If the training is stopped accidentally, it can be resumed by setting `--load_from_checkpoint`, load the check point from `$save_path/every_epoch.pth.tar`.
### Common setups
The following are common setups for all the training scripts:
*`--source_path`: Path for the dataset, eg. `$path/Dataset`.