Note: This repository contains the implementation of the Hierarchical Vision Transformer for leaf disease detection. It includes code for pre-training, fine-tuning, and analysis. This is an active research project.
The architecture follows a multi-stage design:
Initial tokenization of input images.
Stacked transformer blocks with progressive downsampling.
Multi-scale output representations for downstream tasks.
Includes optimized attention mechanisms and memory-efficient implementation.
From the root of the repository, run:
git clone https://github.com/divital-coder/Leaf-Effects.git
cd Leaf-Effects
uv venv .venv
source .venv/bin/activate
uv pip install -r requirements.txt
The repository consists of several experiments (phases), each containing scripts to run specific stages of the pipeline:
phase3_pretraining- Self-supervised learning (SSL) pre-training experiment.phase4_finetuning- Fine-tuning on downstream tasks.phase5_analysis_and_ablation- Analysis, visualization, and robustness testing.
You can run individual experiments using the scripts provided in each phase directory.
Pre-training:
cd phase3_pretraining && uv run python run_ssl_pretraining.pyFine-tuning:
cd phase4_finetuning && uv run python main.py --config config.yamlAnalysis:
cd phase5_analysis_and_ablation && uv run python analyze_best_model.pyUse the analysis scripts to evaluate model performance and visualize features.
Feature Analysis:
uv run python phase5_analysis_and_ablation/visualize_features.pyAttention Analysis:
uv run python phase5_analysis_and_ablation/visualize_attention.pyNote: Want to create a similar README.md? Follow the instructions in the Typst Configuration Readme Rendering Commands section.
There are various make commands that may be helpful.
make format # Run black and isort
make lint # Run flake8, mypy, black --check, and isort --check
make test # Run tests
make clean # Clean up cache files
make readme