AbdullahAlfaraj / Auto-Photoshop-StableDiffusion-Plugin

A user-friendly plug-in that makes it easy to generate stable diffusion images inside Photoshop using either Automatic or ComfyUI as a backend.
MIT License
6.82k stars 508 forks source link

Error while generating the picture #68

Open aniketgore opened 1 year ago

aniketgore commented 1 year ago

Got the plugin installed, but when trying to generate image getting below error. I've API enabled, can access the docs page in the url. The server is on a nw machine, and I've set the SD url to the proper link.

INFO: Will watch for changes in these directories: ['E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server\python_server'] INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: Started reloader process [10248] using WatchFiles INFO: Started server process [13932] INFO: Waiting for application startup. INFO: Application startup complete. INFO: 127.0.0.1:62709 - "POST /sdapi/v1/interrupt HTTP/1.1" 404 Not Found txt2ImgHandle:

payload: {} INFO: 127.0.0.1:62709 - "POST /txt2img/ HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 419, in run_asgi result = await app( # type: ignore[func-returns-value] File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 78, in call return await self.app(scope, receive, send) File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\fastapi\applications.py", line 270, in call await super().call(scope, receive, send) File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\starlette\applications.py", line 124, in call await self.middleware_stack(scope, receive, send) File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\starlette\middleware\errors.py", line 184, in call raise exc File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\starlette\middleware\errors.py", line 162, in call await self.app(scope, receive, _send) File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\starlette\middleware\exceptions.py", line 79, in call raise exc File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\starlette\middleware\exceptions.py", line 68, in call await self.app(scope, receive, sender) File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in call raise e File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in call await self.app(scope, receive, send) File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\starlette\routing.py", line 706, in call await route.handle(scope, receive, send) File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\starlette\routing.py", line 276, in handle await self.app(scope, receive, send) File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\starlette\routing.py", line 66, in app response = await func(request) File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\fastapi\routing.py", line 235, in app raw_response = await run_endpoint_function( File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server_env\lib\site-packages\fastapi\routing.py", line 161, in run_endpoint_function return await dependant.call(**values) File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server\python_server.\serverMain.py", line 159, in txt2ImgHandle dir_name,image_paths,metadata = await txt2ImgRequest(payload) File "E:\Stable-Diffusion-Gits\Auto-Photoshop-StableDiffusion-Plugin\server\python_server.\serverMain.py", line 26, in txt2ImgRequest if(payload['use_prompt_shortcut']): # use edit prompt KeyError: 'use_prompt_shortcut'

remghoost commented 1 year ago

I've had this error in A1111 since my most recent pull.

I'm fairly certain it's an A1111 problem.

Here's an issue from that repo that has the same error. https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/7120#issue-1553351783

edit - It seems to be a problem with extensions. After fixing that problem with A1111, it still pops up in the Photoshop server and prevents the generated image from being passed into Photoshop.

edit 2 - I'm beginning to think that it's the fastapi and starlette not being updated to the correct version. I'll see if updating them fixes the issue.

edit 3 - Did not fix the problem.

remghoost commented 1 year ago

Got it. So I figured out why it wasn't working (for me at least) and have a temporary fix. I'll leave it in a new message so it will alert you on it.

edit- It seems like your stacktrace is different from mine, but perhaps my solution will still work for you.

tl;dr - Enable "Save text information about generation parameters as chunks to png files" in A1111.

In my stacktrace it calls the metadata_to_json.py script and fails once it reaches line 10.

https://github.com/AbdullahAlfaraj/Auto-Photoshop-StableDiffusion-Plugin/blob/ab6cb73e7f74e48e17f1d6dc50c22d2357383251/server/python_server/metadata_to_json.py#L6-L13

And according to ChatGPT, this is what that line is doing.

This line of code is finding the index of the last occurrence of the newline character '\n' in the metadata_str string. The rindex() method is used to find the index of the rightmost occurrence of the specified value in the string, so this line is finding the rightmost occurrence of the newline character in metadata_str. The result is stored in the last_new_line_index variable.

And because there is no metadata to look for that character, it probably returns null, which the other modules aren't a fan of.

I'll poke around and see if I can figure out a permanent fix for those of us that don't want the image generation data saved in the .png. But for now, enable that setting in A1111 and it should work fine for you.

kindLee-alasikoo commented 1 year ago

I have a same error

AbdullahAlfaraj commented 1 year ago

@kindLee-alasikoo I've fixed this in the latest build, you should try installing using the one click plugin.ccx, installer? https://discord.com/channels/1054937599392891000/1055247602578374728/1072213800654225490