nsfw

package
v0.0.0-...-c8acfb9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package nsfw provides detection of images that are "not safe for work" based on various categories.

Copyright (c) 2018 - 2024 PhotoPrism UG. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under Version 3 of the GNU Affero General Public License (the "AGPL"):
<https://docs.photoprism.app/license/agpl>

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

The AGPL is supplemented by our Trademark and Brand Guidelines,
which describe how our Brand Assets may be used:
<https://www.photoprism.app/trademark>

Feel free to send an email to hello@photoprism.app if you have questions, want to support our work, or just want to say hello.

Additional information can be found in our Developer Guide: <https://docs.photoprism.app/developer-guide/>

Index

Constants

View Source
const (
	ThresholdSafe   = 0.75
	ThresholdMedium = 0.85
	ThresholdHigh   = 0.98
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Detector

type Detector struct {
	// contains filtered or unexported fields
}

Detector uses TensorFlow to label drawing, hentai, neutral, porn and sexy images.

func New

func New(modelPath string) *Detector

New returns a new detector instance.

func (*Detector) File

func (t *Detector) File(filename string) (result Labels, err error)

File returns matching labels for a jpeg media file.

func (*Detector) Labels

func (t *Detector) Labels(img []byte) (result Labels, err error)

Labels returns matching labels for a jpeg media string.

type Labels

type Labels struct {
	Drawing float32
	Hentai  float32
	Neutral float32
	Porn    float32
	Sexy    float32
}

func (*Labels) IsSafe

func (l *Labels) IsSafe() bool

IsSafe returns true if the image is probably safe for work.

func (*Labels) NSFW

func (l *Labels) NSFW(threshold float32) bool

NSFW returns true if the image is may not be safe for work.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL