diff --git a/detect-lab/Dockerfile b/detect-lab/Dockerfile index 3218fef..25be84e 100644 --- a/detect-lab/Dockerfile +++ b/detect-lab/Dockerfile @@ -3,7 +3,9 @@ FROM python:3.11-slim LABEL org.opencontainers.image.source="https://github.com/somaus/Signal-server" WORKDIR /srv -ENV DETECT_MODEL_DIR=/models DETECT_MODEL_PATH=/models/onnx/model.onnx HF_HOME=/models/.hf PYTHONUNBUFFERED=1 +# 운영 서버에서 xet(cas-server.xethub.hf.co) 연결이 시간 초과되어 일반 HTTP로 받는다. +ENV DETECT_MODEL_DIR=/models DETECT_MODEL_PATH=/models/onnx/model.onnx HF_HOME=/models/.hf PYTHONUNBUFFERED=1 \ + HF_HUB_DISABLE_XET=1 COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY preprocess.py model.py fetch_model.py app.py ./ diff --git a/docker-compose.yml b/docker-compose.yml index f2810fa..ed8c62a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,6 +33,7 @@ services: PROTECTION_MODE: ${PROTECTION_MODE:-noise} # http로 바꾸면 protection 서비스(노이즈 삽입)를 호출 PROTECTION_API_URL: http://protection:8000 DEEPFAKE_DETECTION_MODE: ${DEEPFAKE_DETECTION_MODE:-llm} # http로 바꾸면 detect 서비스(전용 탐지 모델)를 호출 + DEEPFAKE_EXPLAIN_ENABLED: ${DEEPFAKE_EXPLAIN_ENABLED:-true} # 탐지 등급에 비전 LLM 설명(근거 탭)을 붙인다. 등급은 바꾸지 못함 DEEPFAKE_DETECTION_API_URL: http://detect:8000 RISK_ANALYSIS_MODE: ${RISK_ANALYSIS_MODE:-llm} # http로 바꾸면 risk 서비스(얼굴 검출·측정)로 위험도를 계산 RISK_ANALYSIS_API_URL: http://risk:8000 diff --git a/src/main/java/com/signal/domain/deepfakedetection/detector/LlmDeepfakeExplainer.java b/src/main/java/com/signal/domain/deepfakedetection/detector/LlmDeepfakeExplainer.java index 7619c14..04729bd 100644 --- a/src/main/java/com/signal/domain/deepfakedetection/detector/LlmDeepfakeExplainer.java +++ b/src/main/java/com/signal/domain/deepfakedetection/detector/LlmDeepfakeExplainer.java @@ -44,7 +44,8 @@ public class LlmDeepfakeExplainer implements DeepfakeExplainer { { "observations": [ - {"description": "한국어 한 문장", + {"title": "근거의 핵심을 2~4단어 명사구로 요약 (예: 부자연스러운 피부 질감, 배경 경계 번짐)", + "description": "한국어 한 문장", "region": {"x":0-1,"y":0-1,"width":0-1,"height":0-1} 형태의 정규화 좌표, 특정 부위를 지목할 수 없으면 null} ] } @@ -96,7 +97,7 @@ private List toEvidences(Observations parsed, int width, int height) { continue; } evidences.add(Evidence.builder() - .type("OTHER") + .type(toTitle(observation.title())) .description(description) .region(toRegion(observation.region(), width, height)) .frame(null) @@ -105,6 +106,15 @@ private List toEvidences(Observations parsed, int width, int height) { return evidences; } + /** 탭 이름으로 쓰는 짧은 요약. 없거나 너무 길면 OTHER(프론트가 기본 이름을 붙인다). */ + static String toTitle(String title) { + if (title == null || title.isBlank()) { + return "OTHER"; + } + String trimmed = title.trim(); + return trimmed.length() > 20 || isAssertive(trimmed) ? "OTHER" : trimmed; + } + static boolean isAssertive(String description) { return ASSERTIVE_PHRASES.stream().anyMatch(description::contains); } @@ -133,7 +143,7 @@ private record Observations(List observations) { } @JsonIgnoreProperties(ignoreUnknown = true) - private record Observation(String description, NormalizedRegion region) { + private record Observation(String title, String description, NormalizedRegion region) { } @JsonIgnoreProperties(ignoreUnknown = true)