Stability-AI / StableStudio

Community interface for generative AI
MIT License
8.68k stars 863 forks source link

`stable-diffusion-webui` plugin #25

Open jtydhr88 opened 1 year ago

jtydhr88 commented 1 year ago

https://github.com/Stability-AI/StableStudio/pull/24

jtydhr88 commented 1 year ago

This is a basic implement for stable-diffusion-webui plugin.

How to use

  1. On stable-diffusion-webui side, edit webui-user.bat and
    set COMMANDLINE_ARGS=--nowebui --cors-allow-origins=http://localhost:3000
    Then start your webui.
  2. Once you see INFO: Uvicorn running on http://127.0.0.1:7861, means you started webui on api mode successfully. you can open http://127.0.0.1:7861/docs to double check.
  3. On StableStudio side, run yarn dev:use-webui-plugin
  4. once the server started, click settings to check this plugin loaded successfully or not.
  5. click Dream, your webui server should start to process your request from StableStudio.
  6. if you need to load existing from webui, you also need to install the extension sd-webui-StableStudio)

Still, currently this plugin is a basic implement for webui, and only support a few of features:

wendaleruan commented 1 year ago

Usage Error: Couldn't find a script named "dev:use-webui-plugin". how to fix it @jtydhr88

jtydhr88 commented 1 year ago

@wendaleruan since this one still works in progress, and not get merged yet, if you want to try now, you need to use my repo and check out webui-plugin branch

cruhl commented 1 year ago

@jtydhr88 In terms of what’s needed to merge, I think we’d be good to go once this plug-in is at feature parity with the Stability API plugin with the exception of storing images.

I think we can add storing images locally as a follow-up if you wanted 👍

harrywang commented 1 year ago

@jtydhr88 "MacOS and Linux support (since I don’t have environment with MacOS/Linux, may need someone help with this" I am a Mac user and can help with this. Please let me knwo what to do.

jtydhr88 commented 1 year ago

Thanks @harrywang ! Just make some normal actions I guess you already made would be helpful, and create issues if find any bugs

jtydhr88 commented 1 year ago

https://github.com/Stability-AI/StableStudio/pull/70

wangkai111111 commented 1 year ago

hello, I inserted stable-diffusion-webui according to the method provided in the linux environment. Adding the url in stablestudio keeps turning around, and the insertion does not make progress. How to solve this problem? image image image

jtydhr88 commented 1 year ago

@KaiW98 see here image on your webui side, you should use http://localhost:3000 instead of http://127.0.0.1:3000 in cors-allow-orgins btw, this link should map your StableStudio log: image

harrywang commented 1 year ago

@KaiW98 see here image on your webui side, you should use http://localhost:3000 instead of http://127.0.0.1:3000 in cors-allow-orgins btw, this link should map your StableStudio log: image

@jtydhr88 https://github.com/Stability-AI/StableStudio/issues/71 I reported the same issue and figured it out myself - should we add some instruction in the README?

jtydhr88 commented 1 year ago

@harrywang looks like @KaiW98 is reverse to yours, in your case, you configured localhost:3000 but didn't work, but on his case, I think he need to configure localhost:3000.

nmcbride commented 1 year ago

I'm also having issues getting these talking.

I believe CORS is right but on it's options request the server is throwing a 500. Here is the error:

INFO:     127.0.0.1:58800 - "GET /sdapi/v1/options HTTP/1.1" 500 Internal Server Error
API error: GET: http://127.0.0.1:7861/sdapi/v1/options {'error': 'ValidationError', 'detail': '', 'body': '', 'errors': '1 validation error for Options\nresponse -> sd_model_checkpoint\n  value is not None (type=type_error.not_none)'}
Traceback (most recent call last):
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/anyio/streams/memory.py", line 98, in receive
    return self.receive_nowait()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/anyio/streams/memory.py", line 93, in receive_nowait
    raise WouldBlock
anyio.WouldBlock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 78, in call_next
    message = await recv_stream.receive()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/anyio/streams/memory.py", line 118, in receive
    raise EndOfStream
