GreyModel is a local-first framework for grayscale syringe and vial inspection. It combines:
- dataset ingestion and normalization
- public pretraining
- domain adaptation
- supervised finetuning
- calibration
- hierarchical batch prediction
- explainability
- recovery and run tracking
- a local Streamlit UI
The primary decision is always good vs bad. Defect-family probabilities are secondary evidence for bad samples.
Folder-first import:
python -m greymodel dataset build /path/to/images --output-dir data/production
python -m greymodel dataset validate data/production/manifest.jsonl
python -m greymodel dataset ontology --manifest data/production/manifest.jsonlPublic Hugging Face import:
python -m greymodel dataset build-hf \
--dataset-preset defect_spectrum_full \
--output-dir data/public_pretrain/defect_spectrum_fullPretrain:
torchrun --standalone --nproc_per_node=8 -m greymodel train pretrain \
--manifest data/public_pretrain/defect_spectrum_full/manifest.jsonl \
--index data/public_pretrain/defect_spectrum_full/dataset_index.json \
--variant base \
--run-root artifactsDomain adaptation:
python -m greymodel train domain-adapt \
--manifest data/production/manifest.jsonl \
--index data/production/dataset_index.json \
--variant base \
--run-root artifactsFinetune:
python -m greymodel train finetune \
--manifest data/production/manifest.jsonl \
--index data/production/dataset_index.json \
--variant base \
--run-root artifactsCalibration:
python -m greymodel train calibrate \
--manifest data/production/manifest.jsonl \
--index data/production/dataset_index.json \
--variant base \
--run-root artifactsBenchmark:
python -m greymodel eval benchmark \
--manifest data/production/manifest.jsonl \
--index data/production/dataset_index.json \
--variant base \
--run-root artifactsThreshold sweep:
python -m greymodel eval threshold-sweep \
--manifest data/production/manifest.jsonl \
--index data/production/dataset_index.json \
--variant baseCompare reports:
python -m greymodel eval compare \
--left-report artifacts/benchmark-base/reports/benchmark_report.json \
--right-report artifacts/predict-base/reports/predict_report.jsonManifest-backed prediction:
python -m greymodel predict \
--manifest data/production/manifest.jsonl \
--index data/production/dataset_index.json \
--variant base \
--run-root artifacts \
--evidence-policy badFolder-backed prediction:
python -m greymodel predict \
--input-dir /path/to/incoming_images \
--variant lite \
--run-root artifactsSingle sample:
python -m greymodel explain sample \
--manifest data/production/manifest.jsonl \
--index data/production/dataset_index.json \
--sample-id sample_001 \
--variant base \
--run-root artifactsAudit batch:
python -m greymodel explain audit \
--manifest data/production/manifest.jsonl \
--index data/production/dataset_index.json \
--variant base \
--run-root artifacts \
--limit 20Every run writes under <run_root>/<stage>-<variant>/.
Core files:
run_status.jsonmetrics.jsonlepoch_metrics.jsonlconfig_snapshot.jsonmanifest_snapshot.jsoncheckpoints/reports/predictions/explanations/failures/sessions/<session_id>/...
The latest stage state stays in the stable stage directory. Session folders preserve point-in-time status and failure artifacts.
Prediction persistence is hierarchical:
primary_labelprimary_scoretop_defect_familydefect_family_probsevidence
This is the contract used by:
- batch prediction output
- evaluation
- recovery bundles
- the UI
If a run fails after initialization, GreyModel writes:
- run status with
failedorcompleted_with_failures - traceback bundle
- manifest and index references
- checkpoint references when available
- offending sample ids for quarantined batch failures
See recovery.md for the exact payload.
Launch:
python -m greymodel ui --run-root artifacts --data-root dataThe UI is local-only and reads the same on-disk artifacts that the CLI writes.
If your compute environment is Slurm-backed, start the UI with cluster defaults so the Train, Predict, and Explain pages submit GPU work through sbatch instead of local subprocesses:
python -m greymodel ui \
--run-root artifacts \
--data-root data \
--default-execution-backend slurm \
--slurm-cpus 8 \
--slurm-mem 50G \
--slurm-gres gpu:8 \
--slurm-partition batch_gpu \
--slurm-queue 3h \
--slurm-nproc-per-node 8The Streamlit process itself still stays local. Only the launched GPU jobs are scheduled through Slurm.