upd
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -671,12 +672,20 @@ func (s *ScanService) runScan(ctx context.Context, rootDir, destDir string) erro
|
||||
}
|
||||
|
||||
// ---------- 第五步(可选):色情识别 ----------
|
||||
// 用本机 python + NudeNet 起一个本地检测服务。没装 python/nudenet 时跳过,
|
||||
// 不影响图片整理——检测结果只决定走普通目录还是「图片_敏感」目录。
|
||||
// 从数据库读取 NSFW 配置(支持运行时修改,立即生效)
|
||||
nsfwType := s.store.GetConfig("nsfw.type") // "" / "human" / "anime"
|
||||
pythonPath := config.GetAppConfig().NSFWPython
|
||||
|
||||
nsfwDet := (*nsfw.Detector)(nil)
|
||||
s.setNsfwDetectorReady(false)
|
||||
if cfg := config.GetAppConfig(); cfg.NSFWEnabled {
|
||||
if d, err := nsfw.Start(cfg.NSFWPython, cfg.NSFWThreshold); err != nil {
|
||||
if nsfwType == "human" {
|
||||
threshold := 0.5
|
||||
if v := s.store.GetConfig("nsfw.threshold"); v != "" {
|
||||
if t, err := strconv.ParseFloat(v, 64); err == nil && t > 0 && t < 1 {
|
||||
threshold = t
|
||||
}
|
||||
}
|
||||
if d, err := nsfw.Start(pythonPath, threshold); err != nil {
|
||||
fmt.Printf("=== 色情识别未启用(图片照常处理): %v\n", err)
|
||||
} else {
|
||||
nsfwDet = d
|
||||
@@ -687,10 +696,15 @@ func (s *ScanService) runScan(ctx context.Context, rootDir, destDir string) erro
|
||||
}
|
||||
|
||||
// ---------- 第六步(可选):动漫色情识别 ----------
|
||||
// 用本机 python + WD Tagger v3 起一个本地检测服务。没装 python/onnxruntime 时跳过。
|
||||
animeNsfwDet := (*anime_nsfw.Detector)(nil)
|
||||
if cfg := config.GetAppConfig(); cfg.AnimeNSFWEnabled {
|
||||
if d, err := anime_nsfw.Start(cfg.NSFWPython, cfg.AnimeNSFWThreshold); err != nil {
|
||||
if nsfwType == "anime" {
|
||||
threshold := 0.5
|
||||
if v := s.store.GetConfig("anime.threshold"); v != "" {
|
||||
if t, err := strconv.ParseFloat(v, 64); err == nil && t > 0 && t < 1 {
|
||||
threshold = t
|
||||
}
|
||||
}
|
||||
if d, err := anime_nsfw.Start(pythonPath, threshold); err != nil {
|
||||
fmt.Printf("=== 动漫色情识别未启用(图片照常处理): %v\n", err)
|
||||
} else {
|
||||
animeNsfwDet = d
|
||||
|
||||
Reference in New Issue
Block a user