anyio.EndOfStream

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/<user>/MachineLearning/stable-diffusion-webui/modules/api/api.py", line 152, in exception_handling
    return await call_next(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 84, in call_next
    raise app_exc
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 70, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 108, in __call__
    response = await self.dispatch_func(request, call_next)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<user>/MachineLearning/stable-diffusion-webui/modules/api/api.py", line 117, in log_and_time
    res: Response = await call_next(req)
                    ^^^^^^^^^^^^^^^^^^^^
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 84, in call_next
    raise app_exc
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/base.py", line 70, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 92, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 147, in simple_response
    await self.app(scope, receive, send)
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/gzip.py", line 24, in __call__
    await responder(scope, receive, send)
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/gzip.py", line 44, in __call__
    await self.app(scope, receive, self.send_with_gzip)
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/fastapi/routing.py", line 255, in app
    content = await serialize_response(
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/<user>/MachineLearning/stable-diffusion-webui/venv/lib/python3.11/site-packages/fastapi/routing.py", line 141, in serialize_response
    raise ValidationError(errors, field.type_)
pydantic.error_wrappers.ValidationError: 1 validation error for Options
response -> sd_model_checkpoint
  value is not None (type=type_error.not_none)
INFO:     127.0.0.1:50104 - "GET /sdapi/v1/options HTTP/1.1" 500 Internal Server Error
nmcbride commented 1 year ago

I'm on the latest versions of both as of today.

jtydhr88 commented 1 year ago

hey @nmcbride can you share which version of your webui? for mine is on 1.3.0 commit: image

wangkai111111 commented 1 year ago

I also found the same problem, the webui version is v1.3.0. Modify the cors-allow-orgins address according to the above method, still not working image image image

GRMrGecko commented 1 year ago

I received the same error until I followed the instructions and installed the plugin: https://github.com/jtydhr88/sd-webui-StableStudio

jtydhr88 commented 1 year ago

hey guys, I made a quick bug fix https://github.com/Stability-AI/StableStudio/pull/76 here but I don't think it will fix your guys issue, still research how to reproduce the bug you are facing...

nmcbride commented 1 year ago

I made process but I think there may be an issue with my stable diffusion even though it is the latest version and works from it's own web UI.

When img2text is called it throws a 404 with the following: {"error":"HTTPException","detail":"Sampler not found","body":"","errors":""}

GRMrGecko commented 1 year ago

You need to select a sampler in the advanced options above the dream button.

nmcbride commented 1 year ago

I see. I was thrown off because I also tried the call from stable diffusion's api page using their example body and it threw the same error. So I was figuring the problem was bigger than I thought.

jtydhr88 commented 1 year ago

The difficulty for me is I have no idea how to reproduce this issue, I am happy if someone could provide more information to help me to reproduce it

s-blu commented 1 year ago

Hello,

thanks alot for this plugin! Just FYI: I had the problem that StableStudio reported a CORS Error and stable-diffusion-webui ran into a 500 with a 1 validation error for Options\nresponse -> sd_model_checkpoint\n value is not None (type=type_error.not_none) stack trace when trying to access /sdapi/v1/options. I was able to resolve this issue by starting up the automatic1111 UI and disabling the installed ControlNet extension. It might be worthwhile to check for and disable extensions installed via automatic1111 if this plugin is not running as expected.

jtydhr88 commented 1 year ago

@s-blu great catch! That information may help me to reproduce the issue!

nmcbride commented 1 year ago

For me the CORS issue was just not defining it as arguments. It was 100% on my end. After defining CORS and installing the plugin and setting the values in the UI, everything worked.

maekawataiki commented 1 year ago

I also faced the error 1 validation error for Options\nresponse -> sd_model_checkpoint\n value is not None (type=type_error.not_none)

TLDR: creating config.json with following command solves the error echo "{\"sd_model_checkpoint\": \"\", \"sd_checkpoint_hash\": \"\"}" > stable-diffusion-webui/config.json

Response model of /options endpoint is set to OptionsModel (ref) and type of each attribute of OptionsModel is set to type of value of opts on initialization (ref) which can be overriden by file stable-diffusion-webui/config.json (ref).

The error is caused when app is initialized with sd_model_checkpoint set to default value of None (ref) which result in FastAPI expecting NoneType for sd_model_checkpoint.

Disabling extension is not necessary but clicking "Apply and restart" is the important part since it writes current options to config.json (sd_model_checkpoint is set to i.e. "v1-5-pruned-emaonly.safetensors [6ce0161689]"). After that, newly launched application loads the file on initialization and FastAPI expects string for sd_model_checkpoint and error is solved. Running command echo "{\"sd_model_checkpoint\": \"\", \"sd_checkpoint_hash\": \"\"}" > stable-diffusion-webui/config.json to populate default value can also solve the error.