Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: ci

on: [push, pull_request, workflow_dispatch]
on:
push:
branches: [main]
pull_request:
workflow_dispatch:

jobs:
test:
Expand All @@ -9,7 +13,7 @@ jobs:

strategy:
matrix:
python-version: ["3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, macOs-latest]
fail-fast: false

Expand Down
155 changes: 32 additions & 123 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,177 +1,86 @@


# Byte-compiled / optimized / DLL files
# Python
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so
*.egg-info/
*.egg
.eggs/
MANIFEST

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt
sdist/

# Unit test / coverage reports
htmlcov/
# Testing & coverage
.pytest_cache/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
htmlcov/
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
# Type checkers & linters
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
.ruff_cache

# Mac OS files
.DS_Store
__MACOSX
.idea/
# Jupyter
.ipynb_checkpoints

# Benchmarking
**/lightning_logs
experiments/benchmarking/logs

# Extra directories/files
# Data directories (not source code)
/**data*/
*test*.*
!tests/
!tests/*/
!tests/**
**/__pycache__/

!tests/*/*
agml/_helios
agml/helios_config.sh
agml/train

# Controls for the `_internal` directory.
# agml/_internal: only specific files are tracked
agml/_internal/*
!agml/_internal/preprocess*.py
!agml/_internal/s3internal.py
!agml/_internal/__init__.py
!agml/_internal/utils.py

# Training
experiments/benchmarking/lightning_logs
experiments/benchmarking/logs
# Training outputs
agml/models/training/*.log
agml/models/training/*.err
agml/models/training/*.out
agml/models/training/*.csv
# .*/
/

# Project-specific
agml/_helios
agml/helios_config.sh
agml/train
*.pptx
.ruff_cache
*test*.*
image*.png
.challenges
.paper

# under development
# Under development
agml/data/augmentations/
agml/data/exporters/pascal_voc.py

# vs code settings
# IDEs & editors
.DS_Store
__MACOSX
.idea/
.vscode/
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ Heesup Yun
Mason Earles
Pranav Raja
Alexander Olenskyj
Jared Smith
2 changes: 1 addition & 1 deletion agml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.7.4"
__version__ = "0.8.0"
__all__ = ["data", "synthetic", "backend", "viz", "io"]


Expand Down
39 changes: 20 additions & 19 deletions agml/data/hf_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import List, Union

try:
from datasets import load_dataset, DatasetDict, Image, Sequence, Value, ClassLabel
from datasets import load_dataset, DatasetDict, Image, Sequence, ClassLabel
except ImportError:
raise ImportError(
"The `datasets` library is required to use the HuggingFaceDataLoader. "
Expand Down Expand Up @@ -66,24 +66,25 @@ def _setup_loader(self):

def _cast_features(self):
"""Infers and casts image-like columns to the HF Image type for automated decoding."""
for split_name in self._hf_dataset.keys():
ds = self._hf_dataset[split_name]
features = ds.features

if "image" in features and not isinstance(features["image"], Image):
ds = ds.cast_column("image", Image())

# A "mask" column is always a pixel map — cast unconditionally.
if "mask" in features and not isinstance(features["mask"], Image):
ds = ds.cast_column("mask", Image())
# Cast "label" only when it looks like image data (string path or binary bytes),
# not when it is a ClassLabel or a numeric scalar.
elif "label" in features and not isinstance(features["label"], Image):
label_feat = features["label"]
if isinstance(label_feat, Value) and label_feat.dtype in ("string", "binary", "large_binary"):
ds = ds.cast_column("label", Image())

self._hf_dataset[split_name] = ds
if isinstance(self._hf_dataset, DatasetDict):
splits = {name: self._hf_dataset[name] for name in self._hf_dataset.keys()}
for split_name, ds in splits.items():
self._hf_dataset[split_name] = self._cast_single(ds)
else:
self._hf_dataset = self._cast_single(self._hf_dataset)

def _cast_single(self, ds):
"""Casts image-like columns on a single Dataset."""
features = ds.features

if "image" in features and not isinstance(features["image"], Image):
ds = ds.cast_column("image", Image())

# A "mask" column is always a pixel map — cast unconditionally.
if "mask" in features and not isinstance(features["mask"], Image):
ds = ds.cast_column("mask", Image())

return ds

def split(self,
val_size: float = None,
Expand Down
1 change: 1 addition & 0 deletions agml/data/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import functools

from rich.console import Console
from rich.table import Table
import numpy as np

from agml.backend.config import data_save_path
Expand Down
2 changes: 1 addition & 1 deletion agml/utils/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def download_dataset(dataset_name, dest_dir, redownload=False):
"Loading datasets through the AgML S3 data loader is deprecated and will be "
"removed in a future release. Please use the Hugging Face data loader instead.",
DeprecationWarning,
stacklevel=2,
stacklevel=3,
)

# Connect to S3 and generate unsigned URL for bucket object
Expand Down
14 changes: 5 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ description = "A comprehensive library for agricultural deep learning"
authors = [{name = "UC Davis Plant AI and Biophysics Lab", email = "jmearles@ucdavis.edu"}]
maintainers = [{ name="Amogh Joshi", email="amnjoshi@ucdavis.edu"}]

license = {text = "Apache 2.0"}
license = "Apache-2.0"
license-files = ["LICENSE"]
readme = "README.md"
packages = [{include = "agml", from = "agml", exclude ='agml/_internal'}]
version = "0.7.4"
requires-python = ">=3.9"
version = "0.8.0"
requires-python = ">=3.10"
keywords = []
classifiers = [
"Development Status :: 4 - Beta",
Expand All @@ -23,7 +24,6 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand All @@ -43,15 +43,12 @@ dependencies = [
"opencv-python>=4.10.0.84",
"opencv-python-headless>=4.10.0.84",
"requests>=2.0.0",
"scikit-learn>=1.3.2",
"tqdm>=4.67.0",
"pyyaml>=6.0.2",
"albumentations>=1.4.18",
"dict2xml>=1.7.6",
"ipywidgets>=8.1.5",
"rich>=14.0.0",
"datasets",
"transformers"
]
[project.urls]

Expand All @@ -66,6 +63,7 @@ dependencies = [
dev = [
"boto3>=1.35.66",
"scikit-image>=0.21.0",
"scikit-learn>=1.3.2",
"shapely>=2.0.6",
"botocore>=1.35.66",
"pandas>=2.0.3",
Expand All @@ -76,7 +74,5 @@ dev = [
"mypy>=1.13.0",
"coverage>=7.6.1",
"interrogate>=1.7.0",
"datasets",
"transformers"
]

12 changes: 0 additions & 12 deletions requirements.txt

This file was deleted.

Loading
Loading