CoolFace
Apppublic

AndreaTangL/dry-soil-reflectance-prediction

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

Soil Spectral Reflectance Prediction

This model predicts dry soil spectral reflectance from wet soil measurements using a deep learning approach. It processes spectral data from NaturaSpec measurements and transforms wet soil reflectance into predicted dry soil reflectance.

Model Description

  • —Model Type: Multi-layer Perceptron (MLP)
  • —Input: Wet soil spectral reflectance (2151 wavelengths from 350nm to 2500nm)
  • —Output: Predicted dry soil spectral reflectance
  • —Architecture:
  • —Input Layer: 2151 neurons
  • —Hidden Layers: 128, 64, 32 neurons with ReLU activation
  • —Output Layer: 2151 neurons

Usage

Installation

bash
pip install -r requirements.txt

Basic Usage

python
from tensorflow.keras.models import load_model
import joblib
import numpy as np

# Load the model and scaler
model = load_model('soil_simple_mlp_updated.h5')
scaler = joblib.load('soil_scaler_updated.pkl')

# Prepare your input data (wet soil reflectance)
# Should be a 1D array of 2151 values
input_data = your_wet_soil_data  # shape: (2151,)
input_scaled = scaler.transform(input_data.reshape(1, -1))

# Make prediction
predicted_dry = model.predict(input_scaled)[0]

Processing NaturaSpec Files

The model can process NaturaSpec .sed files directly:

python
from app import read_sed_file, normalize_to_white_panel, preprocess_data

# Read and process a sample
sample_df = read_sed_file('path_to_sample.sed')
white_panel_df = read_sed_file('path_to_white_panel.sed')
normalized_df = normalize_to_white_panel(sample_df, white_panel_df)
processed_df = preprocess_data(normalized_df)

# Make prediction
input_vector = processed_df["Smoothed Reflectance"].values.reshape(1, -1)
input_scaled = scaler.transform(input_vector)
predicted = model.predict(input_scaled)[0]

Data Format

  • —Input data should be spectral reflectance values across 2151 wavelengths
  • —Wavelength range: 350nm to 2500nm
  • —Values should be normalized using a white panel reference
  • —Data should be smoothed using Savitzky-Golay filter

Model Performance

The model has been trained and validated on a dataset of soil samples, with the following performance metrics:

  • —R² Score
  • —RMSE (Root Mean Square Error)
  • —Correlation Coefficient

Requirements

  • —Python 3.7+
  • —TensorFlow 2.8.0+
  • —NumPy 1.21.0+
  • —Pandas 1.3.0+
  • —SciPy 1.7.0+
  • —scikit-learn 0.24.0+
  • —Matplotlib 3.4.0+
  • —joblib 1.0.0+

Citation

If you use this model in your research, please cite:

bibtex
@misc{soil_spectral_prediction,
  author = {Your Name},
  title = {Soil Spectral Reflectance Prediction Model},
  year = {2024},
  publisher = {Hugging Face},
  journal = {Hugging Face Hub},
  howpublished = {\url{https://huggingface.co/your-username/soil-spectral-prediction}}
}

License

This model is released under the MIT License. See the LICENSE file for details.