A generic, phased benchmarking pipeline for HuggingFace image-classification datasets. Computes structural quality, embedding-based, and (upcoming) model-training metrics for any dataset regardless of size, class count, or schema.
benchmark/
app.py # entry point — programmatic and CLI
config.py # PipelineConfig (infrastructure settings)
configs/
config.json # universal config file
core/
dataset_adapter.py # HF dataset loading + schema auto-detection
split_manager.py # stratified 70 / 15 / 15 splits
embedding_engine.py # DINOv2 inference + embedding cache
metrics/
structural/
class_imbalance/ # class distribution + entropy
exact_duplicate/ # MD5-based pixel-exact duplicate detection
resolution_consistency/ # image size and aspect ratio stats
near_duplicate/ # FAISS cosine similarity near-dup detection
diversity/
metadata_coverage/ # label × metadata contingency analysis
intra_class_diversity/ # mean L2 distance to per-class centroid
difficulty/
feature_separability/ # silhouette score + Davies-Bouldin index
output/
writer.py # incremental JSON report writer
run_benchmark.sbatch # SLURM job script for FARM @ UC Davis
Phase 1 — Structural Quality (no GPU required)
- Class Imbalance
- Exact Duplicate Detection
- Resolution Consistency
- Metadata Coverage
Phase 2 — Embedding-Based Metrics (GPU required, DINOv2)
- Near-Duplicate Detection (FAISS)
- Feature Separability (Silhouette + Davies-Bouldin)
- Intra-Class Diversity
Phase 3 — Model Training Metrics (coming soon)
Infrastructure settings live in benchmark/configs/config.json. The config is auto-discovered in this order:
$AGML_CONFIGenvironment variablebenchmark/config.jsonin the current working directory- Built-in defaults
Dataset-specific arguments (dataset name, column names) are passed at runtime, not stored in the config.
# Minimal — config auto-loaded
python3 -m benchmark.app \
--dataset Project-AgML/rice_leaf_disease_classification \
--phases 1 2
# Multi-config HF dataset
python3 -m benchmark.app \
--dataset Project-AgML/watermelon_disease_classification \
--hf-config-name raw \
--phases 1 2
# Dataset with explicit column names
python3 -m benchmark.app \
--dataset Project-AgML/banana_grade_variety_classification \
--label-col label --image-col image \
--metadata-cols variety scale \
--phases 1 2from benchmark.app import AgMLBenchmarkPipeline
pipeline = AgMLBenchmarkPipeline("Project-AgML/rice_leaf_disease_classification")
pipeline.run(phases=[1, 2])module load cuda/12
module load conda
conda activate agvlm
pip install -r benchmark/requirements.txtPre-download dataset and model from the login node before submitting (compute nodes may be offline):
export HF_HOME=/group/jmearlesgrp/$USER/hf
# Dataset
python -c "
from datasets import load_dataset
load_dataset('Project-AgML/rice_leaf_disease_classification', cache_dir='$HF_HOME')
"
# DINOv2 model (Phase 2)
python -c "
from transformers import AutoModel, AutoImageProcessor
AutoImageProcessor.from_pretrained('facebook/dinov2-base', cache_dir='$HF_HOME')
AutoModel.from_pretrained('facebook/dinov2-base', cache_dir='$HF_HOME')
"Edit the variables at the top of benchmark/run_benchmark.sbatch and submit:
sbatch benchmark/run_benchmark.sbatchLogs are written to logs/benchmark_<job_id>.out and .err.
Reasoning pipeline — a separate VLM-based visual reasoning dataset pipeline (
ag_vlm/) also lives in this repo. Documentation for that module is maintained separately.