Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ yarn.lock

performance_staging/
.claude/

# Local, per-user working files (e.g. private/datasets_to_ingest.json from export-dataset-candidates)
private/
90 changes: 90 additions & 0 deletions docs/contributing-models.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
title: Contributing External Models
sidebar_position: 6
---

## Contributing External Models

The [Models](/models) page lists **open-weight agricultural models hosted by their authors**. AgML does not
download, host, or redistribute them, and they are not loadable through the `agml` package. The page points to
where the weights are published, sorts models by task and crop the same way as the [dataset browser](/datasets),
and shows performance **as reported by the original source**.

### Ground rules

- **Not benchmarked by AgML.** Every entry carries `"agml_benchmarked": false` and a `verification` value. The site
and the [agml-agent harness](https://github.com/Project-AgML/agml-harness) both show a *not benchmarked by AgML /
unverified metrics* flag for these entries. Only set `agml_verified` once AgML has re-run the evaluation itself.
- **Separate from the leaderboard.** Source-reported numbers live only in `static/data/models.json`. Never add them to
`static/data/performance/`: splits and protocols differ, so the numbers are not comparable.
- **Copy, don't compute.** Metrics are transcribed exactly from the cited source (model card, paper table, README)
and stored as fractions in `[0, 1]`. Every result row needs a `source_url`. If a number can't be read reliably
(paywall, conflicting secondary sources), leave `reported_results` empty and use
`"verification": "metrics_not_transcribed"`. Don't guess.
- **Describe the data.** For each training / evaluation dataset, say what it contains (crop, classes, sensor,
platform, location, size) so users can judge whether the model fits their conditions.
- **Link to AgML datasets.** Set `agml.status` for each dataset:

| `agml.status` | Meaning |
| :--- | :--- |
| `in_agml` | The same source dataset is in AgML. List its AgML name(s) in `agml.names`. |
| `related_in_agml` | A related or possibly identical dataset is in AgML (e.g. a Meta-Album subset of PlantVillage). List it and explain in `agml.note`. |
| `not_in_agml` | A public dataset that AgML does not host. |
| `not_public` | Private or unreleased data. |
| `not_applicable` | Out of AgML's scope (e.g. a general biodiversity pretraining corpus). |

### Entry format

Each element of `models` in [`static/data/models.json`](https://github.com/Project-AgML/project-agml.github.io/tree/main/static/data/models.json):

```json
{
"id": "deepweeds-baselines",
"name": "DeepWeeds ResNet-50 / Inception-v3",
"publisher_type": "peer_reviewed",
"machine_learning_task": "image_classification",
"agricultural_tasks": ["weed_classification"],
"crop_types": ["rangeland", "weeds"],
"license": "Apache-2.0 (code); CC BY 4.0 (images and annotations)",
"links": { "weights": "https://…", "code": "https://…", "paper": "https://doi.org/…", "demo": null, "model_card": null },
"agml_benchmarked": false,
"verification": "source_reported",
"reported_results": [
{
"variant": "ResNet-50",
"setting": "fine-tuned",
"eval_dataset": "deepweeds",
"split": "5-fold cross-validation",
"metrics": { "accuracy": 0.957 },
"primary_metric": "accuracy",
"source": "Paper abstract",
"source_url": "https://doi.org/10.1038/s41598-018-38343-3"
}
],
"datasets": [
{
"id": "deepweeds",
"name": "DeepWeeds",
"roles": ["train", "eval"],
"description": "17,509 images of eight weed species …",
"link": "https://github.com/AlexOlsen/DeepWeeds",
"agml": { "status": "in_agml", "names": ["DeepWeeds_classification"], "note": null }
}
],
"reproduction": { "status": "fully_reproducible", "notes": "…", "code_url": "https://…", "commands": ["…"] }
}
```

`publisher_type` is `peer_reviewed` (released with a paper), `institutional` (a lab or organization release without a paper), or `community` (an individual upload); the Models page filters on it.

`machine_learning_task` uses the dataset vocabulary (`image_classification`, `object_detection`,
`semantic_segmentation`, …). `agricultural_tasks` and `crop_types` reuse the dataset browser's values where they
exist (e.g. `disease_classification`, `weed_detection`; lowercase crop names). `setting` describes how the number
was produced: `zero-shot`, `fine-tuned`, `linear-probe`, `few-shot (1-shot)`, and so on.

### Validation

`npm run validate-models` runs before every `npm start` / `npm run build` and fails on, among other things: an
`agml.names` entry that isn't a real AgML dataset, a metric stored as a percentage, a result without a
`source_url`, or `agml_benchmarked` disagreeing with `verification`. `npm run test:unit` also checks the published
catalog.
1 change: 1 addition & 0 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const config: Config = {
label: 'Docs',
},
{to: '/datasets', label: 'Datasets', position: 'left'},
{to: '/models', label: 'Models', position: 'left'},
{to: '/leaderboard', label: 'Leaderboard', position: 'left'},
{
href: 'https://github.com/Project-AgML/AgML',
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.0.0",
"private": true,
"scripts": {
"prebuild": "npm run generate-datasets && npm run generate-embeddings",
"prestart": "npm run generate-datasets && npm run generate-embeddings",
"prebuild": "npm run validate-models && npm run generate-datasets && npm run generate-embeddings",
"prestart": "npm run validate-models && npm run generate-datasets && npm run generate-embeddings",
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
Expand All @@ -18,7 +18,9 @@
"generate-datasets": "node scripts/generate-datasets.mjs",
"generate-embeddings": "node scripts/generate-embeddings.mjs",
"test": "node --import tsx --test tests/*.test.mjs tests/*.test.ts",
"test:unit": "node --import tsx --test tests/generate-embeddings.test.mjs tests/semantic-search-index.test.ts"
"test:unit": "node --import tsx --test tests/generate-embeddings.test.mjs tests/semantic-search-index.test.ts tests/models.test.ts",
"validate-models": "node scripts/validate-models.mjs",
"export-dataset-candidates": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON scripts/export-dataset-candidates.mjs"
},
"dependencies": {
"@docusaurus/core": "3.10.1",
Expand Down
76 changes: 76 additions & 0 deletions scripts/export-dataset-candidates.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Builds the INTERNAL ingestion list: public datasets that catalogued external models use but AgML
// does not host (agml.status = "not_in_agml" in static/data/models.json).
// Ingestion planning is private — nothing here is published. Output and notes live in the
// gitignored private/ folder:
// private/ingestion_notes.json hand-kept notes (dataset_notes by dataset id, agml_followups)
// private/datasets_to_ingest.json generated; your `status` edits are kept across reruns
//
// npm run export-dataset-candidates [-- output.json]
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { normalizeCatalog } from '../src/lib/modelCatalog.ts';

const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const privateDir = path.join(projectRoot, 'private');
const modelsPath = path.join(projectRoot, 'static', 'data', 'models.json');
const notesPath = path.join(privateDir, 'ingestion_notes.json');
const outPath = path.resolve(process.argv[2] ?? path.join(privateDir, 'datasets_to_ingest.json'));

function readJson(filePath, fallback) {
return fs.existsSync(filePath) ? JSON.parse(fs.readFileSync(filePath, 'utf8')) : fallback;
}

const catalog = normalizeCatalog(readJson(modelsPath, {}));
const notes = readJson(notesPath, { dataset_notes: {}, agml_followups: [] });
const previous = new Map((readJson(outPath, { candidates: [] }).candidates ?? []).map((entry) => [entry.id, entry]));

const byId = new Map();
for (const model of catalog.models) {
for (const ref of model.datasets) {
if (ref.agml.status !== 'not_in_agml') continue;
const entry = byId.get(ref.id) ?? {
id: ref.id,
name: ref.name,
link: ref.link,
license: ref.license,
description: ref.description,
public_note: ref.agml.note,
internal_notes: notes.dataset_notes?.[ref.id] ?? [],
used_by: [],
status: previous.get(ref.id)?.status ?? 'todo',
};
entry.used_by.push({
id: model.id,
name: model.name,
roles: ref.roles,
machine_learning_task: model.machine_learning_task,
publisher_type: model.publisher_type,
});
byId.set(ref.id, entry);
}
}
const candidates = Array.from(byId.values()).sort(
(a, b) => b.used_by.length - a.used_by.length || a.name.localeCompare(b.name)
);
// Entries you were tracking whose dataset left the catalog (or got into AgML) are kept, flagged.
const dropped = Array.from(previous.values())
.filter((entry) => !byId.has(entry.id))
.map((entry) => ({ ...entry, no_longer_in_catalog: true }));

fs.mkdirSync(path.dirname(outPath), { recursive: true });
fs.writeFileSync(
outPath,
JSON.stringify(
{
generated: new Date().toISOString().slice(0, 10),
source: 'static/data/models.json (agml.status = not_in_agml) + private/ingestion_notes.json',
count: candidates.length,
candidates: [...candidates, ...dropped],
agml_followups: notes.agml_followups ?? [],
},
null,
2
) + '\n'
);
console.log(`Wrote ${candidates.length} datasets (+${dropped.length} no longer in catalog) to ${outPath}`);
154 changes: 154 additions & 0 deletions scripts/validate-models.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
// Validates static/data/models.json (the external-model catalog) against the dataset manifests.
// Runs before every build/start (see package.json) and fails the build on errors, so a model can't
// silently claim AgML verification, link to an AgML dataset that doesn't exist, or show a metric
// without a source.
//
// node scripts/validate-models.mjs
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

const VERIFICATIONS = new Set(['source_reported', 'metrics_not_transcribed', 'no_metrics_reported', 'agml_verified']);
const DATASET_STATUSES = new Set(['in_agml', 'related_in_agml', 'not_in_agml', 'not_public', 'not_applicable']);
const ML_TASKS = new Set([
'image_classification',
'object_detection',
'semantic_segmentation',
'instance_segmentation',
'image_regression',
'image-text-to-text',
]);
const DATASET_ROLES = new Set(['train', 'eval', 'pretrain']);
const PUBLISHER_TYPES = new Set(['peer_reviewed', 'institutional', 'community']);

function isRecord(value) {
return typeof value === 'object' && value !== null && !Array.isArray(value);
}

function nonEmpty(value) {
return typeof value === 'string' && value.trim().length > 0;
}

export function validateModelCatalog(catalog, agmlDatasetNames) {
const errors = [];
const warnings = [];
if (!isRecord(catalog) || !Array.isArray(catalog.models)) {
return { errors: ['models.json must be an object with a "models" array'], warnings };
}

const seen = new Set();
for (const [index, model] of catalog.models.entries()) {
const where = `models[${index}]${model?.id ? ` (${model.id})` : ''}`;
if (!isRecord(model)) {
errors.push(`${where}: not an object`);
continue;
}
if (!nonEmpty(model.id)) errors.push(`${where}: missing id`);
else if (!/^[a-z0-9][a-z0-9-]*$/.test(model.id)) errors.push(`${where}: id must be lowercase kebab-case`);
else if (seen.has(model.id)) errors.push(`${where}: duplicate id`);
else seen.add(model.id);

if (!nonEmpty(model.name)) errors.push(`${where}: missing name`);
if (!PUBLISHER_TYPES.has(model.publisher_type)) errors.push(`${where}: publisher_type must be peer_reviewed, institutional or community`);
if (!ML_TASKS.has(model.machine_learning_task)) errors.push(`${where}: unknown machine_learning_task ${JSON.stringify(model.machine_learning_task)}`);
if (!Array.isArray(model.agricultural_tasks) || model.agricultural_tasks.length === 0) errors.push(`${where}: agricultural_tasks must be a non-empty array`);
if (!Array.isArray(model.crop_types) || model.crop_types.length === 0) errors.push(`${where}: crop_types must be a non-empty array`);
if (!isRecord(model.links) || !nonEmpty(model.links.weights)) errors.push(`${where}: links.weights (where to get the open weights) is required`);
if (!nonEmpty(model.license)) warnings.push(`${where}: no license given — say "Not stated" explicitly`);

// The core guarantee: nothing is presented as AgML-benchmarked unless AgML actually ran it.
if (typeof model.agml_benchmarked !== 'boolean') errors.push(`${where}: agml_benchmarked must be true/false`);
if (!VERIFICATIONS.has(model.verification)) errors.push(`${where}: unknown verification ${JSON.stringify(model.verification)}`);
if ((model.verification === 'agml_verified') !== (model.agml_benchmarked === true)) {
errors.push(`${where}: agml_benchmarked=true if and only if verification="agml_verified"`);
}

const datasetIds = new Set();
for (const [dIndex, ref] of (Array.isArray(model.datasets) ? model.datasets : []).entries()) {
const dWhere = `${where}.datasets[${dIndex}]${ref?.id ? ` (${ref.id})` : ''}`;
if (!isRecord(ref) || !nonEmpty(ref.id)) {
errors.push(`${dWhere}: missing id`);
continue;
}
datasetIds.add(ref.id);
if (!nonEmpty(ref.description)) warnings.push(`${dWhere}: no description — describe what it contains so users can judge fit`);
for (const role of ref.roles ?? []) if (!DATASET_ROLES.has(role)) errors.push(`${dWhere}: unknown role ${JSON.stringify(role)}`);
const status = ref.agml?.status;
const names = Array.isArray(ref.agml?.names) ? ref.agml.names : [];
if (!DATASET_STATUSES.has(status)) {
errors.push(`${dWhere}: unknown agml.status ${JSON.stringify(status)}`);
} else if (status === 'in_agml' || status === 'related_in_agml') {
if (names.length === 0) errors.push(`${dWhere}: agml.status=${status} needs agml.names`);
for (const name of names) {
if (!agmlDatasetNames.has(name)) errors.push(`${dWhere}: agml.names references unknown AgML dataset ${JSON.stringify(name)}`);
}
} else if (names.length > 0) {
errors.push(`${dWhere}: agml.names must be empty when status=${status}`);
}
if (status === 'not_in_agml' && !nonEmpty(ref.link)) warnings.push(`${dWhere}: dataset has no public link`);
}

const results = Array.isArray(model.reported_results) ? model.reported_results : [];
if (model.verification === 'source_reported' && results.length === 0) {
errors.push(`${where}: verification=source_reported but no reported_results`);
}
if (model.verification === 'no_metrics_reported' && results.length > 0) {
errors.push(`${where}: verification=no_metrics_reported but reported_results is not empty`);
}
for (const [rIndex, result] of results.entries()) {
const rWhere = `${where}.reported_results[${rIndex}]`;
if (!isRecord(result)) {
errors.push(`${rWhere}: not an object`);
continue;
}
if (!nonEmpty(result.source_url)) errors.push(`${rWhere}: source_url is required (where the number was reported)`);
if (!nonEmpty(result.eval_dataset) || !datasetIds.has(result.eval_dataset)) {
errors.push(`${rWhere}: eval_dataset must match one of this model's datasets[].id`);
}
const metrics = isRecord(result.metrics) ? Object.entries(result.metrics) : [];
if (metrics.length === 0) errors.push(`${rWhere}: metrics is empty`);
for (const [key, value] of metrics) {
if (typeof value !== 'number' || !Number.isFinite(value)) errors.push(`${rWhere}: metrics.${key} is not a number`);
else if (value < 0 || value > 1) errors.push(`${rWhere}: metrics.${key}=${value} — store fractions in [0, 1], not percentages`);
}
if (result.primary_metric != null && !(isRecord(result.metrics) && result.primary_metric in result.metrics)) {
errors.push(`${rWhere}: primary_metric ${JSON.stringify(result.primary_metric)} is not in metrics`);
}
if (!nonEmpty(result.split)) warnings.push(`${rWhere}: no split described`);
}
}
return { errors, warnings };
}

export function loadAgmlDatasetNames(staticDataDir) {
const names = new Set();
for (const file of ['datasets.json', 'hf_datasets.json']) {
const filePath = path.join(staticDataDir, file);
if (!fs.existsSync(filePath)) continue;
const json = JSON.parse(fs.readFileSync(filePath, 'utf8'));
for (const entry of Array.isArray(json) ? json : Object.values(json)) {
if (entry && typeof entry.name === 'string') names.add(entry.name);
}
}
return names;
}

function main() {
const staticDataDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'static', 'data');
const modelsPath = path.join(staticDataDir, 'models.json');
if (!fs.existsSync(modelsPath)) {
console.log('No models.json — skipping model catalog validation');
return;
}
const catalog = JSON.parse(fs.readFileSync(modelsPath, 'utf8'));
const { errors, warnings } = validateModelCatalog(catalog, loadAgmlDatasetNames(staticDataDir));
for (const warning of warnings) console.warn('warn:', warning);
if (errors.length) {
for (const error of errors) console.error('error:', error);
console.error(`models.json: ${errors.length} error(s)`);
process.exit(1);
}
console.log(`Validated ${modelsPath} — ${catalog.models.length} models, ${warnings.length} warning(s)`);
}

if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main();
2 changes: 1 addition & 1 deletion sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const sidebars: SidebarsConfig = {
label: 'Guide',
collapsible: false,
className: 'sidebarCategoryLabel',
items: ['index', 'contributing-data', 'contributing-results', 'development'],
items: ['index', 'contributing-data', 'contributing-results', 'contributing-models', 'development'],
},
{
type: 'category',
Expand Down
3 changes: 3 additions & 0 deletions src/components/DatasetMetadataModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { oklchToRgb } from '../lib/plotlyChrome';
import { EmbeddingPlot2D } from './EmbeddingPlot2D';
import { EmbeddingPlot3D } from './EmbeddingPlot3D';
import { PointCloudPlot3D } from './PointCloudPlot3D';
import { DatasetModelsSection } from './DatasetModelsSection';
import { ScoringMethodologyModal } from './ScoringMethodologyModal';
import styles from './DatasetMetadataModal.module.css';

Expand Down Expand Up @@ -1494,6 +1495,8 @@ export function DatasetMetadataModal({
</div>
)}

<DatasetModelsSection datasetName={dataset.name} />

<section className={styles.section}>
<h3 className={styles.sectionTitle}>
Leaderboard{datasetPerformance.data?.metric ? ` — ${datasetPerformance.data.metric}` : ''}
Expand Down
Loading
Loading