Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sephuroth11
stable-diffusion-webui
提交
4cafad66
S
stable-diffusion-webui
项目概览
sephuroth11
/
stable-diffusion-webui
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
stable-diffusion-webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4cafad66
编写于
9月 02, 2022
作者:
A
AUTOMATIC
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
this should send the currently selected image to other tabs instead of the first
上级
b541c8ba
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
9 deletion
+46
-9
script.js
script.js
+28
-3
webui.py
webui.py
+18
-6
未找到文件。
script.js
浏览文件 @
4cafad66
...
...
@@ -33,7 +33,7 @@ titles = {
}
function
gradioApp
(){
return
document
.
getElementsByTagName
(
'
gradio-app
'
)[
0
];
return
document
.
getElementsByTagName
(
'
gradio-app
'
)[
0
]
.
shadowRoot
;
}
function
addTitles
(
root
){
...
...
@@ -47,8 +47,33 @@ function addTitles(root){
document
.
addEventListener
(
"
DOMContentLoaded
"
,
function
()
{
var
mutationObserver
=
new
MutationObserver
(
function
(
m
){
addTitles
(
gradioApp
()
.
shadowRoot
);
addTitles
(
gradioApp
());
});
mutationObserver
.
observe
(
gradioApp
()
.
shadowRoot
,
{
childList
:
true
,
subtree
:
true
})
mutationObserver
.
observe
(
gradioApp
(),
{
childList
:
true
,
subtree
:
true
})
});
function
selected_gallery_index
(){
var
gr
=
gradioApp
()
var
buttons
=
gradioApp
().
querySelectorAll
(
"
.gallery-item
"
)
var
button
=
gr
.
querySelector
(
"
.gallery-item.
\\
!ring-2
"
)
var
result
=
-
1
buttons
.
forEach
(
function
(
v
,
i
){
if
(
v
==
button
)
{
result
=
i
}
})
return
result
}
function
extract_image_from_gallery
(
gallery
){
if
(
gallery
.
length
==
1
){
return
gallery
[
0
]
}
index
=
selected_gallery_index
()
if
(
index
<
0
||
index
>=
gallery
.
length
){
return
[]
}
return
gallery
[
index
];
}
webui.py
浏览文件 @
4cafad66
...
...
@@ -1288,7 +1288,14 @@ def txt2img(prompt: str, negative_prompt: str, steps: int, sampler_index: int, u
return
processed
.
images
,
processed
.
js
(),
plaintext_to_html
(
processed
.
info
)
def
image_from_url_text
(
filedata
):
if
type
(
filedata
)
==
list
:
if
len
(
filedata
)
==
0
:
return
None
filedata
=
filedata
[
0
]
if
filedata
.
startswith
(
"data:image/png;base64,"
):
filedata
=
filedata
[
len
(
"data:image/png;base64,"
):]
...
...
@@ -1368,7 +1375,7 @@ with gr.Blocks(analytics_enabled=False) as txt2img_interface:
with
gr
.
Column
(
variant
=
'panel'
):
with
gr
.
Group
():
txt2img_gallery
=
gr
.
Gallery
(
label
=
'Output'
)
txt2img_gallery
=
gr
.
Gallery
(
label
=
'Output'
,
elem_id
=
'txt2img_gallery'
)
with
gr
.
Group
():
with
gr
.
Row
():
...
...
@@ -1760,7 +1767,7 @@ with gr.Blocks(analytics_enabled=False) as img2img_interface:
with
gr
.
Column
(
variant
=
'panel'
):
with
gr
.
Group
():
img2img_gallery
=
gr
.
Gallery
(
label
=
'Output'
)
img2img_gallery
=
gr
.
Gallery
(
label
=
'Output'
,
elem_id
=
'img2img_gallery'
)
with
gr
.
Group
():
with
gr
.
Row
():
...
...
@@ -1863,13 +1870,15 @@ with gr.Blocks(analytics_enabled=False) as img2img_interface:
)
send_to_img2img
.
click
(
fn
=
send_gradio_gallery_to_image
,
fn
=
lambda
x
:
image_from_url_text
(
x
),
_js
=
"extract_image_from_gallery"
,
inputs
=
[
txt2img_gallery
],
outputs
=
[
init_img
],
)
send_to_inpaint
.
click
(
fn
=
send_gradio_gallery_to_image
,
fn
=
lambda
x
:
image_from_url_text
(
x
),
_js
=
"extract_image_from_gallery"
,
inputs
=
[
txt2img_gallery
],
outputs
=
[
init_img_with_mask
],
)
...
...
@@ -1952,14 +1961,17 @@ with gr.Blocks(analytics_enabled=False) as extras_interface:
submit
.
click
(
**
extras_args
)
send_to_extras
.
click
(
fn
=
send_gradio_gallery_to_image
,
fn
=
lambda
x
:
image_from_url_text
(
x
),
_js
=
"extract_image_from_gallery"
,
inputs
=
[
txt2img_gallery
],
outputs
=
[
image
],
)
img2img_send_to_extras
.
click
(
fn
=
send_gradio_gallery_to_image
,
fn
=
lambda
x
:
image_from_url_text
(
x
),
_js
=
"extract_image_from_gallery"
,
inputs
=
[
img2img_gallery
],
outputs
=
[
image
],
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录