CoolFace
Apppublic

N00bML/ndvi-anomaly-detection

sourceHugging Faceapache-2.0updated 9mo agoView on Hugging Face
0likes
App README

๐ŸŒฟ 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

  1. 1.Upload an NDVI image in GeoTIFF (.tif) format
  2. 2.Click Submit to process
  3. 3.View the anomaly map showing:
  4. 4.๐ŸŸข Green areas: Normal, healthy vegetation
  5. 5.๐Ÿ”ด Red areas: Anomalous patterns (potential stress, disease, or damage)

๐Ÿ“Š How It Works

This application uses a custom-trained Isolation Forest model that:

  1. 1.Analyzes temporal patterns from 24 months of historical NDVI data
  2. 2.Compares your uploaded image against learned normal vegetation patterns
  3. 3.Identifies pixels that deviate significantly from expected values
  4. 4.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 application
  • โ€”isolation_forest_ndvi.pkl - Custom-trained Isolation Forest model
  • โ€”NDVI_Images/ - 24 training images (historical NDVI data)
  • โ€”requirements.txt - Python dependencies

๐Ÿ’ป Running Locally

Want to run this on your own machine?

bash
# 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](https://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

txt
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.