2018-09-24 09:53:16 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2018-10-31 07:14:33 +01:00
|
|
|
"log"
|
|
|
|
|
2018-11-17 06:21:39 +01:00
|
|
|
"github.com/photoprism/photoprism/internal/context"
|
2018-09-24 09:53:16 +02:00
|
|
|
"github.com/photoprism/photoprism/internal/photoprism"
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var IndexCommand = cli.Command{
|
|
|
|
Name: "index",
|
|
|
|
Usage: "Re-indexes all originals",
|
|
|
|
Action: indexAction,
|
|
|
|
}
|
|
|
|
|
2018-10-31 02:42:54 +01:00
|
|
|
// Indexes original photos; called by IndexCommand
|
2018-11-17 06:21:39 +01:00
|
|
|
func indexAction(ctx *cli.Context) error {
|
|
|
|
conf := context.NewConfig(ctx)
|
2018-09-24 09:53:16 +02:00
|
|
|
|
|
|
|
if err := conf.CreateDirectories(); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
conf.MigrateDb()
|
|
|
|
|
2018-11-09 20:48:23 +01:00
|
|
|
fmt.Printf("Indexing photos in %s...\n", conf.GetOriginalsPath())
|
2018-09-24 09:53:16 +02:00
|
|
|
|
|
|
|
tensorFlow := photoprism.NewTensorFlow(conf.GetTensorFlowModelPath())
|
|
|
|
|
2018-11-09 20:48:23 +01:00
|
|
|
indexer := photoprism.NewIndexer(conf.GetOriginalsPath(), tensorFlow, conf.GetDb())
|
2018-09-24 09:53:16 +02:00
|
|
|
|
|
|
|
indexer.IndexAll()
|
|
|
|
|
|
|
|
fmt.Println("Done.")
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|