Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
c328deb5
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
11 个月 前同步成功
通知
1754
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c328deb5
编写于
10月 29, 2022
作者:
A
AUTOMATIC1111
提交者:
GitHub
10月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3934 from bamarillo/api-add-png-info-endpoint
[API][Feature] Add png info endpoint
上级
9bb6b650
83a1f44a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
4 deletion
+17
-4
modules/api/api.py
modules/api/api.py
+9
-3
modules/api/models.py
modules/api/models.py
+8
-1
未找到文件。
modules/api/api.py
浏览文件 @
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
浏览文件 @
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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录