This project implements a hierarchical multiscale approach for image classification. The system currently uses a U-Net architecture with attention mechanisms and processes images at multiple scales to improve classification accuracy and robustness while reducing computational requirements. In the future, other architectures may also be utilized.
The multiscale approach works by:
- Processing images at multiple resolutions (scales 0, 1, 2, 3) to capture both fine-grained details and global patterns
- Using confidence-based scale selection to determine which scales are most informative for each image
- Fusing predictions from multiple scales using a learned fusion network
- Employing attention mechanisms to focus on the most relevant image regions
- Patch-wise processing to handle large images efficiently
multiscale-classification/
├── src/
│ ├── chest_xray_dataset.py
│ ├── config.py
│ └── unet.py
├── scripts/
│ ├── download_datasets.py
│ ├── inference.py
│ ├── run_multi_gpu_training.sh
│ └── train_all_scales_separately.py
├── data/
│ └── chest_xray/
│ ├── train/
│ │ ├── NORMAL/
│ │ └── PNEUMONIA/
│ ├── val/
│ │ ├── NORMAL/
│ │ └── PNEUMONIA/
│ └── test/
│ ├── NORMAL/
│ └── PNEUMONIA/
├── checkpoints/
│ ├── scale_0/
│ │ ├── scale_0_best.pth
│ │ └── scale_0_epoch_0.pth
│ ├── scale_1/
│ │ ├── scale_1_best.pth
│ │ └── scale_1_epoch_0.pth
│ ├── scale_2/
│ │ ├── scale_2_best.pth
│ │ └── scale_2_epoch_0.pth
│ └── scale_3/
│ ├── scale_3_best.pth
│ └── scale_3_epoch_0.pth
├── tests/ # Unit tests
├── visualizations/ # Visualizations
├── notebooks/ # Notebooks
├── logs/ # Training logs
├── htmlcov/ # Coverage reports
├── .venv/ # Virtual environment
├── .gitignore # Git ignore
├── .editorconfig # Editor config
├── pyproject.toml # Project configuration
├── setup.sh # Setup script
├── uv.lock # Lock file
├── Makefile # Makefile
└── README.md # This file
-
Weights & Biases (wandb):
- Visit wandb.ai to create a free account.
- Follow the instructions to set up your profile and obtain your API key.
-
Kaggle:
- Visit kaggle.com to sign up for a free account.
- Complete your profile setup and generate an API token for accessing datasets and competitions.
git clone https://github.com/AlexanderZeilmann/multiscale-classification
cd multiscale-classification
make setupmake downloadmake trainmake help # Show all available commands
make setup # Install dependencies using uv
make install # Install the package in development mode
make test # Run the test setup script
make download # Download the dataset
make train # Start the training
make clean # Clean up generated files
make format # Format code using black
make lint # Run linting checks
make dev # Run format, lint, and test
make info # Show project informationThe system expects the datsets to be organized in the following structure:
data/
├── chest_xray/
│ ├── train/
│ │ ├── NORMAL/ # Normal chest X-rays
│ │ └── PNEUMONIA/ # Pneumonia chest X-rays
│ ├── val/
│ │ ├── NORMAL/
│ │ └── PNEUMONIA/
│ └── test/
│ ├── NORMAL/
│ └── PNEUMONIA/
├── soon/
├── other/
└── datasets/