Disable text conditioning for faithful restoration
This commit is contained in:
@@ -724,6 +724,9 @@ services:
|
|||||||
HYPIR_BASE_MODEL: /models/sd2
|
HYPIR_BASE_MODEL: /models/sd2
|
||||||
HYPIR_WEIGHT_FILE: /models/hypir/HYPIR_sd2.pth
|
HYPIR_WEIGHT_FILE: /models/hypir/HYPIR_sd2.pth
|
||||||
HYPIR_DEVICE: cuda:0
|
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
|
IMAGE_DIR: /data/images
|
||||||
networks: [inference]
|
networks: [inference]
|
||||||
security_opt: ["no-new-privileges:true"]
|
security_opt: ["no-new-privileges:true"]
|
||||||
|
|||||||
@@ -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
|
reduzieren, ohne die Szene wie ein Text-zu-Bild-Modell vollständig neu zu
|
||||||
erfinden.
|
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
|
## Aufruf und Routing
|
||||||
|
|
||||||
Der OpenAI-kompatible Endpunkt bleibt `/v1/images/edits`. Das gewünschte
|
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")
|
WEIGHT_FILE = os.environ.get("HYPIR_WEIGHT_FILE", "/models/hypir/HYPIR_sd2.pth")
|
||||||
OUTPUT_DIR = Path(os.environ.get("IMAGE_DIR", "/data/images")).resolve()
|
OUTPUT_DIR = Path(os.environ.get("IMAGE_DIR", "/data/images")).resolve()
|
||||||
DEVICE = os.environ.get("HYPIR_DEVICE", "cuda:0")
|
DEVICE = os.environ.get("HYPIR_DEVICE", "cuda:0")
|
||||||
|
PROMPT_MODE = os.environ.get("HYPIR_PROMPT_MODE", "empty").strip().lower()
|
||||||
ACTIVE = False
|
ACTIVE = False
|
||||||
MODEL = None
|
MODEL = None
|
||||||
LOAD_SECONDS = 0.0
|
LOAD_SECONDS = 0.0
|
||||||
@@ -75,6 +76,12 @@ def _safe_source(name: object) -> Path:
|
|||||||
|
|
||||||
|
|
||||||
def _prompt(value: object) -> str:
|
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 ""
|
text = value.strip() if isinstance(value, str) else ""
|
||||||
operation_words = {
|
operation_words = {
|
||||||
"restauriere", "restaurieren", "restore", "verbessere", "verbessern",
|
"restauriere", "restaurieren", "restore", "verbessere", "verbessern",
|
||||||
@@ -179,8 +186,14 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
self.reply(400, {"status": "error", "message": str(exc)})
|
self.reply(400, {"status": "error", "message": str(exc)})
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
global MODEL
|
||||||
try:
|
try:
|
||||||
ThreadingHTTPServer((HOST, PORT), Handler).serve_forever()
|
ThreadingHTTPServer((HOST, PORT), Handler).serve_forever()
|
||||||
finally:
|
finally:
|
||||||
MODEL = None
|
MODEL = None
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user