feat: 目录层级变更

This commit is contained in:
2025-09-24 21:19:55 +08:00
parent 7792f9281c
commit 72c9d67d9b
12 changed files with 156 additions and 317 deletions
+1 -5
View File
@@ -284,7 +284,6 @@ class Handler(BaseHTTPRequestHandler):
try:
body = json.loads(self.rfile.read(length) or b"{}")
path = body.get("path", "")
threshold = float(body.get("threshold", 0.5))
if not path:
return self._send({"ok": False, "error": "缺少图片路径"})
# 丢给推理线程池:读文件并行、推理由 N 个 worker 并行处理
@@ -293,16 +292,13 @@ class Handler(BaseHTTPRequestHandler):
return self._send({"ok": False, "error": str(exc)})
max_score = 0.0
nsfw = False
for det in detections or []:
cls = det.get("class", "")
sc = float(det.get("score", 0) or 0)
if cls in SENSITIVE:
if sc > max_score:
max_score = sc
if sc >= threshold:
nsfw = True
self._send({"ok": True, "nsfw": nsfw, "score": max_score, "detections": detections})
self._send({"ok": True, "score": max_score, "detections": detections})
def log_message(self, *args): # 不刷屏
pass