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.
https://github.com/project-agml/agml

Category: Consumption
Sub Category: Agriculture and Nutrition

Keywords

agriculture computer-vision dataset deep-learning image-classification object-detection pytorch semantic-segmentation synthetic-data

Keywords from Contributors

geocode virtualization

Last synced: about 3 hours ago
JSON representation

Repository metadata

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.

README.md


ðŸ‘ĻðŸŋ‍ðŸ’ŧðŸ‘ĐðŸ―â€ðŸ’ŧ🌈ðŸŠī Want to join the AI Institute for Food Systems team and help lead AgML development? ðŸŠī🌈ðŸ‘Đ🏞‍ðŸ’ŧðŸ‘ĻðŸŧ‍ðŸ’ŧ

We're looking to hire a postdoc with both Python library development and ML experience. Send your resume and GitHub profile link to jmearles@ucdavis.edu!


Overview

AgML is a comprehensive library for agricultural machine learning. Currently, AgML provides access to a wealth of public agricultural datasets for common agricultural deep learning tasks.

AgML supports both the TensorFlow and PyTorch machine learning frameworks.

To browse our latest datasets, view our full set of documentation, and compare model performance on your crops / tasks of interest, please visit project-agml.github.io.

Installation

To install the latest release of AgML, run the following command:

pip install agml

Quick Start

AgML datasets are hosted on the Hugging Face Hub under the Project-AgML organization. You can start off by using the HuggingFaceDataLoader to download and load a dataset directly into a native Hugging Face DatasetDict:

from agml.data import HuggingFaceDataLoader

# Load a dataset from the Hub
loader = HuggingFaceDataLoader("Project-AgML/apple_flower_segmentation")

# Load a specific config/subset (e.g. an augmented variant)
loader = HuggingFaceDataLoader("Project-AgML/apple_flower_segmentation", config="augmented")

HuggingFaceDataLoader automatically casts image-like columns (image, mask, and image-typed label columns) to the Hugging Face Image type for decoded pixel access.

You can split the dataset into train/val/test sets, with optional stratification across one or more columns:

dataset = loader.split(val_size=0.1, test_size=0.1, stratify_cols="label")
# Returns a DatasetDict with 'train', 'val', and 'test' splits

# Access the underlying DatasetDict at any time
dataset = loader.dataset

For any preprocessing, inference, or training beyond loading and splitting, use the datasets and transformers libraries directly. Since loader.dataset is a native Hugging Face DatasetDict, it works out of the box with datasets' map, filter, and with_transform methods for preprocessing, and with transformers' Trainer, Pipeline, and model classes for training and inference — there's no separate AgML-specific processing API to learn.

from transformers import AutoImageProcessor, AutoModelForImageClassification, Trainer

processor = AutoImageProcessor.from_pretrained("google/vit-base-patch16-224")
model = AutoModelForImageClassification.from_pretrained(
    "google/vit-base-patch16-224",
    num_labels=dataset["train"].features["label"].num_classes,
)

def preprocess(batch):
    batch["pixel_values"] = processor(batch["image"], return_tensors="pt")["pixel_values"]
    return batch

dataset = dataset.with_transform(preprocess)

trainer = Trainer(model=model, train_dataset=dataset["train"], eval_dataset=dataset["val"])
trainer.train()

Public Datasets

AgML contains a wide variety of public datasets from various locations across the world:

AgML Dataset World Map

Use the Dataset Search experience for filtering and previews. For programmatic filtering, agml.data.public_data_sources(...) supports task and modality filters.

iNatAg and iNatAg-mini

AgML provides an API with direct access to iNatAg (and iNatAg-mini), one of the world's largest collections of agricultural images dedicated for the task of image classification. Collectively, this dataset contains over 4 million images along with detailed species classificaations and enables access to a variety of large-scale agricultural machine learning tasks. You can instantiate the iNatAg (or iNatAg-mini, a smaller variant of iNatAg for smaller-scale applications) dataset as follows:

# To select a collection of scientific family names.
loader = agml.data.AgMLDataLoader.from_parent("iNatAg", filters={"family_name": ["...", "..."]})

# To select common names.
loader = agml.data.AgMLDataLoader.from_parent("iNatAg", filters={"common_name": "..."})

Usage Information

Using Public Agricultural Data

AgML aims to provide easy access to a range of existing public agricultural datasets The core of AgML's public data pipeline is AgMLDataLoader. You can use the AgMLDataLoader or agml.data.download_public_dataset() to download the dataset locally from which point it will be automatically loaded from the disk on future runs. From this point, the data within the loader can be split into train/val/test sets, batched, have augmentations and transforms applied, and be converted into a training-ready dataset (including batching, tensor conversion, and image formatting).

Annotation Formats

A core aim of AgML is to provide datasets in a standardized format, enabling the synthesizing of multiple datasets into a single training pipeline. Datasets on the Hugging Face Hub encode annotations as columns on the underlying Dataset/DatasetDict:

  • Image Classification: a label column of type ClassLabel.
  • Object Detection: an objects column, holding COCO-style bounding boxes (un-normlized [x_min, y_min, width, height]) and corresponding category IDs as a ClassLabel per image.
  • Semantic Segmentation: a mask column, a single-channel (L-mode) image the same size as the corresponding image.

Contributions

We welcome contributions! If you would like to contribute a new feature, fix an issue that you've noticed, or even just mention a bug or feature that you would like to see implemented, please don't hesitate to use the Issues tab to bring it to our attention.

See the contributing guidelines for more information, or the guide to contributing leaderboard results if you have benchmark results to add.

Funding

This project is partly funded by the National AI Institute for Food Systems.


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 1 day ago

