Skip to content

Detecting Leaf disease using a hierarchical vision transformer. Patch Embeddings -> Hierarchical Stages -> Feature Pyramid -> Efficiency Optimizations

License

Notifications You must be signed in to change notification settings

divital-coder/Leaf-Effects

Repository files navigation

Leaf Disease VIT - Hierarchical Vision Transformer

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.

Technical Architecture

The architecture follows a multi-stage design:

1. Patch Embedding

Initial tokenization of input images.

Patch Embedding

2. Hierarchical Stages

Stacked transformer blocks with progressive downsampling.

Hierarchical Stages

3. Feature Pyramid

Multi-scale output representations for downstream tasks.

Feature Pyramid

4. Efficiency Optimizations

Includes optimized attention mechanisms and memory-efficient implementation.

Efficiency Optimizations

Installation

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

Usage

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.

Run Experiments

You can run individual experiments using the scripts provided in each phase directory.

Pre-training:

cd phase3_pretraining && uv run python run_ssl_pretraining.py

Fine-tuning:

cd phase4_finetuning && uv run python main.py --config config.yaml

Analysis:

cd phase5_analysis_and_ablation && uv run python analyze_best_model.py

Model Comparison & Analysis

Use the analysis scripts to evaluate model performance and visualize features.

Feature Analysis:

uv run python phase5_analysis_and_ablation/visualize_features.py

Attention Analysis:

uv run python phase5_analysis_and_ablation/visualize_attention.py

Results

Feature Analysis

Feature Analysis

Training Convergence

Training Convergence

Transfer Learning Performance

Transfer Learning Performance

Ablation Studies

Ablation Studies

Attention Analysis

Attention Analysis

Note: Want to create a similar README.md? Follow the instructions in the Typst Configuration Readme Rendering Commands section.

Typst Configuration Readme Rendering Commands

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

About

Detecting Leaf disease using a hierarchical vision transformer. Patch Embeddings -> Hierarchical Stages -> Feature Pyramid -> Efficiency Optimizations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published