Config: Add options to disable classification and/or facial recognition
This commit is contained in:
parent
2929733f78
commit
a1822f9b19
|
@ -67,6 +67,8 @@ func configAction(ctx *cli.Context) error {
|
|||
fmt.Printf("%-25s %t\n", "disable-places", conf.DisablePlaces())
|
||||
fmt.Printf("%-25s %t\n", "disable-exiftool", conf.DisableExifTool())
|
||||
fmt.Printf("%-25s %t\n", "disable-tensorflow", conf.DisableTensorFlow())
|
||||
fmt.Printf("%-25s %t\n", "disable-faces", conf.DisableFaces())
|
||||
fmt.Printf("%-25s %t\n", "disable-classification", conf.DisableClassification())
|
||||
fmt.Printf("%-25s %t\n", "disable-darktable", conf.DisableDarktable())
|
||||
fmt.Printf("%-25s %t\n", "disable-rawtherapee", conf.DisableRawtherapee())
|
||||
fmt.Printf("%-25s %t\n", "disable-sips", conf.DisableSips())
|
||||
|
|
|
@ -78,6 +78,8 @@ type ClientDisable struct {
|
|||
HeifConvert bool `json:"heifconvert"`
|
||||
FFmpeg bool `json:"ffmpeg"`
|
||||
TensorFlow bool `json:"tensorflow"`
|
||||
Faces bool `json:"faces"`
|
||||
Classification bool `json:"classification"`
|
||||
}
|
||||
|
||||
// ClientCounts represents photo, video and album counts for the client UI.
|
||||
|
@ -288,6 +290,8 @@ func (c *Config) UserConfig() ClientConfig {
|
|||
Places: c.DisablePlaces(),
|
||||
ExifTool: c.DisableExifTool(),
|
||||
TensorFlow: c.DisableTensorFlow(),
|
||||
Faces: c.DisableFaces(),
|
||||
Classification: c.DisableClassification(),
|
||||
Darktable: c.DisableDarktable(),
|
||||
Rawtherapee: c.DisableRawtherapee(),
|
||||
Sips: c.DisableSips(),
|
||||
|
|
|
@ -37,16 +37,34 @@ func (c *Config) DisableExifTool() bool {
|
|||
return c.options.DisableExifTool
|
||||
}
|
||||
|
||||
// DisableTensorFlow tests if TensorFlow should not be used for image classification (or anything else).
|
||||
// DisableTensorFlow tests if features that require TensorFlow should be disabled.
|
||||
func (c *Config) DisableTensorFlow() bool {
|
||||
if LowMem && !c.options.DisableTensorFlow {
|
||||
c.options.DisableTensorFlow = true
|
||||
log.Warnf("config: disabled image classification due to memory constraints")
|
||||
log.Warnf("config: disabled tensorflow due to memory constraints")
|
||||
}
|
||||
|
||||
return c.options.DisableTensorFlow
|
||||
}
|
||||
|
||||
// DisableFaces tests if facial recognition is disabled.
|
||||
func (c *Config) DisableFaces() bool {
|
||||
if c.DisableTensorFlow() || c.options.DisableFaces {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// DisableClassification tests if image classification is disabled.
|
||||
func (c *Config) DisableClassification() bool {
|
||||
if c.DisableTensorFlow() || c.options.DisableClassification {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// DisableFFmpeg tests if FFmpeg is disabled for video transcoding.
|
||||
func (c *Config) DisableFFmpeg() bool {
|
||||
return c.options.DisableFFmpeg || c.FFmpegBin() == ""
|
||||
|
|
|
@ -27,3 +27,27 @@ func TestConfig_DisableExifTool(t *testing.T) {
|
|||
c.options.ExifToolBin = "XXX"
|
||||
assert.True(t, c.DisableExifTool())
|
||||
}
|
||||
|
||||
func TestConfig_DisableFaces(t *testing.T) {
|
||||
c := NewConfig(CliTestContext())
|
||||
assert.False(t, c.DisableFaces())
|
||||
c.options.DisableFaces = true
|
||||
assert.True(t, c.DisableFaces())
|
||||
c.options.DisableFaces = false
|
||||
c.options.DisableTensorFlow = true
|
||||
assert.True(t, c.DisableFaces())
|
||||
c.options.DisableTensorFlow = false
|
||||
assert.False(t, c.DisableFaces())
|
||||
}
|
||||
|
||||
func TestConfig_DisableClassification(t *testing.T) {
|
||||
c := NewConfig(CliTestContext())
|
||||
assert.False(t, c.DisableClassification())
|
||||
c.options.DisableClassification = true
|
||||
assert.True(t, c.DisableClassification())
|
||||
c.options.DisableClassification = false
|
||||
c.options.DisableTensorFlow = true
|
||||
assert.True(t, c.DisableClassification())
|
||||
c.options.DisableTensorFlow = false
|
||||
assert.False(t, c.DisableClassification())
|
||||
}
|
||||
|
|
|
@ -155,9 +155,19 @@ var GlobalFlags = []cli.Flag{
|
|||
},
|
||||
cli.BoolFlag{
|
||||
Name: "disable-tensorflow",
|
||||
Usage: "disables image classification with TensorFlow",
|
||||
Usage: "disables features that require TensorFlow",
|
||||
EnvVar: "PHOTOPRISM_DISABLE_TENSORFLOW",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "disable-faces",
|
||||
Usage: "disables facial recognition",
|
||||
EnvVar: "PHOTOPRISM_DISABLE_FACES",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "disable-classification",
|
||||
Usage: "disables image classification",
|
||||
EnvVar: "PHOTOPRISM_DISABLE_CLASSIFICATION",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "disable-ffmpeg",
|
||||
Usage: "disables video transcoding and thumbnail generation with FFmpeg",
|
||||
|
|
|
@ -62,6 +62,8 @@ type Options struct {
|
|||
DisablePlaces bool `yaml:"DisablePlaces" json:"DisablePlaces" flag:"disable-places"`
|
||||
DisableExifTool bool `yaml:"DisableExifTool" json:"DisableExifTool" flag:"disable-exiftool"`
|
||||
DisableTensorFlow bool `yaml:"DisableTensorFlow" json:"DisableTensorFlow" flag:"disable-tensorflow"`
|
||||
DisableFaces bool `yaml:"DisableFaces" json:"DisableFaces" flag:"disable-faces"`
|
||||
DisableClassification bool `yaml:"DisableClassification" json:"DisableClassification" flag:"disable-classification"`
|
||||
DisableFFmpeg bool `yaml:"DisableFFmpeg" json:"DisableFFmpeg" flag:"disable-ffmpeg"`
|
||||
DisableDarktable bool `yaml:"DisableDarktable" json:"DisableDarktable" flag:"disable-darktable"`
|
||||
DisableRawtherapee bool `yaml:"DisableRawtherapee" json:"DisableRawtherapee" flag:"disable-rawtherapee"`
|
||||
|
|
|
@ -92,10 +92,10 @@ func (ind *Index) Start(opt IndexOptions) fs.Done {
|
|||
}
|
||||
|
||||
// Detect faces in images?
|
||||
ind.findFaces = ind.conf.Settings().Features.People
|
||||
ind.findFaces = !ind.conf.DisableFaces() && ind.conf.Settings().Features.People
|
||||
|
||||
// Classify images with TensorFlow?
|
||||
ind.findLabels = !ind.conf.DisableTensorFlow()
|
||||
ind.findLabels = !ind.conf.DisableClassification()
|
||||
|
||||
defer mutex.MainWorker.Stop()
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
var onceClassify sync.Once
|
||||
|
||||
func initClassify() {
|
||||
services.Classify = classify.New(Config().AssetsPath(), Config().DisableTensorFlow())
|
||||
services.Classify = classify.New(Config().AssetsPath(), Config().DisableClassification())
|
||||
}
|
||||
|
||||
func Classify() *classify.TensorFlow {
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
var onceFaceNet sync.Once
|
||||
|
||||
func initFaceNet() {
|
||||
services.FaceNet = face.NewNet(conf.FaceNetModelPath(), "", conf.DisableTensorFlow())
|
||||
services.FaceNet = face.NewNet(conf.FaceNetModelPath(), "", conf.DisableFaces())
|
||||
}
|
||||
|
||||
func FaceNet() *face.Net {
|
||||
|
|
Loading…
Reference in a new issue