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