Spaces:
Sleeping
Sleeping
File size: 6,107 Bytes
eb501c3 365e139 4280f7a 365e139 4280f7a 365e139 4280f7a 365e139 03ad78b 365e139 03ad78b 365e139 4280f7a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
---
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
1. Clone the repository
```bash
git clone https://github.com/yourusername/nature-nexus.git
cd nature-nexus
```
2. Create and activate a virtual environment (optional but recommended)
```bash
python -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
```
3. Install required dependencies
```bash
pip install -r requirements.txt
```
4. Download models
```bash
# Create models directory if it doesn't exist
mkdir -p models
```
### Running the Application
Launch the Streamlit application:
```bash
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
1. Select "Deforestation Detection" from the sidebar
2. Upload satellite or aerial imagery of forest areas
3. View segmentation results showing forest vs. deforested areas
4. Analyze metrics including forest coverage and deforestation level
### Audio Surveillance
1. Select "Forest Audio Surveillance" from the sidebar
2. Choose between uploading audio files or recording live audio
3. Submit the audio for analysis
4. View detected sound classification and potential alerts
### Object Detection
1. Select "Object Detection" from the sidebar
2. Choose between image, video, or camera feed
3. Adjust confidence and IoU thresholds as needed
4. Upload or capture input for processing
5. View detection results with bounding boxes and confidence scores
## Custom Model Training
To train custom models for your specific forest environment:
### Deforestation Model
```bash
# 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.
|