Remove ineffective photo restoration pipeline
This commit is contained in:
@@ -4,11 +4,8 @@ Hermes backend plugin for the OpenAI-compatible image API exposed by the
|
||||
Athena profile router. The router starts the local FLUX worker on demand,
|
||||
unloads the active LLM and Qwen3-TTS, and restores both after generation.
|
||||
|
||||
When the explicit Hermes model `restauration` is selected, reference-image
|
||||
requests are routed to Athena's `HYPIR-SD2` worker. Creative edits in every
|
||||
normal chat model continue to use FLUX. Prompt text is deliberately never used
|
||||
for routing, so words such as "improve" cannot accidentally switch pipelines.
|
||||
No second Hermes provider or desktop installation is required.
|
||||
Reference-image requests use FLUX for creative edits. No second Hermes
|
||||
provider or desktop installation is required.
|
||||
|
||||
## Gateway installation
|
||||
|
||||
@@ -46,7 +43,6 @@ second computer connected to the same gateway needs no plugin installation.
|
||||
Optional overrides:
|
||||
|
||||
- `ATHENA_IMAGE_MODEL` defaults to `FLUX.2-klein-9B-fp8-beta`.
|
||||
- `ATHENA_RESTORATION_MODEL` defaults to `HYPIR-SD2`.
|
||||
- `ROUTER_API_KEY` is accepted as a migration fallback.
|
||||
- An existing `HERMES_CUSTOM_192_168_1_212_8081_API_KEY` is accepted as the
|
||||
final fallback, so an existing Athena chat-provider setup needs no duplicate
|
||||
|
||||
@@ -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}",
|
||||
|
||||
Reference in New Issue
Block a user