Files
photoprism/internal/commands/show_config_options.go
2024-05-20 10:18:52 +02:00

90 lines
2.5 KiB
Go

package commands
import (
"fmt"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
"github.com/photoprism/photoprism/internal/config"
"github.com/photoprism/photoprism/pkg/report"
)
// ShowConfigOptionsCommand configures the command name, flags, and action.
var ShowConfigOptionsCommand = cli.Command{
Name: "config-options",
Usage: "Displays supported environment variables and CLI flags",
Flags: report.CliFlags,
Action: showConfigOptionsAction,
}
var faceFlagsInfo = `!!! info ""
To [recognize faces](https://docs.photoprism.app/user-guide/organize/people/), PhotoPrism first extracts crops from your images using a [library](https://github.com/esimov/pigo) based on [pixel intensity comparisons](https://dl.photoprism.app/pdf/20140820-Pixel_Intensity_Comparisons.pdf). These are then fed into TensorFlow to compute [512-dimensional vectors](https://dl.photoprism.app/pdf/20150101-FaceNet.pdf) for characterization. In the final step, the [DBSCAN algorithm](https://en.wikipedia.org/wiki/DBSCAN) attempts to cluster these so-called face embeddings, so they can be matched to persons with just a few clicks. A reasonable range for the similarity distance between face embeddings is between 0.60 and 0.70, with a higher value being more aggressive and leading to larger clusters with more false positives. To cluster a smaller number of faces, you can reduce the core to 3 or 2 similar faces.
We recommend that only advanced users change these parameters:`
// showConfigOptionsAction displays supported environment variables and CLI flags.
func showConfigOptionsAction(ctx *cli.Context) error {
conf := config.NewConfig(ctx)
conf.SetLogLevel(logrus.FatalLevel)
rows, cols := config.Flags.Report()
// CSV Export?
if ctx.Bool("csv") || ctx.Bool("tsv") {
result, err := report.RenderFormat(rows, cols, report.CliFormat(ctx))
fmt.Println(result)
return err
}
sections := config.OptionsReportSections
j := 0
for i, section := range sections {
fmt.Printf("### %s ###\n\n", section.Title)
if section.Info != "" && ctx.Bool("md") {
fmt.Printf("%s\n\n", section.Info)
}
secRows := make([][]string, 0, len(rows))
for {
row := rows[j]
if len(row) < 1 {
continue
}
if i < len(sections)-1 {
if sections[i+1].Start == row[0] {
break
}
}
secRows = append(secRows, row)
j++
if j >= len(rows) {
break
}
}
result, err := report.RenderFormat(secRows, cols, report.CliFormat(ctx))
if err != nil {
return err
}
fmt.Println(result)
if j >= len(rows) {
break
}
}
return nil
}