photoprism/internal/commands/people.go
Michael Mayer 1fc4ef123b People: Add face clustering worker #22
Work in progress. No performance optimizations yet.
2021-08-12 04:54:20 +02:00

49 lines
885 B
Go

package commands
import (
"context"
"time"
"github.com/photoprism/photoprism/internal/config"
"github.com/photoprism/photoprism/internal/service"
"github.com/urfave/cli"
)
// PeopleCommand registers the people cli command.
var PeopleCommand = cli.Command{
Name: "people",
Usage: "Performs face clustering and recognition",
Action: peopleAction,
}
// peopleAction performs face clustering and recognition.
func peopleAction(ctx *cli.Context) error {
start := time.Now()
conf := config.NewConfig(ctx)
service.SetConfig(conf)
_, cancel := context.WithCancel(context.Background())
defer cancel()
if err := conf.Init(); err != nil {
return err
}
conf.InitDb()
people := service.People()
if err := people.Start(); err != nil {
return err
} else {
elapsed := time.Since(start)
log.Infof("completed in %s", elapsed)
}
conf.Shutdown()
return nil
}