Spaces:
Sleeping
A newer version of the Streamlit SDK is available:
1.48.1
title: Nature Nexus
emoji: π±
colorFrom: green
colorTo: blue
sdk: streamlit
app_file: app.py
pinned: false
Nature Nexus - Forest Surveillance System
Overview
Nature Nexus is an advanced forest surveillance system designed to protect natural ecosystems through AI-powered monitoring. It combines multiple detection technologies to identify illegal activities, monitor deforestation, and detect potential threats to forest areas.
The application leverages:
- Satellite Imagery Analysis - Detects deforestation using segmentation models
- Audio Surveillance - Identifies unusual sounds like chainsaws, vehicles, and human activity
- Object Detection - Recognizes trespassers, vehicles, fires, and other threats
Features
1. Deforestation Detection
- Analyzes satellite or aerial imagery to identify deforested areas
- Uses Attention U-Net segmentation model optimized with ONNX runtime
- Provides detailed metrics on forest coverage and deforestation levels
- Visualizes results with color-coded overlays
2. Forest Audio Surveillance
- Detects unusual sounds that may indicate illegal activities
- Classifies various sounds including:
- Human Sounds: Footsteps, coughing, laughing, breathing, etc.
- Tool Sounds: Chainsaw, hand saw
- Vehicle Sounds: Car horn, engine, siren
- Other Sounds: Crackling fire, fireworks
- Supports both uploaded audio files and real-time recording
3. Object Detection
- Identifies potential threats using YOLOv11 model
- Detects objects including:
- Humans (trespassers)
- Vehicles (cars, bikes, buses/trucks)
- Fire and smoke
- Processes images, videos, and camera feeds
- Alerts on potential threats with confidence scores
Getting Started
Prerequisites
- Python 3.8+
- pip package manager
- Virtual environment (recommended)
Installation
- Clone the repository
git clone https://github.com/yourusername/nature-nexus.git
cd nature-nexus
- Create and activate a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
- Install required dependencies
pip install -r requirements.txt
- Download models
# Create models directory if it doesn't exist
mkdir -p models
Running the Application
Launch the Streamlit application:
streamlit run app.py
The application will open in your default web browser at http://localhost:8501
Model Architecture
Deforestation Detection Model
- Architecture: Attention U-Net
- Input: Satellite/aerial imagery (RGB)
- Output: Binary segmentation mask (forest vs. deforested)
- Optimization: ONNX runtime for faster inference
Audio Classification Model
- Architecture: Convolutional Neural Network (CNN)
- Input: Audio spectrograms
- Output: 14 sound classes with confidence scores
- Features: Mel-spectrogram analysis
Object Detection Model
- Architecture: YOLOv11
- Input: Images/video frames
- Output: Bounding boxes, class labels, confidence scores
- Classes: Humans, vehicles, fire, smoke, etc.
System Architecture
nature-nexus/
β
βββ app.py # Main Streamlit application
βββ prediction_engine.py # Deforestation model interface
β
βββ utils/
β βββ audio_model.py # Audio classification model
β βββ audio_processing.py # Audio preprocessing utilities
β βββ helpers.py # Helper functions for visualization
β βββ model.py # U-Net model definition
β βββ onnx_converter.py # Converts PyTorch models to ONNX
β βββ onnx_inference.py # YOLO object detection inference
β βββ preprocess.py # Image preprocessing utilities
β
βββ models/ # Model weights (not included in repo)
βββ deforestation_model.onnx
βββ best_model.pth # Audio model
βββ best_model.onnx # YOLO model
Usage Guide
Deforestation Detection
- Select "Deforestation Detection" from the sidebar
- Upload satellite or aerial imagery of forest areas
- View segmentation results showing forest vs. deforested areas
- Analyze metrics including forest coverage and deforestation level
Audio Surveillance
- Select "Forest Audio Surveillance" from the sidebar
- Choose between uploading audio files or recording live audio
- Submit the audio for analysis
- View detected sound classification and potential alerts
Object Detection
- Select "Object Detection" from the sidebar
- Choose between image, video, or camera feed
- Adjust confidence and IoU thresholds as needed
- Upload or capture input for processing
- View detection results with bounding boxes and confidence scores
Custom Model Training
To train custom models for your specific forest environment:
Deforestation Model
# Convert trained PyTorch model to ONNX
python -m utils.onnx_converter models/your_pytorch_model.pth models/deforestation_model.onnx [input_size]
Audio Model
Train on your custom audio dataset and replace the model file at models/best_model.pth
YOLO Model
Train on your custom object dataset and replace the model file at models/best_model.onnx
Troubleshooting
Common Issues
- Models not loading: Ensure all model files exist in the
models/
directory - CUDA errors: If using GPU, verify CUDA and cuDNN are correctly installed
- Audio processing issues: Check audio format compatibility (WAV, MP3, OGG)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.