Spaces:
Sleeping
Sleeping
documentation
Browse files- Readme.md +202 -27
- imgs/audio.png +3 -0
- imgs/deforestation.png +3 -0
- imgs/yolo.png +3 -0
Readme.md
CHANGED
@@ -1,30 +1,205 @@
|
|
1 |
-
# Forest Surveillance System
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
## Directory Sturcture
|
4 |
```
|
5 |
-
|
6 |
-
|
7 |
-
βββ
|
8 |
-
βββ
|
9 |
-
β
|
10 |
-
β βββ fire_detection_model.onnx
|
11 |
-
β βββ audio_model.pth
|
12 |
βββ utils/
|
13 |
-
β βββ
|
14 |
-
β βββ
|
15 |
-
β βββ
|
16 |
-
β βββ
|
17 |
-
β βββ onnx_converter.py
|
18 |
-
β βββ
|
19 |
-
β
|
20 |
-
β
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Nature Nexus - Forest Surveillance System
|
2 |
+
|
3 |
+
## Overview
|
4 |
+
|
5 |
+
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.
|
6 |
+
|
7 |
+
The application leverages:
|
8 |
+
- **Satellite Imagery Analysis** - Detects deforestation using segmentation models
|
9 |
+
- **Audio Surveillance** - Identifies unusual sounds like chainsaws, vehicles, and human activity
|
10 |
+
- **Object Detection** - Recognizes trespassers, vehicles, fires, and other threats
|
11 |
+
|
12 |
+
## Features
|
13 |
+
|
14 |
+
### 1. Deforestation Detection
|
15 |
+
- Analyzes satellite or aerial imagery to identify deforested areas
|
16 |
+
- Uses Attention U-Net segmentation model optimized with ONNX runtime
|
17 |
+
- Provides detailed metrics on forest coverage and deforestation levels
|
18 |
+
- Visualizes results with color-coded overlays
|
19 |
+
|
20 |
+

|
21 |
+
|
22 |
+
### 2. Forest Audio Surveillance
|
23 |
+
- Detects unusual sounds that may indicate illegal activities
|
24 |
+
- Classifies various sounds including:
|
25 |
+
- **Human Sounds**: Footsteps, coughing, laughing, breathing, etc.
|
26 |
+
- **Tool Sounds**: Chainsaw, hand saw
|
27 |
+
- **Vehicle Sounds**: Car horn, engine, siren
|
28 |
+
- **Other Sounds**: Crackling fire, fireworks
|
29 |
+
- Supports both uploaded audio files and real-time recording
|
30 |
+
|
31 |
+

|
32 |
+
|
33 |
+
### 3. Object Detection
|
34 |
+
- Identifies potential threats using YOLOv11 model
|
35 |
+
- Detects objects including:
|
36 |
+
- Humans (trespassers)
|
37 |
+
- Vehicles (cars, bikes, buses/trucks)
|
38 |
+
- Fire and smoke
|
39 |
+
- Processes images, videos, and camera feeds
|
40 |
+
- Alerts on potential threats with confidence scores
|
41 |
+
|
42 |
+

|
43 |
+
|
44 |
+
## Getting Started
|
45 |
+
|
46 |
+
### Prerequisites
|
47 |
+
|
48 |
+
- Python 3.8+
|
49 |
+
- pip package manager
|
50 |
+
- Virtual environment (recommended)
|
51 |
+
|
52 |
+
### Installation
|
53 |
+
|
54 |
+
1. Clone the repository
|
55 |
+
```bash
|
56 |
+
git clone https://github.com/yourusername/nature-nexus.git
|
57 |
+
cd nature-nexus
|
58 |
+
```
|
59 |
+
|
60 |
+
2. Create and activate a virtual environment (optional but recommended)
|
61 |
+
```bash
|
62 |
+
python -m venv venv
|
63 |
+
source venv/bin/activate # On Windows, use: venv\Scripts\activate
|
64 |
+
```
|
65 |
+
|
66 |
+
3. Install required dependencies
|
67 |
+
```bash
|
68 |
+
pip install -r requirements.txt
|
69 |
+
```
|
70 |
+
|
71 |
+
4. Download models
|
72 |
+
```bash
|
73 |
+
# Create models directory if it doesn't exist
|
74 |
+
mkdir -p models
|
75 |
+
|
76 |
+
```
|
77 |
+
|
78 |
+
### Running the Application
|
79 |
+
|
80 |
+
Launch the Streamlit application:
|
81 |
+
```bash
|
82 |
+
streamlit run app.py
|
83 |
+
```
|
84 |
+
|
85 |
+
The application will open in your default web browser at http://localhost:8501
|
86 |
+
|
87 |
+
## Model Architecture
|
88 |
+
|
89 |
+
### Deforestation Detection Model
|
90 |
+
- **Architecture**: Attention U-Net
|
91 |
+
- **Input**: Satellite/aerial imagery (RGB)
|
92 |
+
- **Output**: Binary segmentation mask (forest vs. deforested)
|
93 |
+
- **Optimization**: ONNX runtime for faster inference
|
94 |
+
- **Dataset**: The model was trained using multiple datasets:
|
95 |
+
- **Amazon Rainforest Dataset for Semantic Segmentation** by Bragagnolo, Lucimara; da Silva, Roberto Valmir; Grzybowski, JosΓ© Mario Vicensi
|
96 |
+
- Contains 30 GeoTIFF training images (512x512 pixels) with PNG masks (forest in white, non-forest in black)
|
97 |
+
- 15 GeoTIFF validation images with masks
|
98 |
+
- 15 GeoTIFF test images
|
99 |
+
- **Amazon and Atlantic Forest Image Datasets for Semantic Segmentation** by the same creators
|
100 |
+
- Training dataset: 499 Amazon and 485 Atlantic Forest GeoTIFF images (512x512 pixels) with PNG masks
|
101 |
+
- Validation dataset: 100 GeoTIFF images per biome with masks
|
102 |
+
- Test dataset: 20 GeoTIFF images per biome
|
103 |
+
- **Forest Aerial Images for Segmentation** from Kaggle (https://www.kaggle.com/datasets/quadeer15sh/augmented-forest-segmentation)
|
104 |
+
- The 4-channel datasets were converted to 3-channel and merged
|
105 |
+
|
106 |
+
[Space for deforestation model architecture visualization]
|
107 |
+
|
108 |
+
### Audio Classification Model
|
109 |
+
- **Architecture**: Convolutional Neural Network (CNN)
|
110 |
+
- **Input**: Audio spectrograms
|
111 |
+
- **Output**: 14 sound classes with confidence scores
|
112 |
+
- **Features**: Mel-spectrogram analysis
|
113 |
+
- **Dataset**: **ESC-50: Dataset for Environmental Sound Classification**
|
114 |
+
- Contains various environmental sounds categorized for machine learning applications
|
115 |
+
- Used to train the model to recognize forest-relevant sounds including human activity, tools, vehicles, and natural sounds
|
116 |
+
|
117 |
+
[Space for audio model architecture visualization]
|
118 |
+
|
119 |
+
### Object Detection Model
|
120 |
+
- **Architecture**: YOLOv11
|
121 |
+
- **Input**: Images/video frames
|
122 |
+
- **Output**: Bounding boxes, class labels, confidence scores
|
123 |
+
- **Classes**: Humans, vehicles, fire, smoke, etc.
|
124 |
+
- **Dataset**: A merged collection of several datasets from Roboflow, optimized for detecting forest-relevant objects such as:
|
125 |
+
- Human presence (trespassers, loggers)
|
126 |
+
- Various vehicles (trucks, cars, motorcycles)
|
127 |
+
- Fire and smoke detection
|
128 |
+
- Logging equipment
|
129 |
+
|
130 |
+
[Space for YOLO model architecture visualization]
|
131 |
+
|
132 |
+
## System Architecture
|
133 |
|
|
|
134 |
```
|
135 |
+
nature-nexus/
|
136 |
+
β
|
137 |
+
βββ app.py # Main Streamlit application
|
138 |
+
βββ prediction_engine.py # Deforestation model interface
|
139 |
+
β
|
|
|
|
|
140 |
βββ utils/
|
141 |
+
β βββ audio_model.py # Audio classification model
|
142 |
+
β βββ audio_processing.py # Audio preprocessing utilities
|
143 |
+
β βββ helpers.py # Helper functions for visualization
|
144 |
+
β βββ model.py # U-Net model definition
|
145 |
+
β βββ onnx_converter.py # Converts PyTorch models to ONNX
|
146 |
+
β βββ onnx_inference.py # YOLO object detection inference
|
147 |
+
β βββ preprocess.py # Image preprocessing utilities
|
148 |
+
β
|
149 |
+
βββ models/ # Model weights (not included in repo)
|
150 |
+
βββ deforestation_model.onnx
|
151 |
+
βββ best_model.pth # Audio model
|
152 |
+
βββ best_model.onnx # YOLO model
|
153 |
+
```
|
154 |
+
|
155 |
+
## Usage Guide
|
156 |
+
|
157 |
+
### Deforestation Detection
|
158 |
+
1. Select "Deforestation Detection" from the sidebar
|
159 |
+
2. Upload satellite or aerial imagery of forest areas
|
160 |
+
3. View segmentation results showing forest vs. deforested areas
|
161 |
+
4. Analyze metrics including forest coverage and deforestation level
|
162 |
+
|
163 |
+
### Audio Surveillance
|
164 |
+
1. Select "Forest Audio Surveillance" from the sidebar
|
165 |
+
2. Choose between uploading audio files or recording live audio
|
166 |
+
3. Submit the audio for analysis
|
167 |
+
4. View detected sound classification and potential alerts
|
168 |
+
|
169 |
+
### Object Detection
|
170 |
+
1. Select "Object Detection" from the sidebar
|
171 |
+
2. Choose between image, video, or camera feed
|
172 |
+
3. Adjust confidence and IoU thresholds as needed
|
173 |
+
4. Upload or capture input for processing
|
174 |
+
5. View detection results with bounding boxes and confidence scores
|
175 |
+
|
176 |
+
## Custom Model Training
|
177 |
+
|
178 |
+
To train custom models for your specific forest environment:
|
179 |
+
|
180 |
+
### Deforestation Model
|
181 |
+
```bash
|
182 |
+
# Convert trained PyTorch model to ONNX
|
183 |
+
python -m utils.onnx_converter models/your_pytorch_model.pth models/deforestation_model.onnx [input_size]
|
184 |
+
```
|
185 |
+
|
186 |
+
### Audio Model
|
187 |
+
Train on your custom audio dataset and replace the model file at `models/best_model.pth`
|
188 |
+
|
189 |
+
### YOLO Model
|
190 |
+
Train on your custom object dataset and replace the model file at `models/best_model.onnx`
|
191 |
+
|
192 |
+
## Troubleshooting
|
193 |
+
|
194 |
+
### Common Issues
|
195 |
+
- **Models not loading**: Ensure all model files exist in the `models/` directory
|
196 |
+
- **CUDA errors**: If using GPU, verify CUDA and cuDNN are correctly installed
|
197 |
+
- **Audio processing issues**: Check audio format compatibility (WAV, MP3, OGG)
|
198 |
+
|
199 |
+
## Contributing
|
200 |
+
|
201 |
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
202 |
+
|
203 |
+
## License
|
204 |
+
|
205 |
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
imgs/audio.png
ADDED
![]() |
Git LFS Details
|
imgs/deforestation.png
ADDED
![]() |
Git LFS Details
|
imgs/yolo.png
ADDED
![]() |
Git LFS Details
|