pokkiri commited on
Commit
0e330b9
·
verified ·
1 Parent(s): 86b98ed

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +129 -103
README.md CHANGED
@@ -1,132 +1,158 @@
1
- ---
2
- language: en
3
- license: mit
4
- library_name: pytorch
5
- tags:
6
- - biomass
7
- - remote-sensing
8
- - satellite-imagery
9
- - deep-learning
10
- - regression
11
- ---
12
 
13
- # StableResNet Biomass Prediction Model
 
 
14
 
15
- This model predicts above-ground biomass (AGB) from multi-spectral satellite imagery on a per-pixel basis.
16
 
17
- ## Model Description
18
 
19
- - **Developed by:** pokkiri
20
- - **Model type:** StableResNet
21
- - **Date:** 2025-05-17
22
- - **License:** MIT
23
 
24
- ### Input
 
 
 
 
 
 
25
 
26
- The model takes multi-spectral satellite data as input, processing features extracted from each pixel.
27
 
28
- ### Output
 
 
 
 
29
 
30
- The model outputs biomass predictions in Mg/ha (megagrams per hectare).
31
 
32
- ## Training Data
 
 
 
 
33
 
34
- The model was trained on multi-spectral satellite imagery from various forest regions, including:
35
- - Sentinel-1 (SAR)
36
- - Sentinel-2 (optical)
37
- - Landsat-8 (optical)
38
- - PALSAR (SAR)
39
 
40
- Ground truth biomass measurements were derived from field measurements.
 
 
 
 
41
 
42
- ## Performance
43
 
44
- The model achieves strong performance in predicting biomass across diverse landscapes:
45
- - RMSE: ~25 Mg/ha
46
- - R²: ~0.90
47
- - MAE: ~18 Mg/ha
48
 
49
- ## Training Procedure
50
 
51
- The model was trained with:
52
- - MSE loss function
53
- - Adam optimizer with learning rate 0.001
54
- - Early stopping based on validation performance
55
- - Log transformation for target values to stabilize training
56
 
57
- ## How to Use
58
 
59
  ```python
60
- from huggingface_hub import hf_hub_download
61
- import torch
62
- import joblib
63
- import numpy as np
64
- from model import StableResNet
65
-
66
- # Download model files
67
- model_path = hf_hub_download(repo_id="pokkiri/biomass-model", filename="model.pt")
68
- package_path = hf_hub_download(repo_id="pokkiri/biomass-model", filename="model_package.pkl")
69
-
70
- # Load model and package
71
- package = joblib.load(package_path)
72
- model = StableResNet(n_features=package['n_features'])
73
- model.load_state_dict(torch.load(model_path, map_location="cpu"))
74
- model.eval()
75
-
76
- # Example inference function
77
- def predict_biomass(features):
78
- # Scale features
79
- features_scaled = package['scaler'].transform(features)
80
-
81
- # Convert to tensor
82
- tensor = torch.tensor(features_scaled, dtype=torch.float32)
83
-
84
- # Make prediction
85
- with torch.no_grad():
86
- output = model(tensor).numpy()
87
-
88
- # Convert from log scale if needed
89
- if package.get('use_log_transform', True):
90
- output = np.exp(output) - package.get('epsilon', 1.0)
91
- output = np.maximum(output, 0) # Ensure non-negative
92
-
93
- return output
94
-
95
- # Example: predict for a single pixel with features
96
- example_features = np.random.rand(1, package['n_features']) # Replace with actual features
97
- biomass = predict_biomass(example_features)
98
- print(f"Predicted biomass: {biomass[0]:.2f} Mg/ha")
99
-
100
-
101
-
102
- For GeoTIFF processing, use the included inference.py:
103
-
104
- ``` Python
105
- from inference import predict_from_geotiff
106
-
107
- # Process a multi-band satellite image
108
- biomass_map = predict_from_geotiff(
109
- "satellite_image.tif",
110
- "output_biomass.tif",
111
- repo_id="pokkiri/biomass-model"
112
- )
113
 
 
 
 
 
 
 
 
 
 
 
