AndBobsYourUncle / stable-diffusion-discord-bot

A Discord bot, written in Go, that interfaces with the Automatic 1111's API interface.
MIT License
128 stars 35 forks source link

Unexpected end of json #2

Open fooahwt opened 1 year ago

fooahwt commented 1 year ago

I have the webui-user.bat running, and I am able to make images in the web ui I can run the discord bot, but when using /imagine prompt it fails with

2022/12/28 01:00:41 Processing imagine #1057583858859642880: dogs 2022/12/28 01:00:41 Error processing image: unexpected end of JSON input

KeepCreatingOnline commented 1 year ago

I am also having this issue.

AndBobsYourUncle commented 1 year ago

What are the command line arguments you are passing?

Does my suggestion from this closed issue solve it for you?

https://github.com/AndBobsYourUncle/stable-diffusion-discord-bot/issues/1

bitburner commented 1 year ago

I'm having this same issue and the closed issue didn't fix it.

**Fixed by adding "--api" to launch arguments

AndBobsYourUncle commented 1 year ago

I think I'm going to add a bit to the error log that will give more context for issues like this.

AndBobsYourUncle commented 1 year ago

Doing a git pull origin master and a go build

will result in some added logging around errors trying to communicate with the A1111 API.

@bitburner's error (not launching SD with --api) will result in something like this:

Error processing image: Post "http://192.168.1.55:7860/sdapi/v1/txt2img": dial tcp 192.168.1.55:7860: i/o timeout

Having the trailing slash when launching the bot will end up with something like this:

API URL: http://192.168.1.5:7860//sdapi/v1/txt2img
Unexpected API response: {"detail":"Not Found"}

Notice the double / in the URL.

bitburner commented 1 year ago

Awesome! I got it working perfectly except there is an error: firstphase_width/firstphase_height no longer supported; use hr_scale When you try to specify a size. I see in queue.go where you use FirstPhaseWidth/FirstPhaseHeight and am wondering if that needs to get changed to hr_scale to work again. Don't know if that's an issue.

Also, I would LOVE to have the ability to specify a "style" to use in automatic1111 API. I looked in the documentation for the API and there is a method it just needs to be added. It's an array/list though because A1111 has 2 styles (I'm guessing).

styles: [
    "string"
],

There is also one to specify a model which would be nice but not as important I think as the styles.

KeepCreatingOnline commented 1 year ago

Works! =D

KeepCreatingOnline commented 1 year ago

Thankyou @AndBobsYourUncle! =D

AndBobsYourUncle commented 1 year ago

@bitburner

Awesome! I got it working perfectly except there is an error: firstphase_width/firstphase_height no longer supported; use hr_scale

Seems that it should still work, correct? From this code, it looks like A1111 outputs this to the console, but it still proceeds just fine, and calculates the appropriate hr_scale value based on the passed-in width/height values?

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/99b67cff0b48c4a1ad6e14d9cc591b11db6e293c/modules/processing.py#L678-L679

bitburner commented 1 year ago

Ok let me test some more. BTW This is VERY fast and I'm sure it's because you wrote it in go ;)

AndBobsYourUncle commented 1 year ago

@bitburner

Also, I would LOVE to have the ability to specify a "style" to use in automatic1111 API. I looked in the documentation for the API and there is a method it just needs to be added. It's an array/list though because A1111 has 2 styles (I'm guessing).

Nice nice, yeah. If you could open up an issue with these, that would be awesome. There's a label you can add to the issue as well for a feature request.

As much detail as possible in the issue would be helpful as well. I personally haven't messed around with styles (don't even know what they're for 😆), but I could definitely add it in with some more context.

JoshDavis97 commented 1 year ago

Hi - I'm still seeing this issue.

I'm using the --api parameter when starting the webui and no trailing forward slash in my host parameter.

The webui is running on the machine local to the discord bot. I can visit the webui and generate images using my browser.

Webui startup:

>webui-user.bat --api
venv "C:\Users\Josh\Desktop\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug  1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 22bcc7be428c94e9408f589966c2040187245d81
Installing requirements for Web UI
Launching Web UI with arguments:
No module 'xformers'. Proceeding without it.
Loading weights [6ce0161689] from C:\Users\Josh\Desktop\stable-diffusion-webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors
Creating model from config: C:\Users\Josh\Desktop\stable-diffusion-webui\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying cross attention optimization (Doggettx).
Textual inversion embeddings loaded(0):
Model loaded in 10.4s (load weights from disk: 0.3s, create model: 0.4s, apply weights to model: 7.2s, apply half(): 0.6s, move model to device: 0.5s, load textual inversion embeddings: 1.4s).
Running on local URL:  http://127.0.0.1:7860

To create a public link, set `share=True` in `launch()`.
Startup time: 19.5s (import torch: 2.7s, import gradio: 2.0s, import ldm: 0.9s, other imports: 2.1s, setup codeformer: 0.2s, load scripts: 0.8s, load SD checkpoint: 10.5s, create ui: 0.2s, gradio launch: 0.1s).

Discord bot startup:

>stable_diffusion_bot.exe -guild XXX -token XXX -host http://127.0.0.1:7860 -imagine imagine2
2023/03/30 00:02:23 Current DB version: 7, required DB version: 7
2023/03/30 00:02:23 Adding command 'imagine2'...
2023/03/30 00:02:23 Logged in as: loungebot#9611
2023/03/30 00:02:24 Adding command 'imagine2_settings'...
2023/03/30 00:02:24 Retrieved bot default settings: &{MemberID:bot Width:512 Height:512}
2023/03/30 00:02:24 Press Ctrl+C to exit
2023/03/30 00:02:31 Processing imagine #1090773005652734012: test
2023/03/30 00:02:31 API URL: http://127.0.0.1:7860/sdapi/v1/txt2img
2023/03/30 00:02:31 Unexpected API response: {"detail":"Not Found"}
2023/03/30 00:02:31 Error processing image: unexpected end of JSON input

Running Python 3.10.6, Win10 22H2 (build 19045.2728)