mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-01-26 19:09:45 +00:00
Merge pull request #1531 from DenOfEquity/fix-the-hrfix-fix
Update txt2img.py: fix the hrfix fix
This commit is contained in:
@@ -58,11 +58,18 @@ def txt2img_create_processing(id_task: str, request: gr.Request, prompt: str, ne
|
||||
|
||||
def txt2img_upscale_function(id_task: str, request: gr.Request, gallery, gallery_index, generation_info, *args):
|
||||
assert len(gallery) > 0, 'No image to upscale'
|
||||
assert 0 <= gallery_index < len(gallery), f'Bad image index: {gallery_index}'
|
||||
|
||||
if gallery_index < 0 or gallery_index >= len(gallery):
|
||||
return gallery, generation_info, f'Bad image index: {gallery_index}', ''
|
||||
|
||||
geninfo = json.loads(generation_info)
|
||||
|
||||
# catch situation where user tries to hires-fix the grid: probably a mistake, results can be bad aspect ratio - just don't do it
|
||||
if opts.return_grid and 0 == gallery_index and len(gallery) > 1:
|
||||
return gallery, generation_info, 'Unable to upscale the grid image.', ''
|
||||
first_image_index = geninfo.get('index_of_first_image', 0)
|
||||
# catch if user tries to upscale a control image, this function will fail later trying to get infotext that doesn't exist
|
||||
count_images = len(geninfo.get('infotexts')) # note: we have batch_size in geninfo, but not batch_count
|
||||
if len(gallery) > 1 and (gallery_index < first_image_index or gallery_index >= count_images):
|
||||
return gallery, generation_info, 'Unable to upscale grid or control images.', ''
|
||||
|
||||
p = txt2img_create_processing(id_task, request, *args, force_enable_hr=True)
|
||||
p.batch_size = 1
|
||||
@@ -70,8 +77,6 @@ def txt2img_upscale_function(id_task: str, request: gr.Request, gallery, gallery
|
||||
# txt2img_upscale attribute that signifies this is called by txt2img_upscale
|
||||
p.txt2img_upscale = True
|
||||
|
||||
geninfo = json.loads(generation_info)
|
||||
|
||||
image_info = gallery[gallery_index]
|
||||
p.firstpass_image = infotext_utils.image_from_url_text(image_info)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user