AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
140.6k stars 26.61k forks source link

[Bug]: Batch images generated through the API don't create a grid #7391

Open watzon opened 1 year ago

watzon commented 1 year ago

Is there an existing issue for this?

What happened?

The sdapi/v1/txt2img endpoint doesn't create grids when doing batches. Happens with both the batch_size and n_iter parameters.

Steps to reproduce the problem

  1. Generate a 4 image batch through the API
  2. 4 images are returned, no grid is saved

What should have happened?

Ideally I'd like the ability to tell it whether or not to return the grid, but it should always be saved according to the user's settings.

Commit where the problem happens

master

What platforms do you use to access the UI ?

No response

What browsers do you use to access the UI ?

No response

Command Line Arguments

--xformers

List of extensions

auto-sd-paint-ext https://github.com/Interpause/auto-sd-paint-ext unknown
stable-diffusion-webui-images-browser https://github.com/yfszzx/stable-diffusion-webui-images-browser unknown
stable-diffusion-webui-instruct-pix2pix https://github.com/Klace/stable-diffusion-webui-instruct-pix2pix.git unknown
stable-diffusion-webui-promptgen https://github.com/AUTOMATIC1111/stable-diffusion-webui-promptgen.git unknown
LDSR built-in  
Lora built-in  
ScuNET built-in  
SwinIR built-in  
prompt-bracket-checker built-in

Console logs

./webui.sh --xformers

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on watzon user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Python 3.10.9 (main, Dec  7 2022, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)]
Commit hash: 7a14c8ab45da8a681792a6331d48a88dd684a0a9
Installing requirements for Web UI
[auto-sd-paint-ext] Commit hash: ff82c1dcf9309138d8f5c07546ca26e46ea8c3b7
[auto-sd-paint-ext] Auto-update disabled.

Launching Web UI with arguments: --xformers --api
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Loading weights [d8691b4d16] from /home/watzon/AI/stable-diffusion-webui/models/Stable-diffusion/deliberate_v11.safetensors
Loading VAE weights specified in settings: /home/watzon/AI/stable-diffusion-webui/models/Stable-diffusion/vae-ft-mse-840000-ema-pruned.vae.pt
Applying xformers cross attention optimization.
Textual inversion embeddings loaded(39): ...
Model loaded in 2.4s (0.3s create model, 1.8s load weights).
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
auto-sd-paint-ext:INFO: Add --listen to COMMANDLINE_ARGS to enable usage as a remote backend.
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:06<00:00,  4.53it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:06<00:00,  4.85it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:06<00:00,  4.83it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:06<00:00,  4.81it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:06<00:00,  4.81it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:06<00:00,  4.80it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:06<00:00,  4.80it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:06<00:00,  4.79it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:03<00:00,  5.09it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:03<00:00,  5.10it/s]
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:03<00:00,  5.09it/s]

Additional information

No response

DenkingOfficial commented 1 year ago

Agree I guess there is override in api.py file, line 184 Is there a way to get grid from api response?

chimojiacai commented 1 year ago

my current implementation method is to get a single image, and then splice the single image into a grid through code

kalebbroo commented 1 year ago

This has not been resolved right? I think im going to have PIL merge the images into a grid to display in Discord. If anyone knows of a better way please let me know.

zmhgit commented 9 months ago

batch_size=4, the generated pictures are still four pictures, and there is no grid diagram on the webui. How should I deal with this problem

zmhgit commented 9 months ago

这还没解决吧?我想我会让 PIL 将图像合并到网格中以在 Discord 中显示。如果有人知道更好的方法请告诉我。

这还没解决吧?我想我把PIL将图像合并到网格中以在Discord中显示。如果有人知道更好的方法请告诉我。

May I ask how to solve this problem? Do you need to set parameters to directly return to the grid diagram or do you need to manually concatenate the code