Total Commits: 956
Total Committers: 35
Avg Commits per committer: 27.314
Development Distribution Score (DDS): 0.281

Commits in past year: 42
Committers in past year: 7
Avg Commits per committer in past year: 6.0
Development Distribution Score (DDS) in past year: 0.452

Name Email Commits
amogh7joshi j****n@g****m 687
Naitik Jain n****n@s****n 54
Mason Earles j****s@J****l 31
Jared Smith j****h@u****u 23
Mason Earles 2****s 21
Leandro G. Almeida l****a@g****m 18
Heesup Yun h****n@u****u 16
Dario Guevara d****a@u****u 13
smbanx s****x@g****m 10
eranario e****o@u****u 9
alexolenskyj a****j@u****u 9
Dario Guevara d****1@g****m 8
github-actions[bot] g****] 7
Mason Earles j****s@c****u 6
Pranav Raja p****a@p****n 5
Mason Earles j****s@c****u 5
hkaman7 h****r@g****m 4
dguevara d****a@a****u@v****u 3
pranavraja99 p****9@i****m 3
varunUCDavis v****a@u****u 3
Naitik n****1@g****m 2
Ooberaj y****k@c****u 2
Ooberaj y****k@c****u 2
Lars Lundqvist 1****V 2
Urmil Chandarana u****a@g****m 2
ctyeong c****g@g****m 2
ninjacat272 8****2 1
Mason Earles j****s@c****u 1
Ooberaj y****k@Y****l 1
Ooberaj y****k@c****u 1
and 5 more...

Committer domains:


Issue and Pull Request metadata

Last synced: 13 days ago

Total issues: 31
Total pull requests: 62
Average time to close issues: 28 days
Average time to close pull requests: 6 days
Total issue authors: 17
Total pull request authors: 17
Average comments per issue: 3.77
Average comments per pull request: 0.19
Merged pull request: 54
Bot issues: 0
Bot pull requests: 0

Past year issues: 3
Past year pull requests: 14
Past year average time to close issues: 4 days
Past year average time to close pull requests: 5 days
Past year issue authors: 3
Past year pull request authors: 7
Past year average comments per issue: 2.0
Past year average comments per pull request: 0.0
Past year merged pull request: 10
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/project-agml/agml

Top Issue Authors

  • ctyeong (7)
  • masonearles (4)
  • Vincent-WangCH (3)
  • StupiddCupid (3)
  • alexolenskyj (2)
  • cmbadgujar10 (1)
  • dariojavo (1)
  • andreaceruti (1)
  • Icecream-blue-sky (1)
  • Akshatha-Mohan (1)
  • sstiene (1)
  • xml94 (1)
  • boudiafA (1)
  • stardust-96 (1)
  • bradezard131 (1)

Top Pull Request Authors

  • amogh7joshi (21)
  • lalmei (10)
  • js2552 (7)
  • Ooberaj (5)
  • naitikjain3071 (3)
  • dariojavo (3)
  • eranario (2)
  • smbanx (2)
  • bharathsri272 (1)
  • alexolenskyj (1)
  • LasseQV (1)
  • ctyeong (1)
  • momtanu-ag (1)
  • hkaman7 (1)
  • pranavraja99 (1)

Top Issue Labels

  • bug (11)
  • synthetic (7)
  • enhancement (4)
  • dataset (3)
  • documentation (1)
  • question (1)

Top Pull Request Labels

  • enhancement (16)
  • release (9)
  • synthetic (5)
  • bug (5)
  • dataset (5)
  • documentation (4)
  • models (1)

Package metadata

proxy.golang.org: github.com/project-agml/agml

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/project-agml/agml#section-documentation
  • Licenses: apache-2.0
  • Latest release: v0.8.2 (published about 1 month ago)
  • Last Synced: 2026-11-29T18:01:27.566443Z (1 day ago)
  • Versions: 30
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Dependent packages count: 9.049%
    • Average: 9.627%
    • Dependent repos count: 10.204%
proxy.golang.org: github.com/Project-AgML/AgML

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/Project-AgML/AgML#section-documentation
  • Licenses: apache-2.0
  • Latest release: v0.8.3 (published 3 days ago)
  • Last Synced: 2026-11-29T18:01:27.763809Z (1 day ago)
  • Versions: 31
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Dependent packages count: 9.049%
    • Average: 9.627%
    • Dependent repos count: 10.204%

Dependencies

.github/workflows/ci.yml actions
  • actions/checkout v4 composite
  • astral-sh/setup-uv v3 composite
.github/workflows/release_draft.yml actions
  • release-drafter/release-drafter v6 composite
environment.yml conda
  • cmake
  • cuda
  • cuda-nvcc
  • cudatoolkit
  • gcc 12
  • glew
  • glfw
  • gxx
  • libgl
  • libglu
  • libx11-devel-cos6-x86_64
  • libxrandr-devel-cos6-x86_64
  • make
  • mesa-libgl-cos7-x86_64
  • mesa-libgl-devel-cos6-x86_64
  • pip
  • xorg-libx11
  • xorg-libxcursor
  • xorg-libxext
  • xorg-libxi
  • xorg-libxinerama
  • xorg-libxrandr
  • xorg-libxrender
uv.lock pypi
  • 130 dependencies
pyproject.toml pypi
  • albumentations >=1.4.18
  • dict2xml >=1.7.6
  • ipywidgets >=8.1.5
  • matplotlib >=3.7.5
  • numpy >=1.24.4
  • opencv-python >=4.10.0.84
  • opencv-python-headless >=4.10.0.84
  • pyyaml >=6.0.2
  • requests >=2.0.0
  • rich >=14.0.0
  • scikit-learn >=1.3.2
  • tqdm >=4.67.0

Score: -Infinity