capslock / stable-diffusion-bot

Telegram bot for Stable Diffusion, written in Rust.
https://capslock.github.io/stable-diffusion-bot/
MIT License
14 stars 4 forks source link

could you upload a basic api example for img2img? #25

Closed inqoperated closed 11 months ago

inqoperated commented 11 months ago

I get the following error on all of my img2img api jsons

Error: Failed to find a valid img2img prompt node.

Caused by: 0: Failed to get value 1: Failed to find node

getting a basic one in the required format would be helpful Sir.

capslock commented 11 months ago

This is with ComfyUI, right?

You can try the official img2img example provided by ComfyUI: https://comfyanonymous.github.io/ComfyUI_examples/img2img/

This should have everything in the required format.

Let me know if it works for you -- if it does, I'll update the documentation with links to the examples to help other people get started.

inqoperated commented 11 months ago

Yeah i use ComfyUI. Unfortunatelly same error. img2imgbasic.json

capslock commented 11 months ago

Thanks for sharing the json. I ran it locally and I ran into a slightly different error:

Error: Failed to find a valid img2img image node.

Caused by:
    0: Failed to get value
    1: Failed to find node

This is because ComfyUI changed the format of some nodes in the latest version. Could you double check and see if the error you are getting for img2imgbasic.json says Error: Failed to find a valid img2img prompt node. or Error: Failed to find a valid img2img image node.?

If it's the latter, I fixed the issue in the latest version: https://github.com/capslock/stable-diffusion-bot/commit/b3826ef377f16804601062e20327eb852a584dcc

inqoperated commented 11 months ago

true the error on the basic example is this:

Error: Failed to find a valid img2img image node.

Caused by: 0: Failed to get value 1: Failed to find node

the previous error was on some of mine jsons

capslock commented 11 months ago

Great! Try updating to the latest version and try img2imgbasic.json again. I'll add some pointers to samples to help others get started.

inqoperated commented 11 months ago

ok that got the bot started. is there a way to get some debug output as it does not generate images on /gen i can use help and txtimgsettings command so i am allowed to use it via my telegram number i guess. beyond is the basic txt2img api json i try to use.

workflow_1_pic_api.json

capslock commented 11 months ago

I think it is likely a bug that I just uncovered. If you are running comfyUI on a different host/port than default, then those settings weren't being respected. I just fixed this in https://github.com/capslock/stable-diffusion-bot/commit/c6b21ba0c2c8fbeaea9211726fd6acb2214564af.

It should already output error logs by default. If you're running linux, it might be outputting to systemd instead. You can check those logs by running journalctl -xet stable-diffusion-bot.

You can set the environment variable RUST_LOG to see more detailed logs, but this shouldn't be necessary for errors.

export RUST_LOG="info" # or "debug"

You can also check ComfyUI for error output, as it'll print an error if there was an issue running your prompt.

inqoperated commented 11 months ago

perfect the new version runs smooth. and yeah the comfyui is running on a different ip. What i would love in future is a way to choose the model to use and/or different workflows.

:)

capslock commented 11 months ago

Thanks for helping me find those bugs!

What i would love in future is a way to choose the model to use and/or different workflows.

:)

Thanks for the feedback! I do want to support choosing different workflows in the future since ComfyUI supports many different kinds of workflows compared to A1111. It'll take a little bit more design work though since this is a more fundamental change to how the bot currently works.

inqoperated commented 11 months ago

unfortunatelly this the first time i look at rust code ;) but for choosing model you just need to replace the section in the json maybe parse it from the /gen command and build the json on the fly? and handle the model with a shortcut like maybe <> for fenrisxl_V164fp16.safetensors that could be cutable from the normal generation query or as a variable to be set via /choosemodel or so

just ideas ofc

capslock commented 11 months ago

So, setting the model is actually 90% of the way there, code-wise. Both my comfyui-api and stable-diffusion-api crates already support it, and then adding it to the sal-e-api crate is trivial. I could then add another button in the settings menu that sets the model. I think from the user experience side, it's a little larger of a problem:

  1. I could make it so that the user needs to type in the full model name, but typos and having to type the full model name would be frustrating, and discoverability would be an issue. It would really only be usable if you're the owner of the bot and know which models you have installed. Some users may also not want every user of their bot to be able to tweak this parameter.
  2. Another solution would be to build out a menu that pulls the names of the available models from the API (doable both in ComfyUI and A1111) and then the user would just have to select the model from the list. This would take a little bit more work as I haven't implemented that functionality in either of the API layers, and could have interesting edge cases (what happens when there are way too many models?).
  3. A solution which I would like to implement would involve specifying in the config file what kind of settings should be user-editable, and what kind of values they can take. These would have sensible defaults, similar to how the code currently works, but would solve the shortcomings of point (2).

I do like to support a variety of uses-cases though, and I have (3) on my list of things to implement, so I think things will get there eventually, no promises or timelines though! :)

capslock commented 11 months ago

https://github.com/capslock/stable-diffusion-bot/commit/77a738f8c66cd0468d5199309824927e2069fac5: Added a link in the readme to ComfyUI Examples