1 ADR 0054 multi model abstraction layer for plant classification
Forgejo Actions edited this page 2026-09-25 16:38:07 +00:00

ADR 0054: Multi-Model Abstraction Layer for Plant Classification

Status: accepted Date: 2026-06-17

Context

Current plants worker has one hardcoded PlantNet-300K model (ONNX, ResNet-18, 1,081 species). Users report missing species (rhododendron, many garden plants). Broader pretrained models exist: PlantCLEF 2024 DINOv2 (7,800 species, MIT), iNaturalist ViT-Base (~10,000 species, Apache-2.0). These use HuggingFace Transformers (PyTorch) instead of ONNX Runtime.

Decision

Create BasePlantClassifier abstraction layer with two backends: OnnxClassifier (existing ONNX path) and HfTransformerClassifier (HF Transformers). Model selection via MEMORIES_PLANTS_MODEL env var. Default: plantnet300k (backward compatible). ClassId format: {namespace}_{localId} (e.g. plantnet300k_0000). Each model bundles its own class map. Core API scopes allowed_classes by taxonomy_namespace.

Consequences

Positive: operators can switch to broader models without worker code changes; new models addable at ~5% effort each; existing PlantNet pipeline unchanged. Negative: Docker image grows ~2-3GB (torch CPU + transformers); CPU inference latency increases 10-30x for transformer models (~2-5s/image). Risk: OOM on small hosts — recommend >=4GB RAM for PlantCLEF model.