Increase NSFW detector threshold

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-04-29 16:12:09 +02:00
parent 426e5a9f9c
commit 1e05670501
4 changed files with 27 additions and 16 deletions

View file

@ -57,6 +57,9 @@ class Config {
case "favorites": case "favorites":
this.values.count.favorites += data.count; this.values.count.favorites += data.count;
break; break;
case "private":
this.values.count.private += data.count;
break;
case "albums": case "albums":
this.values.count.albums += data.count; this.values.count.albums += data.count;
break; break;

View file

@ -264,25 +264,27 @@ func Exif(filename string) (data Data, err error) {
Lon: float64(data.Lng), Lon: float64(data.Lng),
}) })
if err != nil { if err == nil && len(zones) > 0 {
data.TimeZone = "UTC" data.TimeZone = zones[0]
} }
data.TimeZone = zones[0]
} }
if value, ok := tags["DateTimeOriginal"]; ok { if value, ok := tags["DateTimeOriginal"]; ok && value != "0000:00:00 00:00:00" {
data.TakenAtLocal, _ = time.Parse("2006:01:02 15:04:05", value) if taken, err := time.Parse("2006:01:02 15:04:05", value); err == nil {
data.TakenAtLocal = taken.Round(time.Second)
loc, err := time.LoadLocation(data.TimeZone) if data.TimeZone == "" {
data.TakenAt = data.TakenAtLocal
if err != nil { } else if loc, err := time.LoadLocation(data.TimeZone); err != nil {
data.TakenAt = data.TakenAtLocal data.TakenAt = data.TakenAtLocal
log.Warnf("no location for timezone: %s", err.Error()) log.Warnf("exif: no location for time zone %s", data.TimeZone)
} else if tl, err := time.ParseInLocation("2006:01:02 15:04:05", value, loc); err == nil { } else if tl, err := time.ParseInLocation("2006:01:02 15:04:05", value, loc); err == nil {
data.TakenAt = tl.UTC() data.TakenAt = tl.UTC()
} else {
log.Warnf("exif: %s", err.Error())
}
} else { } else {
log.Warnf("could not parse time: %s", err.Error()) log.Warnf("exif: invalid time %s", value)
} }
} }

View file

@ -15,7 +15,7 @@ import (
const ( const (
ThresholdSafe = 0.75 ThresholdSafe = 0.75
ThresholdMedium = 0.85 ThresholdMedium = 0.85
ThresholdHigh = 0.9 ThresholdHigh = 0.98
) )
var log = event.Log var log = event.Log

View file

@ -317,6 +317,12 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
"count": 1, "count": 1,
}) })
if photo.PhotoPrivate {
event.Publish("count.private", event.Data{
"count": 1,
})
}
event.EntitiesCreated("photos", []entity.Photo{photo}) event.EntitiesCreated("photos", []entity.Photo{photo})
} }
@ -432,7 +438,7 @@ func (ind *Index) NSFW(jpeg *MediaFile) bool {
return false return false
} else { } else {
if nsfwLabels.NSFW(nsfw.ThresholdHigh) { if nsfwLabels.NSFW(nsfw.ThresholdHigh) {
log.Warnf("index: \"%s\" might contain offensive content", jpeg.FileName()) log.Warnf("index: %s might contain offensive content", jpeg.RelativeName(ind.originalsPath()))
return true return true
} }
} }