114
  ```
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  ## Limitations
117
 
118
- - The model performs best on forest types similar to those in the training data
119
- - Very high biomass values (>500 Mg/ha) may be underestimated
120
- - Requires calibrated multi-spectral satellite imagery as input
 
 
 
121
 
122
- @## Citation
123
 
124
  ```
125
- @misc{biomass_model,
126
- author = {pokkiri},
127
- title = {StableResNet Biomass Prediction Model},
128
  year = {2025},
129
  publisher = {HuggingFace},
130
- howpublished = {https://huggingface.co/pokkiri/biomass-model}
 
131
  }
132
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Biomass Prediction Model
 
 
 
 
 
 
 
 
 
 
2
 
3
+ [![Open In Spaces](https://img.shields.io/badge/🤗-Open%20In%20Spaces-blue.svg)](https://huggingface.co/spaces/vertify/biomass-prediction)
4
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
 
7
+ ## Overview
8
 
9
+ This model predicts above-ground biomass (AGB) in forest ecosystems using multi-spectral satellite imagery. Developed by vertify.earth for the GIZ Forest Forward initiative, this tool supports sustainable forest management and carbon monitoring efforts. Biomass estimation is a critical component for carbon stock assessment, ecosystem monitoring, and sustainable forest management.
10
 
11
+ ## Model Details
 
 
 
12
 
13
+ - **Model Type**: StableResNet (Custom PyTorch architecture)
14
+ - **Task**: Regression (Biomass prediction in Mg/ha)
15
+ - **Input**: Multi-spectral satellite imagery (GeoTIFF format)
16
+ - **Output**: Biomass heatmap and statistics
17
+ - **Creator**: vertify.earth
18
+ - **Partner**: GIZ Forest Forward initiative
19
+ - **Date**: May 16, 2025
20
 
21
+ ## Key Features
22
 
23
+ - **Multi-source Fusion**: Combines data from multiple satellite sensors (Sentinel-1, Sentinel-2, Landsat-8, PALSAR)
24
+ - **Advanced Feature Engineering**: Calculates spectral indices, texture features, and spatial context features
25
+ - **Stable Architecture**: Uses ResNet-inspired architecture with numerical stability improvements
26
+ - **Interactive Visualization**: Provides heatmaps and RGB overlays of biomass predictions
27
+ - **Comprehensive Statistics**: Calculates mean, median, min, max, and total biomass for the analyzed area
28
 
29
+ ## Performance
30
 
31
+ | Metric | Log Scale | Original Scale |
32
+ |--------|-----------|----------------|
33
+ | R² | 0.87 | 0.83 |
34
+ | RMSE | 0.32 log(Mg/ha) | 28.7 Mg/ha |
35
+ | MAE | 0.25 log(Mg/ha) | 19.5 Mg/ha |
36
 
37
+ ## Use Cases
 
 
 
 
38
 
39
+ - **Carbon Stock Assessment**: Estimate carbon sequestration in forests
40
+ - **Biodiversity Monitoring**: Monitor forest structure as a proxy for habitat quality
41
+ - **Sustainable Forestry**: Plan and monitor sustainable timber harvesting
42
+ - **Land Use Change**: Detect and quantify forest degradation and regrowth
43
+ - **Climate Change Research**: Monitor changes in biomass over time
44
 
45
+ ## Usage
46
 
47
+ ### Gradio App
 
 
 
48
 
49
+ The easiest way to use this model is through the provided Gradio interface:
50
 
51
+ 1. Upload a multi-band satellite image in GeoTIFF format
52
+ 2. Select visualization type (heatmap or RGB overlay)
53
+ 3. Click "Generate Biomass Prediction"
54
+ 4. View the biomass map and statistics
 
55
 
56
+ ### API Usage
57
 
58
  ```python
59
+ import requests
60
+ import io
61
+ from PIL import Image
62
+
63
+ # API endpoint
64
+ API_URL = "https://api-inference.huggingface.co/models/vertify/biomass-prediction"
65
+ headers = {"Authorization": f"Bearer {API_TOKEN}"}
66
+
67
+ def predict_biomass(filename):
68
+ with open(filename, "rb") as f:
69
+ data = f.read()
70
+ response = requests.post(API_URL, headers=headers, data=data)
71
+ return response.json()
72
+
73
+ # Example usage
74
+ result = predict_biomass("path/to/your/satellite_image.tif")
75
+ ```
76
+
77
+ ### Local Installation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
+ ```bash
80
+ # Clone the repository
81
+ git clone https://huggingface.co/vertify/biomass-prediction
82
+ cd biomass-prediction
83
+
84
+ # Install dependencies
85
+ pip install -r requirements.txt
86
+
87
+ # Run the Gradio app
88
+ python app.py
89
  ```
90
 
91
+ ### Inference Script
92
+
93
+ This repository includes a full inference script (`predict_biomass.py`) that allows you to process satellite imagery in batch mode and generate biomass maps:
94
+
95
+ ```bash
96
+ # Example usage
97
+ python predict_biomass.py --input_dir /path/to/satellite_images --output_dir /path/to/output --visualization_type heatmap
98
+ ```
99
+
100
+ For full documentation on the inference script options, see the script header or run:
101
+ ```bash
102
+ python predict_biomass.py --help
103
+ ```
104
+
105
+ ## Full Training Pipeline
106
+
107
+ The complete training pipeline, including data preprocessing, feature engineering, model training, and evaluation is available in our [GitHub repository](https://github.com/vertify/biomass-prediction-training). Please refer to the GitHub repository for detailed documentation on training your own biomass prediction models.
108
+
109
+ ## Input Data Requirements
110
+
111
+ For optimal results, your satellite imagery should include:
112
+
113
+ - **Optical bands**: Blue, Green, Red, Near Infrared (NIR), SWIR1, SWIR2
114
+ - **Radar bands**: Sentinel-1 VV, VH polarizations (if available)
115
+ - **DEM**: Digital Elevation Model (if available)
116
+ - **Format**: GeoTIFF with proper georeferencing
117
+
118
+ The model has been trained on data from various forest types including tropical, temperate, and boreal forests, making it adaptable to different ecosystems.
119
+
120
  ## Limitations
121
 
122
+ - Performance may vary in extremely dense forests (>500 Mg/ha) due to saturation effects
123
+ - Model accuracy depends on the quality and consistency of input satellite data
124
+ - Cloud cover in optical imagery can reduce prediction quality
125
+ - Limited validation in certain ecosystem types (e.g., mangroves, wetlands)
126
+
127
+ ## Citation
128
 
129
+ If you use this model in your research, please cite:
130
 
131
  ```
132
+ @misc{vertify2025biomass,
133
+ author = {vertify.earth},
134
+ title = {Biomass Prediction Model Using Multi-spectral Satellite Imagery},
135
  year = {2025},
136
  publisher = {HuggingFace},
137
+ note = {Developed for GIZ Forest Forward initiative},
138
+ howpublished = {\url{https://huggingface.co/spaces/vertify/biomass-prediction}}
139
  }
140
+ ```
141
+
142
+ ## License
143
+
144
+ This project is licensed under the MIT License - see the LICENSE file for details.
145
+
146
+ ## Acknowledgements
147
+
148
+ - Project developed by vertify.earth for the GIZ Forest Forward initiative
149
+ - Training data sources include field measurements from various research institutions
150
+ - Satellite imagery from ESA Copernicus Programme (Sentinel-1, Sentinel-2) and NASA/USGS (Landsat-8)
151
+ - Special thanks to the open-source community for tools and libraries used in this project
152
+
153
+ ## Contact
154
+
155
+ For questions, feedback, or collaboration opportunities, please reach out via:
156
+ - HuggingFace: [@vertify](https://huggingface.co/vertify)
157
+ - GitHub: [vertify](https://github.com/vertify)
158
+ - Email: info@vertify.earth