Files
photoprism/internal/commands/vision_run.go
2025-07-15 12:52:02 +02:00

52 lines
1.4 KiB
Go

package commands
import (
"strings"
"github.com/urfave/cli/v2"
"github.com/photoprism/photoprism/internal/ai/vision"
"github.com/photoprism/photoprism/internal/config"
"github.com/photoprism/photoprism/internal/entity"
"github.com/photoprism/photoprism/internal/workers"
)
// VisionRunCommand configures the command name, flags, and action.
var VisionRunCommand = &cli.Command{
Name: "run",
Usage: "Runs one or more computer vision models on a set of pictures, as specified by the search filter",
ArgsUsage: "[filter]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "models",
Aliases: []string{"m"},
Usage: "computer vision `MODELS` to run, e.g. caption, labels, or nsfw",
},
&cli.StringFlag{
Name: "source",
Aliases: []string{"s"},
Value: entity.SrcImage,
Usage: "custom data source `TYPE`, e.g. estimate, image, meta, or manual",
},
&cli.BoolFlag{
Name: "force",
Aliases: []string{"f"},
Usage: "force existing data to be updated if the source priority is equal to or higher than the current one",
},
},
Action: visionRunAction,
}
// visionListAction displays existing user accounts.
func visionRunAction(ctx *cli.Context) error {
return CallWithDependencies(ctx, func(conf *config.Config) error {
worker := workers.NewVision(conf)
return worker.Start(
strings.TrimSpace(ctx.Args().First()),
vision.ParseTypes(ctx.String("models")),
ctx.String("source"),
ctx.Bool("force"),
)
})
}