refactor: 移除二次元识别功能,增强 NSFW 检测

This commit is contained in:
2025-07-12 21:04:52 +08:00
parent 2778393e9d
commit f589592535
17 changed files with 43 additions and 12217 deletions
+5 -17
View File
@@ -19,12 +19,10 @@ import (
// - FFmpegPath:ffmpeg 程序路径(用于把带 EXIF 旋转标记的图片转正);留空自动在 PATH 里找
// - RotateImages:是否处理图片 EXIF 旋转(默认 true);false 则完全不处理,按存储方向/尺寸归类
// - Workers:探测/MIME/移动阶段的并发 worker 数(默认 4;设 0 表示用满全部 CPU 核数)
// - MoveFiles:扫描完成后是否移动文件到分类目录(默认 true)
// - NSFWEnabled:是否开启色情图片识别(本地 python + NudeNet,默认 false)
// - NSFWPython:python 可执行文件路径;留空自动在 PATH 里找
// - NSFWThreshold:判定阈值 0~1(默认 0.5)
// - HentaiEnabled:是否开启二次元图片识别(本地 python + wd-tagger,默认 false)
// - HentaiPython:python 可执行文件路径;留空自动在 PATH 里找
// - HentaiThreshold:判定阈值 0~1(默认 0.5)
type Config struct {
Port int
Dsn string
@@ -32,12 +30,10 @@ type Config struct {
FFmpegPath string
RotateImages bool
Workers int
MoveFiles bool
NSFWEnabled bool
NSFWPython string
NSFWThreshold float64
HentaiEnabled bool
HentaiPython string
HentaiThreshold float64
}
// appConfig 当前生效的配置(程序运行期间一直不变)。
@@ -51,7 +47,7 @@ func GetAppConfig() Config {
// LoadAppConfig 从 application.properties 读配置;文件不存在就用默认值。
func LoadAppConfig() {
// 先给一套默认值
appConfig = Config{Port: 8080, Dsn: "media-info.db", AutoOpen: true, RotateImages: true, Workers: 4, NSFWThreshold: 0.5, HentaiThreshold: 0.5}
appConfig = Config{Port: 8080, Dsn: "media-info.db", AutoOpen: true, RotateImages: true, Workers: 4, MoveFiles: true, NSFWThreshold: 0.5}
p, err := properties.LoadFile("application.properties", properties.UTF8)
if err != nil {
@@ -76,6 +72,8 @@ func LoadAppConfig() {
appConfig.Workers = n
}
}
// 扫描完成后是否移动文件:默认 true
appConfig.MoveFiles = p.GetBool("organize.moveFiles", true)
// 色情识别:默认关;python 路径留空自动在 PATH 找;阈值只认 0~1 之间的小数
appConfig.NSFWEnabled = p.GetBool("nsfw.enabled", false)
if v, ok := p.Get("nsfw.python"); ok && v != "" {
@@ -86,16 +84,6 @@ func LoadAppConfig() {
appConfig.NSFWThreshold = t
}
}
// 二次元识别:默认关;python 路径留空自动在 PATH 找;阈值只认 0~1 之间的小数
appConfig.HentaiEnabled = p.GetBool("hentai.enabled", false)
if v, ok := p.Get("hentai.python"); ok && v != "" {
appConfig.HentaiPython = v
}
if v, ok := p.Get("hentai.threshold"); ok && strings.TrimSpace(v) != "" {
if t, err := strconv.ParseFloat(strings.TrimSpace(v), 64); err == nil && t > 0 && t < 1 {
appConfig.HentaiThreshold = t
}
}
}
// WorkerCount 返回探测/MIME/移动阶段使用的并发 worker 数: