|
3 | 3 | from gradio.processing_utils import encode_pil_to_base64, decode_base64_to_file, decode_base64_to_image
|
4 | 4 | from fastapi import APIRouter, Depends, HTTPException
|
5 | 5 | import modules.shared as shared
|
6 |
| -from modules import devices |
7 | 6 | from modules.api.models import *
|
8 | 7 | 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 |
10 | 9 | from modules.extras import run_extras, run_pnginfo
|
11 | 10 |
|
12 | 11 |
|
@@ -170,6 +169,16 @@ def progressapi(self, req: ProgressRequest = Depends()):
|
170 | 169 |
|
171 | 170 | progress = min(progress, 1)
|
172 | 171 |
|
| 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 | + |
173 | 182 | current_image = None
|
174 | 183 | if shared.state.current_image and not req.skip_current_image:
|
175 | 184 | current_image = encode_pil_to_base64(shared.state.current_image)
|
|
0 commit comments