photoprism/internal/commands/index.go

38 lines
826 B
Go
Raw Normal View History

package commands
import (
"github.com/photoprism/photoprism/internal/context"
"github.com/photoprism/photoprism/internal/photoprism"
2019-05-02 14:10:05 +02:00
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
// Re-indexes all photos in originals directory (photo library)
var IndexCommand = cli.Command{
Name: "index",
Usage: "Re-indexes all originals",
Action: indexAction,
}
func indexAction(ctx *cli.Context) error {
app := context.NewContext(ctx)
if err := app.CreateDirectories(); err != nil {
return err
}
app.MigrateDb()
log.Infof("indexing photos in %s", app.OriginalsPath())
tensorFlow := photoprism.NewTensorFlow(app.TensorFlowModelPath())
indexer := photoprism.NewIndexer(app.OriginalsPath(), tensorFlow, app.Db())
2019-05-02 14:10:05 +02:00
files := indexer.IndexAll()
2019-05-02 14:10:05 +02:00
log.Infof("indexed %d files", len(files))
return nil
}