Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stable-diffusion-webui plugin #25

Open
jtydhr88 opened this issue May 19, 2023 · 25 comments
Open

stable-diffusion-webui plugin #25

jtydhr88 opened this issue May 19, 2023 · 25 comments
Assignees
Labels
help wanted We'd love some help! important We really care about this issue! new feature This is a new feature!

Comments

@jtydhr88
Copy link
Contributor

#24

@jtydhr88
Copy link
Contributor Author

jtydhr88 commented May 19, 2023

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:

  • txt2img
  • basic features (prompt, negative prompt, steps, batch_size, image size)
  • features provided by StableStudio
  • model select
  • sampler select
  • img2img
  • mask/inpaint/outpaint
  • store settings
  • webui status could replace images generated status
  • load existing images (need an extension on webui: sd-webui-StableStudio)
  • Need to think about how to deal with extensions ecosystem in webui (made a start with sd-webui-StableStudio)
  • upscale
  • MacOS and Linux support (since I don’t have environment with MacOS/Linux, may need someone help with this)
  • Lora/hypernetworks support
  • test and bugs fix (working)
  • plugin could use path in settings along with a field for extra cli flags to launch webui on startup
  • many other features from webui...

@cruhl cruhl added enhancement New feature or request good first issue help wanted We'd love some help! labels May 19, 2023
@cruhl cruhl added needs discussion Let's keep chatting about this important We really care about this issue! and removed good first issue needs discussion Let's keep chatting about this labels May 19, 2023
@KAJdev KAJdev changed the title a basic version for webui plugin stable-diffusion-webui plugin May 19, 2023
@cruhl cruhl added new feature This is a new feature! and removed enhancement New feature or request labels May 19, 2023
@KAJdev KAJdev self-assigned this May 19, 2023
@cruhl cruhl pinned this issue May 19, 2023
@wendaleruan
Copy link

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

tocoro pushed a commit to tocoro/StableStudio that referenced this issue May 20, 2023
* mobile ui updates

* fixes sidebar btn

* return if null

* mobile input blur

* handle mobile enter key

* new convo name

* new delete mechanism

* test height

* revert

* change padding

* remove overflow

* check relative

* padding

* done

* retry

* test

* test

* should work now

* test

* test

* more

* max h

* revert

* done
@jtydhr88
Copy link
Contributor Author

@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
Copy link
Contributor

cruhl commented May 20, 2023

@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
Copy link

@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
Copy link
Contributor Author

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

@jtydhr88
Copy link
Contributor Author

#70

@wangkai111111
Copy link

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
Copy link
Contributor Author

@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
Copy link

@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 #71 I reported the same issue and figured it out myself - should we add some instruction in the README?

@jtydhr88
Copy link
Contributor Author

@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
Copy link

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
Copy link

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

@jtydhr88
Copy link
Contributor Author

jtydhr88 commented May 31, 2023

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

@wangkai111111
Copy link

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
Copy link

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

@jtydhr88
Copy link
Contributor Author

hey guys, I made a quick bug fix #76 here but I don't think it will fix your guys issue, still research how to reproduce the bug you are facing...

@nmcbride
Copy link

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
Copy link

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

@nmcbride
Copy link

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
Copy link
Contributor Author

jtydhr88 commented Jun 1, 2023

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
Copy link

s-blu commented Jun 5, 2023

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
Copy link
Contributor Author

jtydhr88 commented Jun 5, 2023

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

@nmcbride
Copy link

nmcbride commented Jun 5, 2023

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We'd love some help! important We really care about this issue! new feature This is a new feature!
Projects
None yet
Development

No branches or pull requests

10 participants