-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
API Implementation working with Gradio #3040
Conversation
…means that one could allow access to /sdapi/ but not the webui.
Looks like this addresses the queue lock issue raised in my branch before I got the chance to do it. I'd end up doing the exact same thing here. So glad to see this getting further along :) |
should this have a wiki page explaining what we can do with the API, with get and post examples? |
@ArcticFaded is |
I'm also interested in polling for the latest in-progress image to view the denoising process, is that possible yet? |
Is there a discussion thread on the features and design for the API? I'm open to contributing stuff like getting & setting config options, which is necessary for me to migrate my plugin to the new API. If possible, such a discussion thread should be open to coordinate work on features that aren't implemented yet. |
Yay, this is a big step in the right direction. Some comments for anybody else having problems: Currently --api is ignored if launch.py is used due to how it hits webui() directly. A work around in webui.py is
I got errors with list in api.py due to using a pre 3.9 version python. fixed it with adding "from typing import List" and changing "List[str]" to "list[str]" @VictorJulianiR, it's not much but here is a basic API example call that might be useful for testing. ] For a full list of parms, check http://127.0.0.1:7860/docs#/default/text2imgapi_sdapi_v1_txt2img_post (change ip to wherever your server is running) |
Hello. May i ask why sampler_index is in API_NOT_ALLOWED in modules/api/processing.py ? |
sampler_index is re-added again at the API level - we are exposing it to the client as a name even though internally its just a number |
Yeah those are coming in separate PRs |
@ArcticFaded could you perhaps create a tracking issue to coordinate progress of the features to be added? That could help the community build out those features with you instead of making you do it all yourself. |
Thank you for the great work. can you please post a step by step example on how to start the server with API enabled and test it with curl? |
@loopstring
|
@loopstring You can also see this thread for a link to the API docs (works for txt2img and img2img as long as api mode is enabled), and another example curl: #3381 (comment) For the type of instructions that you could give users, here's what I just wrote up yesterday (ignore anything about the Blender-specific stuff, after step 6): https://github.com/benrugg/AI-Render/wiki/Local-Installation |
Anyone up to trying to write an API for calling scripts? At a quick glance, the code for using scripts is nearly indecipherable, so good job to whoever contributed that. I think pull requests should also be reviewed for quality... I am going to figure it out anyways for my plugin. Inspecting the script.run() method if aiming to do it dynamically might be necessary: https://docs.python.org/3/library/inspect.html#inspect.signature But it isn't sufficient to determine the input type or other constraints. Right now I am resorting to write a simple adapter to translate Gradio UI elements to Qt... |
Am able to dynamically generate the script GUI in the krita plugin, and then call the script via my API. Lots of intermediate conversion was needed. Whoever decides to eventually work on a pull request for the script API, you may take reference from this. |
Is there something wrong with the img2img api? I can get the txt2img code working here http://127.0.0.1:7860/docs#/default/text2imgapi_sdapi_v1_txt2img_post SethRobinson's post here was very useful: #3040 (comment) I can convert the output Base64 txt to an image and everything works. But when I put Base64 txt in substitution for the word "string" in the img2img code "init_images":[ http://127.0.0.1:7860/docs#/default/img2imgapi_sdapi_v1_img2img_post I get an "Internal Server Error" in the response body and "content-length: 21 error in the response headers |
Woot got it working, ref this comment if you are in need of python code to do img2img in automatic1111 using the API |
This is a working prototype of an API service running with Gradio - besides the regular Gradio calls there is now
"/sdapi/v1/txt2img"
which can be called as a POST request to invoke txt2img. Usingqueue_lock
even when multiple users are active, regardless of interaction in the UI or API, all calls are queued.This prototype also includes a standalone model if you only wanted to run the API and not Gradio. This implementation benefits from being flexible with the API contract -
StableDiffusionProcessingAPI
is built at runtime based off the definition of the classStableDiffusionProcessingTxt2Img
, so if the method contract ofStableDiffusionProcessingTxt2Img
changes, the API would follow.