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"
|
|
|
|
)
|
|
|
|
|
2018-11-17 13:57:19 +01:00
|
|
|
// Re-indexes all photos in originals directory (photo library)
|
2018-09-24 09:53:16 +02:00
|
|
|
var IndexCommand = cli.Command{
|
|
|
|
Name: "index",
|
|
|
|
Usage: "Re-indexes all originals",
|
|
|
|
Action: indexAction,
|
|
|
|
}
|
|
|
|
|
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-12-21 03:21:21 +01:00
|
|
|
fmt.Printf("Indexing photos in %s...\n", conf.OriginalsPath())
|
2018-09-24 09:53:16 +02:00
|
|
|
|
2018-12-21 03:25:50 +01:00
|
|
|
tensorFlow := photoprism.NewTensorFlow(conf.TensorFlowModelPath())
|
2018-09-24 09:53:16 +02:00
|
|
|
|
2018-12-21 03:21:21 +01:00
|
|
|
indexer := photoprism.NewIndexer(conf.OriginalsPath(), tensorFlow, conf.Db())
|
2018-09-24 09:53:16 +02:00
|
|
|
|
|
|
|
indexer.IndexAll()
|
|
|
|
|
|
|
|
fmt.Println("Done.")
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|