AIrjen/OneButtonPrompt

Pretty consistent (but not all the time) error.

Closed this issue · 12 comments

I get this message a lot. I'm not extremely tec savvy, so it might be slightly different each time, but it always ends the same way. It does not always happen though. It seems rather random. I'm never able to produce a long list of images though, since it is more likely to happen than not if I'm running even 4 image generations at a time. Anything higher than that is doomed for me personally.
Here is the command lines and error:

Setting insanity level to 5
adding something rare to the prompt
Nice! adding something legendary to the prompt
extreme wide shot of a Dunmer with a Elk, Geass, Face mask, from inside of a Impressive Hotel, at Dusk, Knightcore, 50mm
Going to run with sampling method Heun
Going to run with upscaler Latent (nearest-exact)
Traceback (most recent call last):
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\gradio\routes.py", line 422, in run_predict
output = await app.get_blocks().process_api(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\gradio\blocks.py", line 1323, in process_api
result = await self.call_function(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\gradio\blocks.py", line 1051, in call_function
prediction = await anyio.to_thread.run_sync(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio_backends_asyncio.py", line 807, in run
result = context.run(func, *args)
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\extensions\OneButtonPrompt\main.py", line 140, in generateimages
txt2img = call_txt2img(randomprompt, size ,hiresfix, 0, filenamecomplete,model ,samplingsteps,cfg, hiressteps, denoisestrength,samplingmethod, upscaler,hiresscale,apiurl,qualitygate,quality,runs,negativeprompt)
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\extensions\OneButtonPrompt\call_txt2img.py", line 138, in call_txt2img
for i in r['images']:
KeyError: 'images'

AIrjen commented

I had to try the prompt first, looks like you missed out on a good one!

00000-294695677

For the error, I have had similar experiences. On my PC this would happen if the image before this one would fail with an Out of Memory error. The next one it picks up will give this error.

Can you check wether this is the case for you as well?

I can tell by the messages, that you are running with random samplers and upscalers. It might be worth setting these to values you know your PC can handle, to see if that improves the problem.

In the meantime, I will keep an eye out for these kind of messages.

Let me know if you find any Out of Memory messages as well.

Thank you for the reply!

This issue can occur on the very first image, the moment I press the generation button as well.
Another issue that might be connected is that the extension is unable to find my upscalers for some reason.
I will attach some images that show how my SD is able to find my upscale models, but OneButtonPrompt is not:

Screenshot 2023-06-03 at 6 49 22 AM Screenshot 2023-06-03 at 6 49 03 AM Screenshot 2023-06-03 at 6 48 49 AM

update:
the upscale model issue was with Vlad SD Next, and I found a fix.

However, I still get similar errors even using settings I know my pc can handle.

Traceback (most recent call last):
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\gradio\routes.py", line 422, in run_predict
output = await app.get_blocks().process_api(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\gradio\blocks.py", line 1323, in process_api
result = await self.call_function(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\gradio\blocks.py", line 1051, in call_function
prediction = await anyio.to_thread.run_sync(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio_backends_asyncio.py", line 807, in run
result = context.run(func, *args)
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\extensions\OneButtonPrompt\main.py", line 194, in generateimages
img2img = call_img2img(image, originalimage, originalpnginfo, apiurl, filenamecomplete, randomprompt,negativeprompt,img2imgsamplingsteps, img2imgcfg, img2imgsamplingmethod, img2imgupscaler, img2imgmodel, img2imgdenoisestrength, img2imgscale, img2imgpadding,upscalescript,usdutilewidth, usdutileheight, usdumaskblur, usduredraw, usduSeamsfix, usdusdenoise, usduswidth, usduspadding, usdusmaskblur,controlnetenabled, controlnetmodel,controlnetblockymode)
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\extensions\OneButtonPrompt\call_img2img.py", line 182, in call_img2img
for i in r['images']:
KeyError: 'images'

update again:
actually, the upscale models just randomly disappear even now from OneButtonPrompt. My fix didn't work. When I change where Stable diffusion looks for those models, it will work for a while until I restart the program, then, the extension no longer can find them.

AIrjen commented

I'm having a lot of trouble to reproduce this. Please bear with me.

Sorry for asking the obvious, but are you using the latest version of One Button Prompt? A few weeks ago, there was a change in how the models and upscalers are loaded.

The loading is actually done now by accessing the same libraries that WebUI has:
image

Meaning that it just uses what WebUI also has.

Have you tried just putting the models in the standard set directories, to see if that helps?

I checked whether Vladmantic has done something different, but it seems to still use the same code that WebUI does for this:

image

Edit/update:

I just remembered, I had issues before with the "unprompted" extension.
So what you can do to test, is to remove all other extension, and see if the issue persists. If so, you might be able to determine which other extension might be interfering.

old:
good call on the extension issue. without any besides OneButtonPrompt installed the issue is gone. I'll see if I can find which one is causing the issue for me, and let you know (just for knowledge sake. not expecting you to fix something like that lol).

update:
There is a weird issue happening here I didn't expect. If I get rid of all my extensions, and only hit "apply and restart" from the extension tab, it brings up the upscale options.
However, if I then proceed to close out the entire app and reload the entire thing, even without any extensions enabled besides OneButtonPrompt, then the upscalers are gone again.
super weird...
update #2: if I reinstall all the extensions and then hit "apply and restart" I am then able to see the upscalers again. They only go away when I completely reboot the whole program. Something must be happening on startup that makes this issue occur with the upscale models.

Also, still getting the original issue even when the upscale models are showing (without restarting completely).

this error happened on the first generated image in a batch of 2 with a quality gate of 7.4 and only 2 tries to reach that quality gate. My system is more than capable of doubling the resolution of a 768x512 image using controlnet and ultimate SD upscale with the upscale model of 4x-UltraSharp (the model chosen here). It looks like the system gets through all 6 upscale sections, and then something happens after that for some reason. That's where my tech abilities end lol:

Setting insanity level to 5
over the shoulder shot of a portly Isabelle Fuhrman, wearing Tulle Maroon Maternity wear, Thoughtful Pose, Satisfying, Sunlight, inticrate details
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [00:07<00:00, 5.59it/s]
Found aesthetic-image-scorer! Using this to measure the results...
This image has scored: 5.3 out of 7.4
Not a good result. Retrying for another 1 times or until the image is good enough.
100%|██████████████████████████████████████████████████████████████████████████████████| 40/40 [00:05<00:00, 6.91it/s]
Found aesthetic-image-scorer! Using this to measure the results...
This image has scored: 5.9 out of 7.4
Not a good result. Retrying for another 0 times or until the image is good enough.
Stopped trying, keeping the best image we had so far.
Canva size: 1536x1024
Image size: 768x512
Scale factor: 2
Upscaling iteration 1 with scale factor 2
Tile size: 512x512
Tiles amount: 6
Grid: 2x3
Redraw enabled: True
Seams fix mode: BAND_PASS
100%|██████████████████████████████████████████████████████████████████████████████████| 31/31 [00:07<00:00, 3.96it/s]
100%|██████████████████████████████████████████████████████████████████████████████████| 31/31 [00:06<00:00, 4.60it/s]
100%|██████████████████████████████████████████████████████████████████████████████████| 31/31 [00:06<00:00, 4.59it/s]
100%|██████████████████████████████████████████████████████████████████████████████████| 31/31 [00:06<00:00, 4.59it/s]
100%|██████████████████████████████████████████████████████████████████████████████████| 31/31 [00:06<00:00, 4.59it/s]
100%|██████████████████████████████████████████████████████████████████████████████████| 31/31 [00:06<00:00, 4.59it/s]
Traceback (most recent call last):
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\gradio\routes.py", line 422, in run_predict
output = await app.get_blocks().process_api(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\gradio\blocks.py", line 1323, in process_api
result = await self.call_function(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\gradio\blocks.py", line 1051, in call_function
prediction = await anyio.to_thread.run_sync(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio_backends_asyncio.py", line 807, in run
result = context.run(func, *args)
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\extensions\OneButtonPrompt\main.py", line 194, in generateimages
img2img = call_img2img(image, originalimage, originalpnginfo, apiurl, filenamecomplete, randomprompt,negativeprompt,img2imgsamplingsteps, img2imgcfg, img2imgsamplingmethod, img2imgupscaler, img2imgmodel, img2imgdenoisestrength, img2imgscale, img2imgpadding,upscalescript,usdutilewidth, usdutileheight, usdumaskblur, usduredraw, usduSeamsfix, usdusdenoise, usduswidth, usduspadding, usdusmaskblur,controlnetenabled, controlnetmodel,controlnetblockymode)
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\extensions\OneButtonPrompt\call_img2img.py", line 182, in call_img2img
for i in r['images']:
KeyError: 'images'

I don't really know what "for i in r['images']:" means, but that seems to be the issue somehow.

another update:
I've been experimenting to see if this happens with other settings. I was having a lot of luck with disabling the "seam fix" option until I ran into this error:

11:10:18-920450 ERROR API error: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'IndexError', 'detail': '',
'body': '', 'errors': 'index 0 is out of bounds for dimension 0 with size 0'}
11:10:18-923451 ERROR HTTP API: IndexError
┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐
│ C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio\streams\memory.py:98 in │
│ receive │
│ │
│ C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio\streams\memory.py:93 in │
│ receive_nowait │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
WouldBlock

During handling of the above exception, another exception occurred:

┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐
│ C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\starlette\middleware\base.py:78 │
│ in call_next │
│ │
│ C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio\streams\memory.py:118 in │
│ receive │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
EndOfStream

During handling of the above exception, another exception occurred:

┌───────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────┐
│ C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\modules\middleware.py:72 in exception_handling │
│ │
│ 71 │ │ try: │
│ > 72 │ │ │ return await call_next(req) │
│ 73 │ │ except CancelledError: │
│ │
│ C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\starlette\middleware\base.py:84 │
│ in call_next │
│ │
│ ... 29 frames hidden ... │
│ │
│ C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\modules\processing.py:1086 in sample │
│ │
│ 1085 │ │ │ x *= self.initial_noise_multiplier │
│ > 1086 │ │ samples = self.sampler.sample_img2img(self, self.init_latent, x, conditioning, u │
│ 1087 │ │ if self.mask is not None: │
│ │
│ C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\modules\sd_samplers_kdiffusion.py:344 in │
│ sample_img2img │
│ │
│ 343 │ │ sigma_sched = sigmas[steps - t_enc - 1:] │
│ > 344 │ │ xi = x + noise * sigma_sched[0] │
│ 345 │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
IndexError: index 0 is out of bounds for dimension 0 with size 0
Traceback (most recent call last):
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\gradio\routes.py", line 422, in run_predict
output = await app.get_blocks().process_api(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\gradio\blocks.py", line 1323, in process_api
result = await self.call_function(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\gradio\blocks.py", line 1051, in call_function
prediction = await anyio.to_thread.run_sync(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio_backends_asyncio.py", line 807, in run
result = context.run(func, *args)
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\extensions\OneButtonPrompt\main.py", line 194, in generateimages
img2img = call_img2img(image, originalimage, originalpnginfo, apiurl, filenamecomplete, randomprompt,negativeprompt,img2imgsamplingsteps, img2imgcfg, img2imgsamplingmethod, img2imgupscaler, img2imgmodel, img2imgdenoisestrength, img2imgscale, img2imgpadding,upscalescript,usdutilewidth, usdutileheight, usdumaskblur, usduredraw, usduSeamsfix, usdusdenoise, usduswidth, usduspadding, usdusmaskblur,controlnetenabled, controlnetmodel,controlnetblockymode)
File "C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\extensions\OneButtonPrompt\call_img2img.py", line 182, in call_img2img
for i in r['images']:
KeyError: 'images'

Is it possible that this is occurring because Vlad's fork doesn't really work with "--api"? It requires "--api auth" which has always broken your extension in my case.

update:
seams fix definitely has some contribution to the original error. it will always come up for me on the very first image I make at the same time seams fix would start to come into effect (after the image has gone through the upscales).
Without seams fix enabled, the second error consistently happens to me on the 4th image to be generated. It creates the test images for the quality gate, and then has the exact error I listed before occur when it is going to upscale the one it chooses. IDK why this consistently happens on the 4th image, but that's a constant for me, and likely why in my original post I felt like it would never let me past the first few generations.

AIrjen commented

Hi, thanks for the clear description! I have a very busy week, so I'll only have time to look this weekend I hope.
I have to install Vlad as well, since I'm only running base automatic1111.

As for this error:

for i in r['images']:
KeyError: 'images'

This is actually a result of another error. If we call the API, and the API does not return any images, it breaks here.

If I have time this weekend, I will do these reproduction steps. See if it is something I can do to reproduce and fix, or that it needs to be reported to automatic1111/vlad instead. :)

AIrjen commented

Hi, I installed Vlad this morning and have been running tests. I can't reproduce your problem, even running long batches with seams fix enabled.

I've put out a mini-update with some stability changes for Ultimate SD Upscale (making sure types are set correctly), maybe get latest version and see if that works?

I do still think it might be a memory issue. The stacktrace does start with:
"C:\Users\Gaming\Desktop\Stable Diffusion\Vlad A111\automatic\venv\lib\site-packages\anyio\streams\memory.py"

It could be something specific to Vladmantic, it could be memory not being released properly during the API calls, it could be a specific sampler of upscaler you are using.

I would suggest trying on Automatic1111 as well, to see if the problem persists there as well.

I'm not sure what I can do to help here (besides the minor update I did).

noahwh commented

FWIW I saw the error from the first comment when I first tried to use this plugin and it was caused by not using the --api command line option. It'd probably be worthwhile to add some error checking to call_txt2img.py to make sure the API is actually responding.

AIrjen commented

Hi, it is a good idea to implement something around this. Like an automatic wait and retry if there was no image returned. Will put this on my todo list.

AIrjen commented

I've added a automatic "wait and retry" into txt2img, img2img and extra calls.
It will now try a total of 3 times, each time waiting each longer for each call (10,20,30 seconds)

If there is still no response, a proper error is raised.

I also made a small fix, there was a "None" upscaler which could cause trouble as well. This has now been removed.

AIrjen commented

Closing this for now. There is no clear reproduction scenario and stability factors have been implemented.