mirror of
https://github.com/photoprism/photoprism.git
synced 2026-01-23 02:24:24 +00:00
|
|
||
|---|---|---|
| .. | ||
| classify.go | ||
| const.go | ||
| gen.go | ||
| label.go | ||
| label_rule.go | ||
| label_rule_test.go | ||
| label_test.go | ||
| labels.go | ||
| labels_test.go | ||
| model.go | ||
| model_external_test.go | ||
| model_test.go | ||
| README.md | ||
| rules.go | ||
| rules.yml | ||
| rules_test.go | ||
PhotoPrism — Classification Package
Last Updated: December 23, 2025
Overview
internal/ai/classify wraps PhotoPrism’s TensorFlow-based image classification (labels). It loads SavedModel classifiers (Nasnet by default), prepares inputs, runs inference, and maps output probabilities to label rules.
How It Works
- Model Loading — The classifier loads a SavedModel under
assets/models/<name>and resolves model tags and input/output ops (seevision.ymloverrides for custom models). - Input Preparation — JPEGs are decoded and resized/cropped to the model’s expected input resolution.
- Inference — The model outputs probabilities;
Rulesapply thresholds and priority to produce final labels.
Memory & Performance
TensorFlow tensors allocate C memory and are freed by Go GC finalizers. To keep RSS bounded during long runs, PhotoPrism periodically triggers garbage collection to return freed tensor memory to the OS. Tune with:
PHOTOPRISM_TF_GC_EVERY(default 200,0disables).
Lower values reduce peak RSS but increase GC overhead and can slow indexing.
Troubleshooting Tips
- Labels are empty: Verify the model labels file and that
Rulesthresholds are not too strict. - Model load failures: Ensure
saved_model.pbandvariables/exist under the configured model path. - Unexpected outputs: Check
TensorFlow.Input/Outputsettings invision.ymlfor custom models.
Related Docs
internal/ai/vision/README.md— model registry andvision.ymlconfigurationinternal/ai/tensorflow/README.md— TensorFlow helpers, GC behavior, and model loading