AI: Update log messages in internal/ai/tensorflow/labels.go #127 #5011

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-08-04 10:08:03 +02:00
parent 10fe7d2b40
commit 523605f7d7

View File

@@ -5,10 +5,12 @@ import (
"io/fs" "io/fs"
"os" "os"
"path/filepath" "path/filepath"
"github.com/photoprism/photoprism/pkg/clean"
) )
func loadLabelsFromPath(path string) (labels []string, err error) { func loadLabelsFromPath(path string) (labels []string, err error) {
log.Infof("tensorflow: loading model labels from %s", path) log.Infof("vision: loading TensorFlow model labels from %s", path)
f, err := os.Open(path) f, err := os.Open(path)
if err != nil { if err != nil {
@@ -39,22 +41,22 @@ func LoadLabels(modelPath string, expectedLabels int) (labels []string, err erro
} }
for i := range matches { for i := range matches {
labels, err := loadLabelsFromPath(filepath.Join(modelPath, matches[i])) loadedLabels, labelsErr := loadLabelsFromPath(filepath.Join(modelPath, matches[i]))
if err != nil {
return nil, err if labelsErr != nil {
return nil, labelsErr
} }
switch expectedLabels - len(labels) { switch expectedLabels - len(loadedLabels) {
case 0: case 0:
log.Infof("Found a valid labels file: %s", matches[i]) log.Infof("vision: found valid labels in %s", clean.Log(matches[i]))
return labels, nil return loadedLabels, nil
case 1: case 1:
log.Infof("Found a valid labels file %s but we have to add bias", matches[i]) log.Infof("vision: found valid labels in %s, but bias needs to be added", clean.Log(matches[i]))
return append([]string{"background"}, loadedLabels...), nil
return append([]string{"background"}, labels...), nil
default: default:
log.Infof("File not valid. Expected %d labels and have %d", log.Infof("vision: invalid labels file, expected %d labels and found %d",
expectedLabels, len(labels)) expectedLabels, len(loadedLabels))
} }
} }
return nil, os.ErrNotExist return nil, os.ErrNotExist