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
+15 -4
View File
@@ -285,10 +285,11 @@ func (d *Detector) detectOnce(path string) (score float64, nsfw bool, err error)
return 0, false, err
}
var out struct {
Ok bool `json:"ok"`
Error string `json:"error"`
Nsfw bool `json:"nsfw"`
Score float64 `json:"score"`
Ok bool `json:"ok"`
Error string `json:"error"`
Nsfw bool `json:"nsfw"`
Score float64 `json:"score"`
Detections []map[string]interface{} `json:"detections"`
}
if err := json.Unmarshal(data, &out); err != nil {
return 0, false, fmt.Errorf("解析检测结果失败: %v", err)
@@ -296,6 +297,16 @@ func (d *Detector) detectOnce(path string) (score float64, nsfw bool, err error)
if !out.Ok {
return 0, false, fmt.Errorf("检测服务返回错误: %s", out.Error)
}
// 打印所有检测到的类别和分数(调试用)
if len(out.Detections) > 0 {
var classes []string
for _, det := range out.Detections {
cls, _ := det["class"].(string)
sc, _ := det["score"].(float64)
classes = append(classes, fmt.Sprintf("%s:%.3f", cls, sc))
}
fmt.Printf("=== NSFW 检测详情 %s: [%s]\n", path, strings.Join(classes, ", "))
}
return out.Score, out.Nsfw, nil
}