Disable text conditioning for faithful restoration

This commit is contained in:
Mikei386 committed 2026-09-08 08:52:49 +02:00
1 parent 3220a67f1b
commit f82dc081c9
3 files changed
+27 -5

No files matched your search

@@ -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:
ThreadingHTTPServer((HOST, PORT), Handler).serve_forever()
finally:
MODEL = None
gc.collect()
def main() -> None:
global MODEL
try:
ThreadingHTTPServer((HOST, PORT), Handler).serve_forever()
finally:
MODEL = None
gc.collect()
if __name__ == "__main__":
main()