Spaces:
Sleeping
A newer version of the Gradio SDK is available: 6.13.0
title: NDVI Anomaly Detection
emoji: πΏ
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 6.2.0
app_file: app.py
pinned: false
license: apache-2.0
πΏ NDVI Anomaly Detection
Detect vegetation anomalies in satellite imagery using Isolation Forest machine learning. This application monitors forest health by identifying unusual patterns in NDVI (Normalized Difference Vegetation Index) data from the Changa Manga Forest, Pakistan.
π Quick Start
- Upload an NDVI image in GeoTIFF (.tif) format
- Click Submit to process
- View the anomaly map showing:
- π’ Green areas: Normal, healthy vegetation
- π΄ Red areas: Anomalous patterns (potential stress, disease, or damage)
π How It Works
This application uses a custom-trained Isolation Forest model that:
- Analyzes temporal patterns from 24 months of historical NDVI data
- Compares your uploaded image against learned normal vegetation patterns
- Identifies pixels that deviate significantly from expected values
- Generates a color-coded anomaly map with statistics
Technical Details
- Algorithm: Isolation Forest (unsupervised anomaly detection)
- Training Data: 24 monthly NDVI images from Changa Manga Forest
- Input: Single-band GeoTIFF with NDVI values (-1.0 to 1.0)
- Output: Side-by-side comparison of original NDVI and anomaly map
- Model: Custom-trained using scikit-learn, saved as
isolation_forest_ndvi.pkl
π Use Cases
- Forest Health Monitoring: Detect areas of vegetation stress or disease
- Deforestation Detection: Identify unusual clearing patterns
- Agricultural Monitoring: Spot crop anomalies early
- Environmental Research: Track vegetation changes over time
- Climate Impact Studies: Monitor effects of weather events on vegetation
π οΈ About the Model
The Isolation Forest model was trained specifically for this project:
- Dataset: 24 months of NDVI satellite imagery
- Study Area: Changa Manga Forest, Pakistan
- Data Source: Google Earth Engine
- Framework: scikit-learn
- Training: Custom-trained on temporal patterns to learn normal vegetation behavior
The model identifies anomalies by isolating observations that are easier to separate from the rest of the data, making it ideal for detecting unusual vegetation patterns.
π Model Files
This Space includes:
app.py- Gradio interface applicationisolation_forest_ndvi.pkl- Custom-trained Isolation Forest modelNDVI_Images/- 24 training images (historical NDVI data)requirements.txt- Python dependencies
π» Running Locally
Want to run this on your own machine?
# Clone the repository
git clone https://github.com/NoobML/ndvi-anomaly-detection.git
cd ndvi-anomaly-detection
# Install dependencies
pip install -r requirements.txt
# Run the app
python app.py
π Full Documentation
For detailed documentation, training code, and more examples, visit the GitHub repository:
π github.com/NoobML/ndvi-anomaly-detection
The GitHub repo includes:
- Complete training scripts
- Data preprocessing code
- Google Earth Engine scripts for downloading NDVI data
- Detailed technical documentation
- Example datasets and outputs
- Troubleshooting guides
π― Example Results
The application provides:
- Visual Comparison: Original NDVI vs Anomaly Map
- Statistics: Number and percentage of anomalous pixels
- Color Coding: Intuitive red-green scale for easy interpretation
- High Resolution: Pixel-level anomaly detection
βοΈ Requirements
numpy
rasterio
matplotlib
scikit-learn
gradio
joblib
π Data Format
Input Requirements:
- Format: GeoTIFF (.tif)
- Bands: Single-band (NDVI only)
- Value Range: -1.0 to 1.0 (standard NDVI scale)
- Projection: Should match training data (ideally same study area)
Note: For best results, use NDVI images from similar geographic areas and time periods as the training data.
π Interpreting Results
Anomaly Map Colors:
- Dark Red: Strong anomaly (highly unusual pattern)
- Light Red/Orange: Mild anomaly
- Yellow: Borderline normal
- Light Green: Normal vegetation
- Dark Green: Very normal (matches historical patterns closely)
Statistics:
The app displays the percentage of anomalous pixels, helping you quantify the extent of unusual vegetation patterns.
π€ Contributing
Found a bug? Have a feature request?
- Report issues: GitHub Issues
- Contribute: Fork the repo and submit a pull request
- Discuss: Use the Community tab on this Space
π About the Study Area
Changa Manga Forest is one of the largest man-made forests in the world, located in Punjab, Pakistan. Monitoring its vegetation health is crucial for:
- Biodiversity conservation
- Climate regulation
- Local community livelihoods
- Research and education
π§ Contact
π License
This project is licensed under the Apache 2.0 License.
π Acknowledgments
- Data Source: Google Earth Engine
- ML Framework: scikit-learn
- Interface: Gradio by Hugging Face
- Study Area: Changa Manga Forest, Pakistan
β If you find this Space useful, please give it a like and share it with others interested in remote sensing and vegetation monitoring!
π Related Projects
Interested in satellite imagery analysis and environmental monitoring? Check out other Spaces and resources:
- Explore more on GitHub
- Learn about NDVI and remote sensing
- Discover Google Earth Engine for satellite data
This is a research and educational tool. For critical applications, results should be validated with ground truth data and expert analysis.