-
Notifications
You must be signed in to change notification settings - Fork 2k
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-UPDATE] Need to update to accommodate recent API changes in AUTOMATIC1111 #567
Comments
Add str check for image for API compatibility related to #567
For posterity, at time of writing and to my understanding, the way args for scripts work in auto1111 is that there is a giant list of args that cover all scripts. Each script gets handed a args_from and args_to variable to know where their args are in that list. One of the things I did in my PR is to initialize that list with None everywhere and then fill it in with whatever is passed in the API request instead of not generating one at all or a very limited one when using selectable scripts. After initializing the arg list with None in every position to the correct size to cover all scripts, the API request finds the script you specified in the If I recall correctly, in the case of controlnet, the number of args will depend on the max controlnet modules you have. While only filling one module, if you have more then one, might not be a problem, you can essentially fill everything. So the controlnet API might benefit from a get config or get max_model api route, if it hasn't already got one, which would allow the client to know how many controlnet modules he can pass and the schema in the docs might want to account for this. |
@Vespinian, I understood that concept but the issue is that two args(is_img2img and is_ui) are already there in process method of controlnet script which throws of the count of arguments to be passed on. Currently each controlnet model takes 15 args(ref: sd-webui-controlnet/scripts/controlnet.py Line 72 in 5bf7e54
But this is great thing as it will allow all AUTOMATIC1111 scripts to be streamlined into single flow format. |
The curl command linked above is unable to be viewed ("Error, this is a private paste or is pending moderation. If this paste belongs to you, please login to Pastebin to view it."). I've tried to use the alwayson_scripts with the sdapi/v1/txt2img route and I'm still not getting images using responses, not sure if I'm formatting things incorrectly. |
Exemple "alwayson_scripts": {
"ControlNet": {
"args": [false, false,
true,
"none",
"difference_controlSd15Openpose [1723948e]",
1.0,
{"image": "base64img..."},
false,
"Scale to Fit (Inner Fit)",
false,
false,
64,
64,
64,
0.0,
1.0,
false
]
}
} Workaround for now since the goal of this update is to remove the need to pass |
@Vespinian
My call body
|
When I use controlnet through the UI it works |
Didn't think auto would merge the alwayson scripts PR so quickly. in #527 I tried changing how the args of gradio are passed so that we can accept dicts instead of an unreasonably long list of arguments to keep the api as close to what it is right now. I'll try spending a bit of time on this to see if it can be a good fix to the situation. |
Hi @killamonis, Can you confirm following things?
|
That is only true for the gradio interface. In the web API (and also external code API), you can pass an arbitrary number of control net units and the webui will resize the script args of the controlnet script to match the passed args. Edit: I looked at the code again, and it seems that the webui |
Alright. Also I believe that in the alwayson scripts PR, the way the arg list is initialized is currently overwriting the modifications made by the scriptrunner hijack, which broke the API hijack, see #571. I made a bit of a dirty fix in a branch of my fork by taking the control units from the request and creating a ControlNet dict in the request's alwayson_scripts but that may have broken other things. |
Yes, thanks for your quick fix. I opened #527 also for this purpose. Hopefully I can get some confidence on the code and will open for review when we get there. |
Hey @PhoenixCreation Automatic commit: AUTOMATIC1111/stable-diffusion-webui@dfeee78 Controlnet extension commit: 274dd5d |
However, using the curl command you sent and the UI, the controlnet pose does work. |
I'm unable to run the extension in img2img mode. Not sure if related to current issue.
|
Hi @freecoderai01, can you elaborate how you interact with the extension? The value Otherwise, please clarify what situation caused the error. |
Hi @ljleb, I was not trying to use the extension's API, so the value should be in the default state, isn't it? |
Thanks for the context. I think this should go in its own issue, it does not seem related to API migration. |
这样做可能会遇到的一个潜在问题是,如果用户将 controlnet 脚本替换为脚本运行器中的副本。我不认为这是一个阻塞问题,因为它可能不会发生,但它可能会导致令人惊讶的行为。 在未更改的 SD 安装上进行常规 api 调用时,会发生这种情况吗?我不完全了解这个问题以及它将如何影响脚本的行为,但是一旦我完成了重新映射对象和迁移调用,我可以帮助测试内容。  This parameter error, do not understand why; |
For anyone coming here in the future, here is the new format for how to use the Automatic1111 |
What Happened
/sdapi/v1/txt2img
andsdapi/v1/img2img
with parameteralwayson_scripts
./controlnet/txt2img
and/controlnet/img2img
routes as mentioned in wiki.Issue 1
ScriptRunner
class hasprocess
method which is responsible to pass on arguments to the other scripts like Controlnet.process(self, p, *args):
which will allow all scripts to be run with API.process(self, p, is_img2img=False, is_ui=False, *args)
which is causing trouble if we want to just directly use the Controlnet from the/sdapi/v1/txt2img
API because first two parameters will go towards theis_img2img
andis_ui
.Ref:
sd-webui-controlnet/scripts/controlnet.py
Line 610 in 5bf7e54
This is current workaround and I am mentioning this because Second issue is dependent on this.
Curl Command for the Request :https://pastebin.com/432EG3PT
Issue 2
sd-webui-controlnet/scripts/controlnet.py
Line 751 in 5bf7e54
I am creating this issue so we can keep track of the API related changes. Also let me know if Issue 1 needs to be changing but that is something you should handle as you have more knowledge of the API flow.
Tasks
/controlnet/txt2img
and/controlnet/img2img
as deprecated.The text was updated successfully, but these errors were encountered: