Automatically set private flag if detect-nsfw is enabled
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
4fb01fe669
commit
8609ab805f
13 changed files with 26 additions and 29 deletions
|
@ -16,5 +16,7 @@ library:
|
|||
rescan: false
|
||||
raw: false
|
||||
thumbs: false
|
||||
group: true
|
||||
move: false
|
||||
group: true
|
||||
review: true
|
||||
private: true
|
||||
|
|
|
@ -23,7 +23,7 @@ services:
|
|||
PHOTOPRISM_PUBLIC: "false"
|
||||
PHOTOPRISM_EXPERIMENTAL: "true"
|
||||
PHOTOPRISM_UPLOAD_NSFW: "false"
|
||||
PHOTOPRISM_HIDE_NSFW: "false"
|
||||
PHOTOPRISM_DETECT_NSFW: "true"
|
||||
PHOTOPRISM_SERVER_MODE: "debug"
|
||||
PHOTOPRISM_ASSETS_PATH: "/go/src/github.com/photoprism/photoprism/assets"
|
||||
PHOTOPRISM_CACHE_PATH: "/go/src/github.com/photoprism/photoprism/assets/cache"
|
||||
|
|
|
@ -11,7 +11,7 @@ ENV PHOTOPRISM_READONLY false
|
|||
ENV PHOTOPRISM_PUBLIC true
|
||||
ENV PHOTOPRISM_EXPERIMENTAL true
|
||||
ENV PHOTOPRISM_UPLOAD_NSFW false
|
||||
ENV PHOTOPRISM_HIDE_NSFW false
|
||||
ENV PHOTOPRISM_DETECT_NSFW false
|
||||
ENV PHOTOPRISM_THUMB_QUALITY 95
|
||||
ENV PHOTOPRISM_THUMB_SIZE 3840
|
||||
ENV PHOTOPRISM_THUMB_LIMIT 3840
|
||||
|
|
|
@ -13,6 +13,12 @@ services:
|
|||
- seccomp:unconfined
|
||||
ports:
|
||||
- 2342:2342 # [local port]:[container port]
|
||||
# - 4000:4000 # Internal database (MySQL compatible)
|
||||
healthcheck: # Optional
|
||||
test: "photoprism status"
|
||||
interval: 60s
|
||||
timeout: 15s
|
||||
retries: 5
|
||||
environment: # Run "photoprism help" and "photoprism config" too see all config options and current values
|
||||
PHOTOPRISM_URL: "https://demo.photoprism.org/"
|
||||
PHOTOPRISM_TITLE: "PhotoPrism"
|
||||
|
@ -21,7 +27,7 @@ services:
|
|||
PHOTOPRISM_AUTHOR: "Anonymous"
|
||||
PHOTOPRISM_TWITTER: "@browseyourlife"
|
||||
PHOTOPRISM_UPLOAD_NSFW: "true"
|
||||
PHOTOPRISM_HIDE_NSFW: "false"
|
||||
PHOTOPRISM_DETECT_NSFW: "false"
|
||||
PHOTOPRISM_EXPERIMENTAL: "false"
|
||||
PHOTOPRISM_DEBUG: "false"
|
||||
PHOTOPRISM_READONLY: "false"
|
||||
|
|
|
@ -12,7 +12,8 @@ services:
|
|||
restart: unless-stopped
|
||||
ports:
|
||||
- 2342:2342 # [local port]:[container port]
|
||||
healthcheck:
|
||||
# - 4000:4000 # Internal database (MySQL compatible)
|
||||
healthcheck: # Optional
|
||||
test: "photoprism status"
|
||||
interval: 60s
|
||||
timeout: 15s
|
||||
|
@ -25,7 +26,7 @@ services:
|
|||
PHOTOPRISM_AUTHOR: "Anonymous"
|
||||
PHOTOPRISM_TWITTER: "@browseyourlife"
|
||||
PHOTOPRISM_UPLOAD_NSFW: "true"
|
||||
PHOTOPRISM_HIDE_NSFW: "false"
|
||||
PHOTOPRISM_DETECT_NSFW: "true"
|
||||
PHOTOPRISM_EXPERIMENTAL: "false"
|
||||
PHOTOPRISM_DEBUG: "false"
|
||||
PHOTOPRISM_READONLY: "false"
|
||||
|
|
|
@ -27,7 +27,6 @@ class Photo extends RestModel {
|
|||
PhotoFavorite: false,
|
||||
PhotoStory: false,
|
||||
PhotoPrivate: false,
|
||||
PhotoNSFW: false,
|
||||
PhotoResolution: 0,
|
||||
PhotoQuality: 0,
|
||||
PhotoLat: 0.0,
|
||||
|
|
|
@ -222,12 +222,12 @@ var GlobalFlags = []cli.Flag{
|
|||
},
|
||||
cli.BoolFlag{
|
||||
Name: "detect-nsfw",
|
||||
Usage: "flag photos that may be offensive",
|
||||
Usage: "flag photos as private that may be offensive",
|
||||
EnvVar: "PHOTOPRISM_DETECT_NSFW",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "upload-nsfw",
|
||||
Usage: "allow uploads that may contain offensive content",
|
||||
Usage: "allow uploads that may be offensive",
|
||||
EnvVar: "PHOTOPRISM_UPLOAD_NSFW",
|
||||
},
|
||||
cli.StringFlag{
|
||||
|
|
|
@ -72,10 +72,10 @@ func NewSettings() *Settings {
|
|||
CompleteRescan: false,
|
||||
ConvertRaw: false,
|
||||
CreateThumbs: false,
|
||||
GroupRelated: true,
|
||||
MoveImported: false,
|
||||
GroupRelated: true,
|
||||
RequireReview: true,
|
||||
HidePrivate: false,
|
||||
HidePrivate: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
2
internal/config/testdata/configEmpty.yml
vendored
2
internal/config/testdata/configEmpty.yml
vendored
|
@ -19,4 +19,4 @@ library:
|
|||
group: true
|
||||
move: false
|
||||
review: true
|
||||
private: false
|
||||
private: true
|
||||
|
|
|
@ -30,7 +30,6 @@ type Photo struct {
|
|||
PhotoFavorite bool `json:"PhotoFavorite"`
|
||||
PhotoPrivate bool `json:"PhotoPrivate"`
|
||||
PhotoStory bool `json:"PhotoStory"`
|
||||
PhotoNSFW bool `json:"PhotoNSFW"`
|
||||
PhotoLat float64 `gorm:"index;" json:"PhotoLat"`
|
||||
PhotoLng float64 `gorm:"index;" json:"PhotoLng"`
|
||||
PhotoAltitude int `json:"PhotoAltitude"`
|
||||
|
|
|
@ -27,7 +27,6 @@ type Photo struct {
|
|||
DescriptionSrc string `json:"DescriptionSrc"`
|
||||
PhotoFavorite bool `json:"PhotoFavorite"`
|
||||
PhotoPrivate bool `json:"PhotoPrivate"`
|
||||
PhotoNSFW bool `json:"PhotoNSFW"`
|
||||
PhotoStory bool `json:"PhotoStory"`
|
||||
PhotoReview bool `json:"PhotoReview"`
|
||||
PhotoLat float64 `json:"PhotoLat"`
|
||||
|
|
|
@ -144,7 +144,10 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
|
|||
if !ind.conf.DisableTensorFlow() && (fileChanged || o.UpdateKeywords || o.UpdateLabels || o.UpdateTitle) {
|
||||
// Image classification via TensorFlow
|
||||
labels = ind.classifyImage(m)
|
||||
photo.PhotoNSFW = ind.isNSFW(m)
|
||||
|
||||
if !photoExists && ind.conf.DetectNSFW() {
|
||||
photo.PhotoPrivate = ind.NSFW(m)
|
||||
}
|
||||
}
|
||||
|
||||
if fileChanged || o.UpdateExif {
|
||||
|
@ -443,12 +446,8 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
|
|||
return result
|
||||
}
|
||||
|
||||
// isNSFW returns true if media file might be offensive and detection is enabled.
|
||||
func (ind *Index) isNSFW(jpeg *MediaFile) bool {
|
||||
if !ind.conf.DetectNSFW() {
|
||||
return false
|
||||
}
|
||||
|
||||
// NSFW returns true if media file might be offensive and detection is enabled.
|
||||
func (ind *Index) NSFW(jpeg *MediaFile) bool {
|
||||
filename, err := jpeg.Thumbnail(ind.thumbnailsPath(), "fit_720")
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -290,14 +290,6 @@ func (q *Query) Photos(f form.PhotoSearch) (results PhotoResults, count int, err
|
|||
s = s.Where("photos.photo_favorite = 1")
|
||||
}
|
||||
|
||||
if f.Safe {
|
||||
s = s.Where("photos.photo_nsfw = 0")
|
||||
}
|
||||
|
||||
if f.Nsfw {
|
||||
s = s.Where("photos.photo_nsfw = 1")
|
||||
}
|
||||
|
||||
if f.Story {
|
||||
s = s.Where("photos.photo_story = 1")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue