You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ErnieImagePipeline builds callback kwargs via locals() in a dict comprehension, which is scope-fragile and may cause callback lookup issues. I will submit a PR with a safe explicit-loop fix.
Reproduction
importtorchfromdiffusersimportErnieImagePipelinedefon_step_end(pipe, step, timestep, callback_kwargs):
latents=callback_kwargs["latents"]
print(f"[callback] step={step}")
return {}
defmain():
model_id="PaddlePaddle/ERNIE-Image/"pipe=ErnieImagePipeline.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
).to("cuda")
image=pipe(
prompt="A tiny red car on a rainy street at dusk, cinematic lighting",
height=512,
width=512,
num_inference_steps=8,
guidance_scale=1.0,
use_pe=False, # keep demo minimal and deterministiccallback_on_step_end=on_step_end,
callback_on_step_end_tensor_inputs=["latents"],
).images[0]
image.save("output.png")
if__name__=="__main__":
main()
Logs
<details><summary>Traceback</summary>
Traceback (most recent call last):
File "/root/workspace/demo.py", line 35, in<module>main()
File "/root/workspace/demo.py", line 19, in main
image = pipe(
File "/usr/local/lib/python3.10/dist-packages/torch/utils/_contextlib.py", line 120, in decorate_context
return func(*args, **kwargs)
File "/root/workspace/diffusers/src/diffusers/pipelines/ernie_image/pipeline_ernie_image.py", line 355, in __call__
callback_kwargs = {k: locals()[k] forkin callback_on_step_end_tensor_inputs}
File "/root/workspace/diffusers/src/diffusers/pipelines/ernie_image/pipeline_ernie_image.py", line 355, in<dictcomp>
callback_kwargs = {k: locals()[k] forkin callback_on_step_end_tensor_inputs}
KeyError: 'latents'
System Info
Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.
Activity