|
5 | 5 | from gradio.processing_utils import decode_base64_to_file, decode_base64_to_image
|
6 | 6 | from fastapi import APIRouter, Depends, HTTPException
|
7 | 7 | import modules.shared as shared
|
8 |
| -from modules import devices |
9 | 8 | from modules.api.models import *
|
10 | 9 | from modules.processing import StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img, process_images
|
11 |
| -from modules.sd_samplers import all_samplers |
| 10 | +from modules.sd_samplers import all_samplers, sample_to_image, samples_to_image_grid |
12 | 11 | from modules.extras import run_extras, run_pnginfo
|
13 | 12 |
|
14 | 13 |
|
@@ -179,6 +178,16 @@ def progressapi(self, req: ProgressRequest = Depends()):
|
179 | 178 |
|
180 | 179 | progress = min(progress, 1)
|
181 | 180 |
|
| 181 | + # copy from check_progress_call of ui.py |
| 182 | + |
| 183 | + if shared.parallel_processing_allowed: |
| 184 | + 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: |
| 185 | + if shared.opts.show_progress_grid: |
| 186 | + shared.state.current_image = samples_to_image_grid(shared.state.current_latent) |
| 187 | + else: |
| 188 | + shared.state.current_image = sample_to_image(shared.state.current_latent) |
| 189 | + shared.state.current_image_sampling_step = shared.state.sampling_step |
| 190 | + |
182 | 191 | current_image = None
|
183 | 192 | if shared.state.current_image and not req.skip_current_image:
|
184 | 193 | current_image = encode_pil_to_base64(shared.state.current_image)
|
|
0 commit comments