Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
6c88eaed
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
10 个月 前同步成功
通知
1743
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6c88eaed
编写于
1月 12, 2023
作者:
S
space-nuko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add script callback for fixing infotext parameters
上级
d7aec59c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
2 deletion
+21
-2
modules/generation_parameters_copypaste.py
modules/generation_parameters_copypaste.py
+2
-1
modules/script_callbacks.py
modules/script_callbacks.py
+19
-1
未找到文件。
modules/generation_parameters_copypaste.py
浏览文件 @
6c88eaed
...
...
@@ -7,7 +7,7 @@ from pathlib import Path
import
gradio
as
gr
from
modules.shared
import
script_path
from
modules
import
shared
,
ui_tempdir
from
modules
import
shared
,
ui_tempdir
,
script_callbacks
import
tempfile
from
PIL
import
Image
...
...
@@ -298,6 +298,7 @@ def connect_paste(button, paste_fields, input_comp, jsfunc=None):
prompt
=
file
.
read
()
params
=
parse_generation_parameters
(
prompt
)
script_callbacks
.
infotext_pasted_callback
(
prompt
,
params
)
res
=
[]
for
output
,
key
in
paste_fields
:
...
...
modules/script_callbacks.py
浏览文件 @
6c88eaed
...
...
@@ -2,7 +2,7 @@ import sys
import
traceback
from
collections
import
namedtuple
import
inspect
from
typing
import
Optional
from
typing
import
Optional
,
Dict
,
Any
from
fastapi
import
FastAPI
from
gradio
import
Blocks
...
...
@@ -71,6 +71,7 @@ callback_map = dict(
callbacks_before_component
=
[],
callbacks_after_component
=
[],
callbacks_image_grid
=
[],
callbacks_infotext_pasted
=
[],
callbacks_script_unloaded
=
[],
)
...
...
@@ -172,6 +173,14 @@ def image_grid_callback(params: ImageGridLoopParams):
report_exception
(
c
,
'image_grid'
)
def
infotext_pasted_callback
(
infotext
:
str
,
params
:
Dict
[
str
,
Any
]):
for
c
in
callback_map
[
'callbacks_infotext_pasted'
]:
try
:
c
.
callback
(
infotext
,
params
)
except
Exception
:
report_exception
(
c
,
'infotext_pasted'
)
def
script_unloaded_callback
():
for
c
in
reversed
(
callback_map
[
'callbacks_script_unloaded'
]):
try
:
...
...
@@ -290,6 +299,15 @@ def on_image_grid(callback):
add_callback
(
callback_map
[
'callbacks_image_grid'
],
callback
)
def
on_infotext_pasted
(
callback
):
"""register a function to be called before applying an infotext.
The callback is called with two arguments:
- infotext: str - raw infotext.
- result: Dict[str, any] - parsed infotext parameters.
"""
add_callback
(
callback_map
[
'callbacks_infotext_pasted'
],
callback
)
def
on_script_unloaded
(
callback
):
"""register a function to be called before the script is unloaded. Any hooks/hijacks/monkeying about that
the script did should be reverted here"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录