stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Bug]: SD upscale error on second tile

Open Ladypoly opened this issue 3 years ago • 16 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What happened?

SD upscale stops after finishing the first tile and throws an error.

Steps to reproduce the problem

  1. Go to img2img
  2. Select SD Upscale
  3. Select SwinIR_4x

What should have happened?

Generate all necessary tiles.

Commit where the problem happens

d35bf649456da2558cbb6f2ea16fa1606022b7e7

What platforms do you use to access UI ?

Windows

What browsers do you use to access the UI ?

Mozilla Firefox

Command Line Arguments

"--ckpt-dir=D:\StableDiffusion/SD_Models" --xformers --deepdanbooru "--vae-path=D:\StableDiffusion/SD_Models/ft-MSE/vae-ft-mse-840000-ema-pruned.vae.pt" --api --autolaunch

Additional information, context and logs

SD upscale throws a error after completing the first tile.

SwinIR tiles: 100%|████████████████████████████████████████████████████████████████████| 15/15 [00:12<00:00, 1.19it/s] SD upscaling will process a total of 9 images tiled as 3x3 per upscale in a total of 9 batches. 100%|██████████████████████████████████████████████████████████████████████████████████| 23/23 [00:03<00:00, 7.07it/s] Error completing request████▏ | 23/207 [00:03<00:25, 7.26it/s] Arguments: (0, 'A (cyberpunk :1.2)castle with a river in front and fireworks in the sky, 8 k, unreal engine, octane, trending on artstation', '', 'None', 'None', <PIL.Image.Image image mode=RGB size=832x512 at 0x1A560473DF0>, None, None, None, 0, 150, 0, 4, 0, False, False, 1, 1, 7, 0.15, 4277678666.0, -1.0, 0, 0, 0, False, 512, 832, 0, False, 32, 0, '', '', 13, 0.9, 5, '0.0001', False, 'None', '', 0.1, False, 'Not set', 'Not set', 'Not set', 'Not set', 'No focus', '', True, False, '

    \n
  • CFG Scale should be 2 or lower.
  • \n
\n', True, True, '', '', True, 50, True, 1, 0, False, None, '', 0.2, 0.1, 1, 1, False, True, True, False, False, False, False, 4, 1, 4, 0.09, True, 1, 0, 7, False, False, 0, 0, 'Show/Hide Canvas', 0, '

Recommended settings: Sampling Steps: 80-100, Sampler: Euler a, Denoising strength: 0.8

', 128, 8, ['left', 'right', 'up', 'down'], 1, 0.05, 128, 4, 0, ['left', 'right', 'up', 'down'], False, False, None, '', '

Will upscale the image to twice the dimensions; use width and height sliders to set tile size

', 64, 8, 10.0, True, 30.0, True, 'Illustration', 'svg', True, True, False, 0.5, 1, '', 0, '', True, True, False, 1.0, 2.0, 'a painting in', 'style', 'picture frame, portrait photo', None) {}

Traceback (most recent call last): File "D:\StableDiffusion\stable-diffusion-webui\modules\ui.py", line 185, in f res = list(func(*args, **kwargs)) File "D:\StableDiffusion\stable-diffusion-webui\webui.py", line 54, in f res = func(*args, **kwargs) File "D:\StableDiffusion\stable-diffusion-webui\modules\img2img.py", line 135, in img2img processed = modules.scripts.scripts_img2img.run(p, *args) File "D:\StableDiffusion\stable-diffusion-webui\modules\scripts.py", line 282, in run processed = script.run(p, *script_args) File "D:\StableDiffusion\stable-diffusion-webui\scripts\sd_upscale.py", line 75, in run processed = processing.process_images(p) File "D:\StableDiffusion\stable-diffusion-webui\modules\processing.py", line 427, in process_images res = process_images_inner(p) File "D:\StableDiffusion\stable-diffusion-webui\modules\processing.py", line 487, in process_images_inner with torch.no_grad(), p.sd_model.ema_scope(): AttributeError: 'NoneType' object has no attribute 'ema_scope'

Ladypoly avatar Nov 01 '22 11:11 Ladypoly

same problem with img2tiles AttributeError: 'NoneType' object has no attribute 'ema_scope'` error after update

chifeisoong avatar Nov 01 '22 12:11 chifeisoong

img2img loopback has the same problem

slashedstar avatar Nov 01 '22 12:11 slashedstar

Batch img2img has the same problem

akino-germany avatar Nov 01 '22 13:11 akino-germany

I can't test right now but I'm going to go out on a limb that https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/f126986b76a4129061c85cd7213cde05a2f63b33 is a probable reason for this. The error is happening in processing.py and this is the only change to processing.py in the past day.

File "D:\StableDiffusion\stable-diffusion-webui\modules\processing.py", line 487, in process_images_inner
with torch.no_grad(), p.sd_model.ema_scope():
AttributeError: 'NoneType' object has no attribute 'ema_scope'

Changes made to processing.py with that commit.

     if p.scripts is not None:
         p.scripts.postprocess(p, res)

+    p.sd_model = None
+    p.sampler = None

    return res

Can't test myself, but try going to a commit (git checkout 5b0f624bdc1335313258f59a37607e699e800c22) before this one. Alternatively commenting out those 2 lines in processing.py might resolve those features not working.

Quoting the PR:

PS: I confirmed that the x/y plot still adds and keeps references, but I couldn't find what part of the code was keeping the references. I cannot run all features, but the basic workflow of txt2img/img2img > change model to inpaint > inpaint > change model back is working without leak.

rabidcopy avatar Nov 01 '22 14:11 rabidcopy

Not sure of repercussions elsewhere, but commenting out these two lines gets batch img2img working again:

p.sd_model = None
p.sampler = None

MichaelCarychao avatar Nov 01 '22 14:11 MichaelCarychao

I'm getting this issue with the Wildcard and inpainting scripts as well.

jrjustiss avatar Nov 01 '22 17:11 jrjustiss

getting this error when running loopback

AttributeError: 'NoneType' object has no attribute 'ema_scope'

Commit hash: 198a1ffcfc963a3d74674fad560e87dbebf7949f

jonwong666 avatar Nov 01 '22 17:11 jonwong666

Has anyone got loopback to work? I tried commenting those 2 lines but doesn't seem to be having any effect. Not sure if I'm doing something wrong...

TiagoTiago avatar Nov 01 '22 19:11 TiagoTiago

Has anyone got loopback to work? I tried commenting those 2 lines but doesn't seem to be having any effect. Not sure if I'm doing something wrong...

Sharing the error output you get might help, there may be more issues beyond just those two lines.

rabidcopy avatar Nov 01 '22 20:11 rabidcopy

Loopback Error: Traceback (most recent call last): File "C:\Users\AAAA\stable-diffusion-webui\modules\ui.py", line 185, in f res = list(func(*args, **kwargs)) File "C:\Users\AAAA\stable-diffusion-webui\webui.py", line 54, in f res = func(*args, **kwargs) File "C:\Users\AAAA\stable-diffusion-webui\modules\img2img.py", line 136, in img2img processed = modules.scripts.scripts_img2img.run(p, *args) File "C:\Users\AAAA\stable-diffusion-webui\modules\scripts.py", line 282, in run processed = script.run(p, *script_args) File "C:\Users\AAAA\stable-diffusion-webui\scripts\loopback.py", line 62, in run processed = processing.process_images(p) File "C:\Users\AAAA\stable-diffusion-webui\modules\processing.py", line 427, in process_images res = process_images_inner(p) File "C:\Users\AAAA\stable-diffusion-webui\modules\processing.py", line 487, in process_images_inner with torch.no_grad(), p.sd_model.ema_scope(): AttributeError: 'NoneType' object has no attribute 'ema_scope'

Medelisa avatar Nov 01 '22 20:11 Medelisa

Has anyone got loopback to work? I tried commenting those 2 lines but doesn't seem to be having any effect. Not sure if I'm doing something wrong...

yes, just # comment out the two lines in \modules\processing.py

p.sd_model = None

p.sampler = None

loopback now working

jonwong666 avatar Nov 01 '22 20:11 jonwong666

Has anyone got loopback to work? I tried commenting those 2 lines but doesn't seem to be having any effect. Not sure if I'm doing something wrong...

Sharing the error output you get might help, there may be more issues beyond just those two lines.

I'm getting the same messages as what Medelisa posted, and pretty close to OP's (different prompt and stuff).

TiagoTiago avatar Nov 01 '22 20:11 TiagoTiago

Has anyone got loopback to work? I tried commenting those 2 lines but doesn't seem to be having any effect. Not sure if I'm doing something wrong...

Sharing the error output you get might help, there may be more issues beyond just those two lines.

I'm getting the same messages as what Medelisa posted, and pretty close to OP's (different prompt and stuff).

make sure you are not updating the repo (disable autp update / git pull ) everytime you change the processing,py and restarting webUI. ( u need to restart the program )

jonwong666 avatar Nov 01 '22 20:11 jonwong666

Had saved and restarted countless times before; somehow this time it seems to have worked....

TiagoTiago avatar Nov 01 '22 20:11 TiagoTiago

I made a mistake in a previous PR, I just sent a new PR #4142 to solve it, sorry for the trouble.

jn-jairo avatar Nov 02 '22 01:11 jn-jairo

Has anyone got loopback to work? I tried commenting those 2 lines but doesn't seem to be having any effect. Not sure if I'm doing something wrong...

yes, just # comment out the two lines in \modules\processing.py

p.sd_model = None

p.sampler = None

loopback now working

So I have that problem in batch and i tried doing this. I tried the # just before the p, one space away and at the beginning of the line because I'm not a programmer. However, I end up with another error when trying to run batch img2img: AttributeError: 'NoneType' object has no attribute 'getexif'

Anonym121 avatar Nov 03 '22 22:11 Anonym121

Has anyone got loopback to work? I tried commenting those 2 lines but doesn't seem to be having any effect. Not sure if I'm doing something wrong...

yes, just # comment out the two lines in \modules\processing.py

p.sd_model = None

p.sampler = None

loopback now working

I am a complete newbie. How can I edit these files? I can not find this modules/processing.py file anywhere.

SweetScore avatar Nov 24 '22 00:11 SweetScore