Skip to content

Commit 1a4ff2d

Browse files
committed
fix current image in progress api when parallel processing enabled
1 parent be27fd4 commit 1a4ff2d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

modules/api/api.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
from gradio.processing_utils import encode_pil_to_base64, decode_base64_to_file, decode_base64_to_image
44
from fastapi import APIRouter, Depends, HTTPException
55
import modules.shared as shared
6-
from modules import devices
76
from modules.api.models import *
87
from modules.processing import StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img, process_images
9-
from modules.sd_samplers import all_samplers
8+
from modules.sd_samplers import all_samplers, sample_to_image, samples_to_image_grid
109
from modules.extras import run_extras, run_pnginfo
1110

1211

@@ -170,6 +169,16 @@ def progressapi(self, req: ProgressRequest = Depends()):
170169

171170
progress = min(progress, 1)
172171

172+
# copy from check_progress_call of ui.py
173+
174+
if shared.parallel_processing_allowed:
175+
if shared.state.sampling_step - shared.state.current_image_sampling_step >= shared.opts.show_progress_every_n_steps and shared.state.current_latent is not None:
176+
if shared.opts.show_progress_grid:
177+
shared.state.current_image = samples_to_image_grid(shared.state.current_latent)
178+
else:
179+
shared.state.current_image = sample_to_image(shared.state.current_latent)
180+
shared.state.current_image_sampling_step = shared.state.sampling_step
181+
173182
current_image = None
174183
if shared.state.current_image and not req.skip_current_image:
175184
current_image = encode_pil_to_base64(shared.state.current_image)

0 commit comments

Comments
 (0)