Disable text conditioning for faithful restoration

This commit is contained in:
Mikei386
2026-09-08 08:52:49 +02:00
parent 3220a67f1b
commit f82dc081c9
3 changed files with 27 additions and 5 deletions
+3
View File
@@ -724,6 +724,9 @@ services:
HYPIR_BASE_MODEL: /models/sd2
HYPIR_WEIGHT_FILE: /models/hypir/HYPIR_sd2.pth
HYPIR_DEVICE: cuda:0
# Empty conditioning avoids prompt-driven repainting in the conservative
# restoration profile. Set to passthrough only for deliberate experiments.
HYPIR_PROMPT_MODE: "empty"
IMAGE_DIR: /data/images
networks: [inference]
security_opt: ["no-new-privileges:true"]
+6
View File
@@ -10,6 +10,12 @@ Referenzbilder verwendet und soll Rauschen, Unschärfe und Kompressionsschäden
reduzieren, ohne die Szene wie ein Text-zu-Bild-Modell vollständig neu zu
erfinden.
Das Produktionsprofil verwendet absichtlich eine leere HYPIR-Textkonditionierung
(`HYPIR_PROMPT_MODE=empty`). Ausführliche Beschreibungen des Bildinhalts können
bei dem Stable-Diffusion-basierten Modell sonst neue Texturen und Details
erzwingen. Hermes versteht weiterhin die Benutzeranweisung; der Restaurations-
Worker erhält für die eigentliche Rekonstruktion jedoch keinen Kreativprompt.
## Aufruf und Routing
Der OpenAI-kompatible Endpunkt bleibt `/v1/images/edits`. Das gewünschte
@@ -24,6 +24,7 @@ BASE_MODEL = os.environ.get("HYPIR_BASE_MODEL", "/models/sd2")
WEIGHT_FILE = os.environ.get("HYPIR_WEIGHT_FILE", "/models/hypir/HYPIR_sd2.pth")
OUTPUT_DIR = Path(os.environ.get("IMAGE_DIR", "/data/images")).resolve()
DEVICE = os.environ.get("HYPIR_DEVICE", "cuda:0")
PROMPT_MODE = os.environ.get("HYPIR_PROMPT_MODE", "empty").strip().lower()
ACTIVE = False
MODEL = None
LOAD_SECONDS = 0.0
@@ -75,6 +76,12 @@ def _safe_source(name: object) -> Path:
def _prompt(value: object) -> str:
# HYPIR inherits text-guided texture synthesis from Stable Diffusion. For
# the explicit restoration profile fidelity is more important than
# creativity, so the production default disables text conditioning. A
# future experimental profile can opt back into it without changing code.
if PROMPT_MODE == "empty":
return ""
text = value.strip() if isinstance(value, str) else ""
operation_words = {
"restauriere", "restaurieren", "restore", "verbessere", "verbessern",
@@ -179,8 +186,14 @@ class Handler(BaseHTTPRequestHandler):
self.reply(400, {"status": "error", "message": str(exc)})
try:
def main() -> None:
global MODEL
try:
ThreadingHTTPServer((HOST, PORT), Handler).serve_forever()
finally:
finally:
MODEL = None
gc.collect()
if __name__ == "__main__":
main()