2019-12-14 15:41:37 +01:00
|
|
|
/*
|
|
|
|
This package detects porn images.
|
|
|
|
|
|
|
|
Additional information can be found in our Developer Guide:
|
|
|
|
|
|
|
|
https://github.com/photoprism/photoprism/wiki/Storage
|
|
|
|
*/
|
|
|
|
|
|
|
|
package nsfw
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/photoprism/photoprism/internal/event"
|
|
|
|
)
|
|
|
|
|
|
|
|
var log = event.Log
|
|
|
|
|
|
|
|
type Labels struct {
|
|
|
|
Drawing float32
|
|
|
|
Hentai float32
|
|
|
|
Neutral float32
|
|
|
|
Porn float32
|
|
|
|
Sexy float32
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *Labels) IsSafe() bool {
|
|
|
|
return !l.NSFW()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l *Labels) NSFW() bool {
|
2019-12-14 20:35:14 +01:00
|
|
|
if l.Neutral > 0.25 {
|
2019-12-14 15:41:37 +01:00
|
|
|
return false
|
|
|
|
}
|
2019-12-14 20:35:14 +01:00
|
|
|
|
|
|
|
if l.Porn > 0.75 {
|
2019-12-14 15:41:37 +01:00
|
|
|
return true
|
|
|
|
}
|
2019-12-14 20:35:14 +01:00
|
|
|
if l.Sexy > 0.75 {
|
2019-12-14 15:41:37 +01:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
if l.Hentai > 0.75 {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|