-
Notifications
You must be signed in to change notification settings - Fork 109
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
add sd-webui api doc and script #559
Conversation
onediff_sd_webui_extensions/api.py
Outdated
# Enable OneDiff speed up | ||
"script_name": "onediff_diffusion_model", | ||
# If you are using OneDiff Enterprise, add the field below to enable quant feature | ||
# "script_args" : [{"0": True}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
增加这里的字段就可以使用 OneDiff 的加速功能,下面的 script_args : [{"0": True}] 是开启量化功能
onediff_sd_webui_extensions/api.py
Outdated
} | ||
call_txt2img_api(**payload) | ||
|
||
# OneDiff sd-webui doesn't support img2img now, the feature is under urgent development |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OneDiff sd-webui 似乎不支持 img2img,所以这里先注释掉了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接删除吧。 img2img 之后另外准备一个新的脚本
onediff_sd_webui_extensions/api.py
Outdated
@@ -0,0 +1,170 @@ | |||
from datetime import datetime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新建个 api 目录吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新建个 api 目录吧
新建了一个 api_examples 目录
onediff_sd_webui_extensions/api.py
Outdated
@@ -0,0 +1,170 @@ | |||
from datetime import datetime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个作为 example,单独放到一个 examples
目录吧。现在是 txt2img 的例子,未来还有 img2img, controlnet 的例子
onediff_sd_webui_extensions/api.py
Outdated
@@ -0,0 +1,170 @@ | |||
from datetime import datetime | |||
import urllib.request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里注释加一下原始来源吧,方便以后维护这个脚本的人定位更新。
而且可以注释里,把因为适配 onediff 改动的地方强调下。让后面维护的人,以及用户,都知道改动不用特别多、怎么改。
@@ -98,6 +98,28 @@ If you possess a OneDiff Enterprise license key, you can access instructions on | |||
|
|||
Note: The quantified model doesn't currently support LoRA loading, and related features are under emergency development. | |||
|
|||
## API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## API | |
## Invoke OneDiff by API |
”用 api 方式调用onediff",具体英文是否正确你再确认下吧。
To use the OneDiff-based sd-webui API, you only need to add a `"script": "onediff_diffusion_model"` field to the request to speed up model inference. | ||
|
||
For OneDiff Enterprise, add `"script_args" : [{"0": True}]` to use the quantization feature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得这些东西放 py 脚本里,作为注释就可以了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我是这么想的,对于经常用 api 调用 sd-webui 的用户,看到文档里这么写就能明白怎么用了,省去了一步扒代码的过程
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那也可以保留。不过我建议换一下顺序:先介绍如何跑起来。然后再解释在干什么。
因为大部分看这个文档的,是想要 “howto”,就是照着就能复现,复现成功了,再看能干嘛
|
||
For OneDiff Enterprise, add `"script_args" : [{"0": True}]` to use the quantization feature. | ||
|
||
Check file `extensions/onediff_sd_webui_extensions/api.py` for more details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check file `extensions/onediff_sd_webui_extensions/api.py` for more details. | |
Check file [api.py](./api.py) for more details. |
改成超链接(这个路径只是当前的例子。需要合并前根据实际情况更新)
|
||
Then you can get the images returned by sd-webui client at `api_out/txt2img/`. | ||
|
||
Note: OneDiff sd-webui only supports txt2img now, img2img and ControlNet is under urgent development. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这句可以删除?
onediff_sd_webui_extensions/api.py
Outdated
# If you are using OneDiff Enterprise, add the field below to enable quant feature | ||
# "script_args" : [{"0": True}], | ||
|
||
# example args for x/y/z plot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些是原来脚本就有的注释吧。
不知道有特殊意义没有,为了干净可以删掉?
onediff_sd_webui_extensions/api.py
Outdated
} | ||
call_txt2img_api(**payload) | ||
|
||
# OneDiff sd-webui doesn't support img2img now, the feature is under urgent development |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
直接删除吧。 img2img 之后另外准备一个新的脚本
api 代码参考了 sd-webui 的 wiki:https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API ,改动是在 request 的 data 中增加了对应的字段。
由于现在 OneDiff 还不支持 img2img,所以注释掉了脚本中对应的部分。