Remove ineffective photo restoration pipeline

This commit is contained in:
Mikei386
2026-09-08 09:40:43 +02:00
parent f82dc081c9
commit e82e0340e4
9 changed files with 17 additions and 552 deletions
+3 -44
View File
@@ -34,7 +34,6 @@ _SIZES = {
}
_DEFAULT_BASE_URL = "http://192.168.1.212:8081/v1"
_DEFAULT_MODEL = "FLUX.2-klein-9B-fp8-beta"
_DEFAULT_RESTORATION_MODEL = "HYPIR-SD2"
_MAX_IMAGE_BYTES = 20 * 1024 * 1024
@@ -48,34 +47,6 @@ def _model() -> str:
return os.environ.get("ATHENA_IMAGE_MODEL", "").strip() or _DEFAULT_MODEL
def _restoration_model() -> str:
return (os.environ.get("ATHENA_RESTORATION_MODEL", "").strip()
or _DEFAULT_RESTORATION_MODEL)
def _restoration_profile_selected() -> bool:
"""Use HYPIR only when Hermes explicitly selected the restoration model."""
try:
from hermes_cli.config import load_config
config = load_config()
model = config.get("model") if isinstance(config, dict) else None
selected = model.get("default") if isinstance(model, dict) else None
return isinstance(selected, str) and selected.casefold() in {
"restauration", "restoration", "qwen-restoration",
}
except Exception:
return False
def _select_model(requested: object) -> str:
"""Resolve an explicit image/profile selection; never inspect prompt text."""
if _restoration_profile_selected():
return _restoration_model()
if isinstance(requested, str) and requested.strip() == _restoration_model():
return _restoration_model()
return _model()
def _api_key() -> str:
"""Prefer a scoped key; accept the existing router key for migration."""
return (
@@ -145,12 +116,6 @@ class AthenaLocalImageProvider(ImageGenProvider):
"speed": "local",
"strengths": "Private local generation and multi-reference editing",
"price": "local / no cloud",
}, {
"id": _restoration_model(),
"display": "HYPIR-SD2 Restoration on Athena",
"speed": "local",
"strengths": "Faithful denoise, deblur and photo restoration",
"price": "local / no cloud",
}]
def default_model(self) -> Optional[str]:
@@ -213,10 +178,9 @@ class AthenaLocalImageProvider(ImageGenProvider):
sources.append(image_url.strip())
sources.extend(normalize_reference_images(reference_image_urls) or [])
# Hermes may expose the primary upload through both ``image_url`` and
# ``reference_image_urls``. Preserve order while removing duplicates;
# restoration deliberately accepts exactly one physical source image.
# ``reference_image_urls``. Preserve order while removing duplicates.
sources = list(dict.fromkeys(sources))[:4]
model = _select_model(kwargs.get("model"))
model = _model()
try:
encoded_sources = [
base64.b64encode(_load_private_image(source)).decode("ascii")
@@ -243,9 +207,6 @@ class AthenaLocalImageProvider(ImageGenProvider):
endpoint = "edits"
request_data["image_b64"] = encoded_sources[0]
request_data["reference_images_b64"] = encoded_sources[1:]
if model == _restoration_model():
request_data.update({"upscale": 1, "patch_size": 512,
"stride": 256})
request = urllib.request.Request(
f"{base_url}/images/{endpoint}",
data=json.dumps(request_data).encode("utf-8"), method="POST",
@@ -283,9 +244,7 @@ class AthenaLocalImageProvider(ImageGenProvider):
prompt=clean_prompt, aspect_ratio=aspect)
try:
prefix = ("athena_hypir" if model == _restoration_model()
else "athena_flux2")
saved = save_b64_image(b64_data, prefix=prefix)
saved = save_b64_image(b64_data, prefix="athena_flux2")
except Exception as exc:
return error_response(
error=f"Generated image could not be saved: {exc}",