Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
S
Stable Diffusion Webui
管理
动态
成员
代码
仓库
分支
提交
标签
仓库图
比较修订版本
部署
模型注册表
分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
Hunter0726
Stable Diffusion Webui
提交
c328deb5
未验证
提交
c328deb5
编辑于
2 years ago
作者:
AUTOMATIC1111
提交者:
GitHub
2 years ago
浏览文件
操作
下载
差异文件
Merge pull request #3934 from bamarillo/api-add-png-info-endpoint
[API][Feature] Add png info endpoint
上级
9bb6b650
83a1f44a
No related branches found
分支 包含提交
No related tags found
标签 包含提交
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
modules/api/api.py
+9
-3
9 个添加, 3 个删除
modules/api/api.py
modules/api/models.py
+8
-1
8 个添加, 1 个删除
modules/api/models.py
有
17 个添加
和
4 个删除
modules/api/api.py
+
9
−
3
浏览文件 @
c328deb5
...
...
@@ -5,7 +5,7 @@ import modules.shared as shared
from
modules.api.models
import
*
from
modules.processing
import
StableDiffusionProcessingTxt2Img
,
StableDiffusionProcessingImg2Img
,
process_images
from
modules.sd_samplers
import
all_samplers
from
modules.extras
import
run_extras
from
modules.extras
import
run_extras
,
run_pnginfo
def
upscaler_to_index
(
name
:
str
):
try
:
...
...
@@ -32,6 +32,7 @@ class Api:
self
.
app
.
add_api_route
(
"
/sdapi/v1/img2img
"
,
self
.
img2imgapi
,
methods
=
[
"
POST
"
],
response_model
=
ImageToImageResponse
)
self
.
app
.
add_api_route
(
"
/sdapi/v1/extra-single-image
"
,
self
.
extras_single_image_api
,
methods
=
[
"
POST
"
],
response_model
=
ExtrasSingleImageResponse
)
self
.
app
.
add_api_route
(
"
/sdapi/v1/extra-batch-images
"
,
self
.
extras_batch_images_api
,
methods
=
[
"
POST
"
],
response_model
=
ExtrasBatchImagesResponse
)
self
.
app
.
add_api_route
(
"
/sdapi/v1/png-info
"
,
self
.
pnginfoapi
,
methods
=
[
"
POST
"
],
response_model
=
PNGInfoResponse
)
def
text2imgapi
(
self
,
txt2imgreq
:
StableDiffusionTxt2ImgProcessingAPI
):
sampler_index
=
sampler_to_index
(
txt2imgreq
.
sampler_index
)
...
...
@@ -125,8 +126,13 @@ class Api:
return
ExtrasBatchImagesResponse
(
images
=
list
(
map
(
encode_pil_to_base64
,
result
[
0
])),
html_info
=
result
[
1
])
def
pnginfoapi
(
self
):
raise
NotImplementedError
def
pnginfoapi
(
self
,
req
:
PNGInfoRequest
):
if
(
not
req
.
image
.
strip
()):
return
PNGInfoResponse
(
info
=
""
)
result
=
run_pnginfo
(
decode_base64_to_image
(
req
.
image
.
strip
()))
return
PNGInfoResponse
(
info
=
result
[
1
])
def
launch
(
self
,
server_name
,
port
):
self
.
app
.
include_router
(
self
.
router
)
...
...
此差异已折叠。
点击以展开。
modules/api/models.py
+
8
−
1
浏览文件 @
c328deb5
import
inspect
from
click
import
prompt
from
pydantic
import
BaseModel
,
Field
,
create_model
from
typing
import
Any
,
Optional
from
typing_extensions
import
Literal
...
...
@@ -148,4 +149,10 @@ class ExtrasBatchImagesRequest(ExtrasBaseRequest):
imageList
:
list
[
FileData
]
=
Field
(
title
=
"
Images
"
,
description
=
"
List of images to work on. Must be Base64 strings
"
)
class
ExtrasBatchImagesResponse
(
ExtraBaseResponse
):
images
:
list
[
str
]
=
Field
(
title
=
"
Images
"
,
description
=
"
The generated images in base64 format.
"
)
\ No newline at end of file
images
:
list
[
str
]
=
Field
(
title
=
"
Images
"
,
description
=
"
The generated images in base64 format.
"
)
class
PNGInfoRequest
(
BaseModel
):
image
:
str
=
Field
(
title
=
"
Image
"
,
description
=
"
The base64 encoded PNG image
"
)
class
PNGInfoResponse
(
BaseModel
):
info
:
str
=
Field
(
title
=
"
Image info
"
,
description
=
"
A string with all the info the image had
"
)
\ No newline at end of file
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录