This library facilitates the classification of optical remote sensing images using advanced deep learning models such as Vision Transformer (ViT), Swin Transformer (SwinViT), etc... This library also facilitates the automatic downloading of remote sensing datasets like Million AID and arranges them in the directory structure as shown below. It’s designed to be modular and extendable, enabling easy integration of additional datasets, models, and training strategies.
- Clone the repository:
git clone https://github.com/pranavsingla/SwinViT_GNR650.git
cd remote-sensing-library
- Install dependencies:
pip install -r requirements.txt
- Dataset Preparation: The dataset manager supports any directory structure compatible with PyTorch’s ImageFolder. Organize images into folders by class name under a main directory. Example:
data/
├── train/
│ ├── class_1/
│ ├── class_2/
│ └── ...
└── val/
├── class_1/
├── class_2/
└── ...
To train a model, run the following command:
python main.py --config path/to/config.yaml
Below is an example configuration file, which you can modify based on your training requirements:
dataset:
data_dir: "path/to/dataset"
batch_size: 32
model:
name: "swinvit"
pretrained_model: "microsoft/swin-tiny-patch4-window7-224"
training:
epochs: 20
lr: 0.001
device: "cuda"
dataset
: Details on dataset location and parameters.model
: Choose between "vit" or "swinvit", and specify a pretrained model path if desired.training
: Define the number of epochs, learning rate, and the computing device.
To add a new dataset:
- Create a new Python file in the
datasets/
folder. - Implement a data-loading class similar to
DatasetManager
indatasets/million_aid.py
. - Add any dataset-specific preprocessing as needed.
- Create a new Python file in the
models/
folder for the model architecture. - Implement a class that initializes the model and defines its forward pass.
- Import and register the model in
models/__init__.py
.
We welcome contributions to enhance the functionality of this library. To contribute:
- Fork the repository and clone your forked version locally.
- Create a new branch for your feature or bug fix:
git checkout -b feature/new-feature
- Add your changes in the relevant files. Ensure new features are well-documented and modular.
- Run tests to validate your changes (test scripts coming soon).
- Commit your changes and push to your forked repository:
git add .
git commit -m "Add feature/new-feature"
git push origin feature/new-feature
- Open a pull request to the main repository.
- Follow the structure of existing modules for consistency.
- Write clear, concise comments and docstrings for new functions and classes.
- Ensure new code adheres to PEP8 standards.
If you encounter any bugs or have suggestions, please open an issue on GitHub.
To package and distribute the library:
- Modify the
setup.py
(add if missing) to define the package information and dependencies. - Run the following command to build the package:
python setup.py sdist bdist_whee
- Use PyPI or a private repository to distribute.
To deploy in a cloud environment like AWS or GCP:
- Create a cloud VM with a GPU if training on a large dataset.
- Set up the environment by following the Setup steps.
- Upload your dataset to cloud storage or directly to the VM.
- Run training by executing:
nohup python main.py --config path/to/config.yaml &
This runs the training in the background, enabling you to log out without interrupting the process.
- Build a Dockerfile that includes necessary dependencies, GPU support, and entry points for training.
- Build and run the Docker container with:
docker build -t remote-sensing-library .
docker run --gpus all -v $(pwd)/data:/data -it remote-sensing-library
This project is licensed under the MIT License. See the LICENSE file for details.