instantX-research / InstantID

InstantID: Zero-shot Identity-Preserving Generation in Seconds 🔥
https://instantid.github.io/
Apache License 2.0
11.16k stars 813 forks source link

Errors when add ”num_images_per_prompt“ to batch generate pictures in gradio_demo/app.py #236

Open gaojinghua opened 6 months ago

gaojinghua commented 6 months ago

Problems descriptions: image

when add ”num_images_per_prompt“ to batch generate pictures in gradio_demo/app.py, it occurs: File "/home/gennexuslabs/data/service/ai/InstantIDAPI/./pipeline_stable_diffusion_xl_instantid_full.py", line 1040, in call encoder_hidden_states = torch.cat([prompt_embeds, prompt_image_emb], dim=1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 2 but got size 8 for tensor number 1 in the list.

Solve: img_v3_02b5_c3eba8ed-a1c3-4cf6-a798-756a2111c6ag

Reason:

image

In the "pipeline_stable_diffusion_xl_instantid_full.py" file, The encoding step may need "num_images_per_prompt" as the parameters also.

haofanwang commented 6 months ago

num_images_per_prompt have to be set to 1, you can modify to support batch inference.