mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-07-13 20:21:16 -03:00
fix(recipe): fallback to locate custom example image on disk by model hash and image id (#1012)
This commit is contained in:
@@ -2218,6 +2218,31 @@ class RecipeManagementHandler:
|
|||||||
"Failed to download image for recipe: %s", exc
|
"Failed to download image for recipe: %s", exc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Fallback: try to locate a custom image on disk using model_hash + image id
|
||||||
|
if image_bytes is None:
|
||||||
|
image_id = image_data.get("id") or ""
|
||||||
|
if image_id and model_hash:
|
||||||
|
from ...utils.example_images_paths import get_model_folder
|
||||||
|
model_folder = get_model_folder(model_hash)
|
||||||
|
if model_folder and os.path.exists(model_folder):
|
||||||
|
for fname in os.listdir(model_folder):
|
||||||
|
if f"custom_{image_id}" in fname:
|
||||||
|
ext = os.path.splitext(fname)[1].lower()
|
||||||
|
if ext not in (".jpg", ".jpeg", ".png", ".webp", ".gif"):
|
||||||
|
continue
|
||||||
|
fpath = os.path.join(model_folder, fname)
|
||||||
|
if os.path.isfile(fpath):
|
||||||
|
try:
|
||||||
|
with open(fpath, "rb") as f:
|
||||||
|
image_bytes = f.read()
|
||||||
|
extension = ext
|
||||||
|
except Exception as exc:
|
||||||
|
self._logger.warning(
|
||||||
|
"Failed to read custom image file %s: %s",
|
||||||
|
fpath, exc,
|
||||||
|
)
|
||||||
|
break
|
||||||
|
|
||||||
prompt = (
|
prompt = (
|
||||||
(parsed.get("gen_params") or {}).get("prompt") or ""
|
(parsed.get("gen_params") or {}).get("prompt") or ""
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user