Enhance prompt parsing compatibility with ComfyUI Flux

pull/748/head
zanllp 2024-11-10 18:27:39 +08:00
parent 77fd0ffe66
commit cd1d02a533
2 changed files with 3 additions and 2 deletions

View File

@ -30,7 +30,7 @@ class ComfyUIParser:
else:
params = get_comfyui_exif_data(img)
info = comfyui_exif_data_to_str(params)
except Exception:
except Exception as e:
logger.error('parse comfyui image failed. prompt:')
logger.error(img.info.get('prompt'))
return ImageGenerationInfo()

View File

@ -422,7 +422,8 @@ def get_comfyui_exif_data(img: Image):
meta["Model"] = data[KSampler_entry["model"][0]]["inputs"]["ckpt_name"]
meta["Source Identifier"] = "ComfyUI"
def get_text_from_clip(idx: str) :
text = data[idx]["inputs"]["text"]
inputs = data[idx]["inputs"]
text = inputs["text"] if "text" in inputs else inputs["t5xxl"]
if isinstance(text, list): # type:CLIPTextEncode (NSP) mode:Wildcards
text = data[text[0]]["inputs"]["text"]
return text.strip()