xinfereo: Deep Learning for EO Analysis Made Easy
xinfereo is a Python package designed to simplify the application of spatio-temporal deep learning models to Earth Observation (EO) data. It bridges the gap between common geospatial data structures like xarray Datasets and complex deep learning workflows, making advanced EO analysis more accessible to geoscientists and researchers.
Whether you’re working with pre-trained models for tasks like tree cover mapping or aiming to deploy your own custom solutions, xinfereo streamlines the process, handling many of the technical intricacies involved in model inference.
Key Goals:
Democratize Access: Lower the barrier to entry for using deep learning in EO.
Simplify Workflows: Abstract away complex data preparation and model execution steps.
Enable Scalability: Support for Dask allows processing of large EO datasets.
Promote Interoperability: Built around xarray and standard model formats like ONNX.
Key Features:
Seamless integration with xarray Datasets.
User-friendly EOInferencer class for applying pre-trained models.
Automatic retrieval and management of model parameters (e.g., ONNX files from online repositories like Zenodo).
Handles critical pre-processing steps: data conformance checks, normalization, temporal encoding, padding.
Supports both NumPy-backed (in-memory) and Dask-backed (scalable) xarray Datasets.
Uses a JSON-based schema for model metadata, inspired by the STAC Machine Learning Model (mlm) extension.
Getting Started
1. Installation
Install xinfereo directly from PyPI:
pip install xinfereo
2. Quick Example
Here’s a brief example of how to use xinfereo to run inference:
import xarray as xr
from xinfereo import EOInferencer, data
# 1. Load your Earth Observation data into an xarray.Dataset
# (e.g., a Sentinel-2 data cube)
ds = xr.open_dataset("path/to/your/datacube.nc") # Replace with your data path
# 2. Initialize the EOInferencer with a model medatada dictionary and ONNX model reference
infrs = EOInferencer(data.tcd_model_meta(), 'tcd_onnx_v0.2')
# 3. Run inference on your xarray Dataset
tcd_predictions = infrs.predict(ds)
# 4. 'tcd_predictions' is typically a NumPy array containing the model output
print("TCD Predictions shape:", tcd_predictions.shape)
# Further process or save your predictions as needed
Contents: