Project-AgML/AgML

AgML is a centralized framework for agricultural machine learning. AgML provides access to public agricultural datasets for common agricultural deep learning tasks, with standard benchmarks and pretrained models, as well the ability to generate synthetic data and annotations.

What it solves

AgML tackles the friction of working with agricultural machine-learning data. Researchers and developers often have to hunt down scattered public datasets, deal with inconsistent annotation formats, and write custom code to load and split data. AgML centralizes access to a wide range of public agricultural datasets, standardizes their annotation formats, and provides easy loaders for both common ML frameworks (TensorFlow and PyTorch) plus agricultural statistics from sources like USDA NASS and California county-level benchmarks.

How it works

AgML hosts its datasets on the Hugging Face Hub under the Project-AgML organization. The HuggingFaceDataLoader downloads and loads a dataset directly into a native Hugging Face DatasetDict, automatically casting image-like columns to the Image type. You can split into train/val/test with optional stratification, then use the standard datasets and transformers libraries for preprocessing, training, and inference — no AgML-specific processing API needed.

For very large image-text-to-text datasets (e.g., AgroOmni) that don't fit the standard archive handling, AgML provides loadImageTextToTextDataset, which reads images lazily from zip shards using a shared path-to-shard index, avoiding full extraction and caching bytes on first access.

AgML also includes agml.ag_stats, a subpackage for agricultural statistics. agml.ag_stats.nass queries USDA NASS crop statistics (yield, area, production, progress, condition) at national/state/district/county levels, returning pandas, polars, arrow, or CSV/parquet. agml.ag_stats.calicropyield reads the California Crop Yield Benchmark, providing county-level yield, satellite, climate, and soil rasters as xarray objects. Each source is an optional extra install.

Who it's for

Agricultural machine-learning researchers, data scientists, and developers who need quick, standardized access to public agricultural datasets and statistics — whether for image classification, object detection, semantic segmentation, or large-scale multimodal tasks. It's also useful for anyone building models that combine crop imagery with tabular statistics, and for those who want to avoid reinventing data-loading pipelines.

Highlights

  • One library for many public agricultural datasets, with consistent annotation formats (ClassLabel for classification, COCO-style boxes for detection, single-channel masks for segmentation).
  • Works directly with Hugging Face datasets and transformers, so you can use standard preprocessing, Trainer, and pipelines without learning a new API.
  • Supports both TensorFlow and PyTorch.
  • Lazy loading and caching for huge image-text-to-text datasets, avoiding full extraction and reducing memory use.
  • Agricultural statistics loaders for USDA NASS (US-wide crop data) and California Crop Yield Benchmark (county-level yield with satellite, climate, and soil layers).
  • Optional extras keep the install light — only pull in the statistics sources you need.
  • Programmatic dataset filtering by task and modality, plus a web-based Dataset Search for browsing and previews.

Related

  • Project
  • Project
  • Project
  • Project
  • Project