Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
a1d6ada6
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
12 个月 前同步成功
通知
1771
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
a1d6ada6
编写于
7月 16, 2023
作者:
A
AUTOMATIC1111
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
allow refreshing single card after editing user metadata instead of all cards
上级
efceed8c
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
142 addition
and
87 deletion
+142
-87
extensions-builtin/Lora/ui_edit_user_metadata.py
extensions-builtin/Lora/ui_edit_user_metadata.py
+1
-3
extensions-builtin/Lora/ui_extra_networks_lora.py
extensions-builtin/Lora/ui_extra_networks_lora.py
+30
-24
html/extra-networks-card.html
html/extra-networks-card.html
+1
-1
javascript/extraNetworks.js
javascript/extraNetworks.js
+14
-5
modules/ui_extra_networks.py
modules/ui_extra_networks.py
+20
-0
modules/ui_extra_networks_checkpoints.py
modules/ui_extra_networks_checkpoints.py
+17
-14
modules/ui_extra_networks_hypernets.py
modules/ui_extra_networks_hypernets.py
+17
-14
modules/ui_extra_networks_textual_inversion.py
modules/ui_extra_networks_textual_inversion.py
+17
-13
modules/ui_extra_networks_user_metadata.py
modules/ui_extra_networks_user_metadata.py
+25
-13
未找到文件。
extensions-builtin/Lora/ui_edit_user_metadata.py
浏览文件 @
a1d6ada6
...
@@ -182,6 +182,4 @@ class LoraUserMetadataEditor(ui_extra_networks_user_metadata.UserMetadataEditor)
...
@@ -182,6 +182,4 @@ class LoraUserMetadataEditor(ui_extra_networks_user_metadata.UserMetadataEditor)
self
.
edit_notes
,
self
.
edit_notes
,
]
]
self
.
button_save
\
self
.
setup_save_handler
(
self
.
button_save
,
self
.
save_lora_user_metadata
,
edited_components
)
.
click
(
fn
=
self
.
save_lora_user_metadata
,
inputs
=
[
self
.
edit_name_input
,
*
edited_components
],
outputs
=
[])
\
.
then
(
fn
=
None
,
_js
=
"extraNetworksReloadAll"
)
extensions-builtin/Lora/ui_extra_networks_lora.py
浏览文件 @
a1d6ada6
...
@@ -13,31 +13,37 @@ class ExtraNetworksPageLora(ui_extra_networks.ExtraNetworksPage):
...
@@ -13,31 +13,37 @@ class ExtraNetworksPageLora(ui_extra_networks.ExtraNetworksPage):
def
refresh
(
self
):
def
refresh
(
self
):
lora
.
list_available_loras
()
lora
.
list_available_loras
()
def
list_items
(
self
):
def
create_item
(
self
,
name
,
index
=
None
):
for
index
,
(
name
,
lora_on_disk
)
in
enumerate
(
lora
.
available_loras
.
items
()):
lora_on_disk
=
lora
.
available_loras
.
get
(
name
)
path
,
ext
=
os
.
path
.
splitext
(
lora_on_disk
.
filename
)
path
,
ext
=
os
.
path
.
splitext
(
lora_on_disk
.
filename
)
alias
=
lora_on_disk
.
get_alias
()
alias
=
lora_on_disk
.
get_alias
()
item
=
{
"name"
:
name
,
item
=
{
"filename"
:
lora_on_disk
.
filename
,
"name"
:
name
,
"preview"
:
self
.
find_preview
(
path
),
"filename"
:
lora_on_disk
.
filename
,
"description"
:
self
.
find_description
(
path
),
"preview"
:
self
.
find_preview
(
path
),
"search_term"
:
self
.
search_terms_from_path
(
lora_on_disk
.
filename
),
"description"
:
self
.
find_description
(
path
),
"local_preview"
:
f
"
{
path
}
.
{
shared
.
opts
.
samples_format
}
"
,
"search_term"
:
self
.
search_terms_from_path
(
lora_on_disk
.
filename
),
"metadata"
:
json
.
dumps
(
lora_on_disk
.
metadata
,
indent
=
4
)
if
lora_on_disk
.
metadata
else
None
,
"local_preview"
:
f
"
{
path
}
.
{
shared
.
opts
.
samples_format
}
"
,
"sort_keys"
:
{
'default'
:
index
,
**
self
.
get_sort_keys
(
lora_on_disk
.
filename
)},
"metadata"
:
json
.
dumps
(
lora_on_disk
.
metadata
,
indent
=
4
)
if
lora_on_disk
.
metadata
else
None
,
}
"sort_keys"
:
{
'default'
:
index
,
**
self
.
get_sort_keys
(
lora_on_disk
.
filename
)},
}
self
.
read_user_metadata
(
item
)
activation_text
=
item
[
"user_metadata"
].
get
(
"activation text"
)
preferred_weight
=
item
[
"user_metadata"
].
get
(
"preferred weight"
,
0.0
)
item
[
"prompt"
]
=
json
.
dumps
(
f
"<lora:
{
alias
}
:"
)
+
" + "
+
(
str
(
preferred_weight
)
if
preferred_weight
else
"opts.extra_networks_default_multiplier"
)
+
" + "
+
json
.
dumps
(
">"
)
if
activation_text
:
item
[
"prompt"
]
+=
" + "
+
json
.
dumps
(
" "
+
activation_text
)
self
.
read_user_metadata
(
item
)
activation_text
=
item
[
"user_metadata"
].
get
(
"activation text"
)
preferred_weight
=
item
[
"user_metadata"
].
get
(
"preferred weight"
,
0.0
)
item
[
"prompt"
]
=
json
.
dumps
(
f
"<lora:
{
alias
}
:"
)
+
" + "
+
(
str
(
preferred_weight
)
if
preferred_weight
else
"opts.extra_networks_default_multiplier"
)
+
" + "
+
json
.
dumps
(
">"
)
if
activation_text
:
item
[
"prompt"
]
+=
" + "
+
json
.
dumps
(
" "
+
activation_text
)
return
item
def
list_items
(
self
):
for
index
,
name
in
enumerate
(
lora
.
available_loras
):
item
=
self
.
create_item
(
name
,
index
)
yield
item
yield
item
def
allowed_directories_for_previews
(
self
):
def
allowed_directories_for_previews
(
self
):
...
...
html/extra-networks-card.html
浏览文件 @
a1d6ada6
<div
class=
'card'
style=
{style}
onclick=
{card_clicked}
{
sort_keys
}
>
<div
class=
'card'
style=
{style}
onclick=
{card_clicked}
data-name=
"{name}"
{
sort_keys
}
>
{background_image}
{background_image}
<div
class=
"button-row"
>
<div
class=
"button-row"
>
{edit_button}
{edit_button}
...
...
javascript/extraNetworks.js
浏览文件 @
a1d6ada6
...
@@ -296,9 +296,18 @@ function extraNetworksEditUserMetadata(event, tabname, extraPage, cardName) {
...
@@ -296,9 +296,18 @@ function extraNetworksEditUserMetadata(event, tabname, extraPage, cardName) {
event
.
stopPropagation
();
event
.
stopPropagation
();
}
}
function
extraNetworksReloadAll
()
{
function
extraNetworksRefreshSingleCard
(
page
,
tabname
,
name
)
{
closePopup
();
requestGet
(
"
./sd_extra_networks/get-single-card
"
,
{
page
:
page
,
tabname
:
tabname
,
name
:
name
},
function
(
data
)
{
if
(
data
&&
data
.
html
)
{
gradioApp
().
getElementById
(
'
txt2img_extra_refresh
'
).
click
();
var
card
=
gradioApp
().
querySelector
(
'
.card[data-name=
'
+
JSON
.
stringify
(
name
)
+
'
]
'
);
// likely using the wrong stringify function
gradioApp
().
getElementById
(
'
img2img_extra_refresh
'
).
click
();
var
newDiv
=
document
.
createElement
(
'
DIV
'
);
newDiv
.
innerHTML
=
data
.
html
;
var
newCard
=
newDiv
.
firstElementChild
;
newCard
.
style
=
''
;
card
.
parentElement
.
insertBefore
(
newCard
,
card
);
card
.
parentElement
.
removeChild
(
card
);
}
});
}
}
modules/ui_extra_networks.py
浏览文件 @
a1d6ada6
...
@@ -51,9 +51,26 @@ def get_metadata(page: str = "", item: str = ""):
...
@@ -51,9 +51,26 @@ def get_metadata(page: str = "", item: str = ""):
return
JSONResponse
({
"metadata"
:
metadata
})
return
JSONResponse
({
"metadata"
:
metadata
})
def
get_single_card
(
page
:
str
=
""
,
tabname
:
str
=
""
,
name
:
str
=
""
):
from
starlette.responses
import
JSONResponse
page
=
next
(
iter
([
x
for
x
in
extra_pages
if
x
.
name
==
page
]),
None
)
try
:
item
=
page
.
create_item
(
name
)
except
Exception
as
e
:
errors
.
display
(
e
,
"creating item for extra network"
)
item
=
page
.
items
.
get
(
name
)
item_html
=
page
.
create_html_for_item
(
item
,
tabname
)
return
JSONResponse
({
"html"
:
item_html
})
def
add_pages_to_demo
(
app
):
def
add_pages_to_demo
(
app
):
app
.
add_api_route
(
"/sd_extra_networks/thumb"
,
fetch_file
,
methods
=
[
"GET"
])
app
.
add_api_route
(
"/sd_extra_networks/thumb"
,
fetch_file
,
methods
=
[
"GET"
])
app
.
add_api_route
(
"/sd_extra_networks/metadata"
,
get_metadata
,
methods
=
[
"GET"
])
app
.
add_api_route
(
"/sd_extra_networks/metadata"
,
get_metadata
,
methods
=
[
"GET"
])
app
.
add_api_route
(
"/sd_extra_networks/get-single-card"
,
get_single_card
,
methods
=
[
"GET"
])
class
ExtraNetworksPage
:
class
ExtraNetworksPage
:
...
@@ -168,6 +185,9 @@ class ExtraNetworksPage:
...
@@ -168,6 +185,9 @@ class ExtraNetworksPage:
return
res
return
res
def
create_item
(
self
,
name
,
index
=
None
):
raise
NotImplementedError
()
def
list_items
(
self
):
def
list_items
(
self
):
raise
NotImplementedError
()
raise
NotImplementedError
()
...
...
modules/ui_extra_networks_checkpoints.py
浏览文件 @
a1d6ada6
...
@@ -12,21 +12,24 @@ class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
...
@@ -12,21 +12,24 @@ class ExtraNetworksPageCheckpoints(ui_extra_networks.ExtraNetworksPage):
def
refresh
(
self
):
def
refresh
(
self
):
shared
.
refresh_checkpoints
()
shared
.
refresh_checkpoints
()
def
create_item
(
self
,
name
,
index
=
None
):
checkpoint
:
sd_models
.
CheckpointInfo
=
sd_models
.
checkpoints_list
.
get
(
name
)
path
,
ext
=
os
.
path
.
splitext
(
checkpoint
.
filename
)
return
{
"name"
:
checkpoint
.
name_for_extra
,
"filename"
:
checkpoint
.
filename
,
"preview"
:
self
.
find_preview
(
path
),
"description"
:
self
.
find_description
(
path
),
"search_term"
:
self
.
search_terms_from_path
(
checkpoint
.
filename
)
+
" "
+
(
checkpoint
.
sha256
or
""
),
"onclick"
:
'"'
+
html
.
escape
(
f
"""return selectCheckpoint(
{
json
.
dumps
(
name
)
}
)"""
)
+
'"'
,
"local_preview"
:
f
"
{
path
}
.
{
shared
.
opts
.
samples_format
}
"
,
"sort_keys"
:
{
'default'
:
index
,
**
self
.
get_sort_keys
(
checkpoint
.
filename
)},
}
def
list_items
(
self
):
def
list_items
(
self
):
checkpoint
:
sd_models
.
CheckpointInfo
for
index
,
name
in
enumerate
(
sd_models
.
checkpoints_list
):
for
index
,
(
name
,
checkpoint
)
in
enumerate
(
sd_models
.
checkpoints_list
.
items
()):
yield
self
.
create_item
(
name
,
index
)
path
,
ext
=
os
.
path
.
splitext
(
checkpoint
.
filename
)
yield
{
"name"
:
checkpoint
.
name_for_extra
,
"filename"
:
checkpoint
.
filename
,
"preview"
:
self
.
find_preview
(
path
),
"description"
:
self
.
find_description
(
path
),
"search_term"
:
self
.
search_terms_from_path
(
checkpoint
.
filename
)
+
" "
+
(
checkpoint
.
sha256
or
""
),
"onclick"
:
'"'
+
html
.
escape
(
f
"""return selectCheckpoint(
{
json
.
dumps
(
name
)
}
)"""
)
+
'"'
,
"local_preview"
:
f
"
{
path
}
.
{
shared
.
opts
.
samples_format
}
"
,
"sort_keys"
:
{
'default'
:
index
,
**
self
.
get_sort_keys
(
checkpoint
.
filename
)},
}
def
allowed_directories_for_previews
(
self
):
def
allowed_directories_for_previews
(
self
):
return
[
v
for
v
in
[
shared
.
cmd_opts
.
ckpt_dir
,
sd_models
.
model_path
]
if
v
is
not
None
]
return
[
v
for
v
in
[
shared
.
cmd_opts
.
ckpt_dir
,
sd_models
.
model_path
]
if
v
is
not
None
]
...
...
modules/ui_extra_networks_hypernets.py
浏览文件 @
a1d6ada6
...
@@ -11,21 +11,24 @@ class ExtraNetworksPageHypernetworks(ui_extra_networks.ExtraNetworksPage):
...
@@ -11,21 +11,24 @@ class ExtraNetworksPageHypernetworks(ui_extra_networks.ExtraNetworksPage):
def
refresh
(
self
):
def
refresh
(
self
):
shared
.
reload_hypernetworks
()
shared
.
reload_hypernetworks
()
def
create_item
(
self
,
name
,
index
=
None
):
full_path
=
shared
.
hypernetworks
[
name
]
path
,
ext
=
os
.
path
.
splitext
(
full_path
)
return
{
"name"
:
name
,
"filename"
:
full_path
,
"preview"
:
self
.
find_preview
(
path
),
"description"
:
self
.
find_description
(
path
),
"search_term"
:
self
.
search_terms_from_path
(
path
),
"prompt"
:
json
.
dumps
(
f
"<hypernet:
{
name
}
:"
)
+
" + opts.extra_networks_default_multiplier + "
+
json
.
dumps
(
">"
),
"local_preview"
:
f
"
{
path
}
.preview.
{
shared
.
opts
.
samples_format
}
"
,
"sort_keys"
:
{
'default'
:
index
,
**
self
.
get_sort_keys
(
path
+
ext
)},
}
def
list_items
(
self
):
def
list_items
(
self
):
for
index
,
(
name
,
full_path
)
in
enumerate
(
shared
.
hypernetworks
.
items
()):
for
index
,
name
in
enumerate
(
shared
.
hypernetworks
):
path
,
ext
=
os
.
path
.
splitext
(
full_path
)
yield
self
.
create_item
(
name
,
index
)
yield
{
"name"
:
name
,
"filename"
:
full_path
,
"preview"
:
self
.
find_preview
(
path
),
"description"
:
self
.
find_description
(
path
),
"search_term"
:
self
.
search_terms_from_path
(
path
),
"prompt"
:
json
.
dumps
(
f
"<hypernet:
{
name
}
:"
)
+
" + opts.extra_networks_default_multiplier + "
+
json
.
dumps
(
">"
),
"local_preview"
:
f
"
{
path
}
.preview.
{
shared
.
opts
.
samples_format
}
"
,
"sort_keys"
:
{
'default'
:
index
,
**
self
.
get_sort_keys
(
path
+
ext
)},
}
def
allowed_directories_for_previews
(
self
):
def
allowed_directories_for_previews
(
self
):
return
[
shared
.
cmd_opts
.
hypernetwork_dir
]
return
[
shared
.
cmd_opts
.
hypernetwork_dir
]
...
...
modules/ui_extra_networks_textual_inversion.py
浏览文件 @
a1d6ada6
...
@@ -12,20 +12,24 @@ class ExtraNetworksPageTextualInversion(ui_extra_networks.ExtraNetworksPage):
...
@@ -12,20 +12,24 @@ class ExtraNetworksPageTextualInversion(ui_extra_networks.ExtraNetworksPage):
def
refresh
(
self
):
def
refresh
(
self
):
sd_hijack
.
model_hijack
.
embedding_db
.
load_textual_inversion_embeddings
(
force_reload
=
True
)
sd_hijack
.
model_hijack
.
embedding_db
.
load_textual_inversion_embeddings
(
force_reload
=
True
)
def
create_item
(
self
,
name
,
index
=
None
):
embedding
=
sd_hijack
.
model_hijack
.
embedding_db
.
word_embeddings
.
get
(
name
)
path
,
ext
=
os
.
path
.
splitext
(
embedding
.
filename
)
return
{
"name"
:
name
,
"filename"
:
embedding
.
filename
,
"preview"
:
self
.
find_preview
(
path
),
"description"
:
self
.
find_description
(
path
),
"search_term"
:
self
.
search_terms_from_path
(
embedding
.
filename
),
"prompt"
:
json
.
dumps
(
embedding
.
name
),
"local_preview"
:
f
"
{
path
}
.preview.
{
shared
.
opts
.
samples_format
}
"
,
"sort_keys"
:
{
'default'
:
index
,
**
self
.
get_sort_keys
(
embedding
.
filename
)},
}
def
list_items
(
self
):
def
list_items
(
self
):
for
index
,
embedding
in
enumerate
(
sd_hijack
.
model_hijack
.
embedding_db
.
word_embeddings
.
values
()):
for
index
,
name
in
enumerate
(
sd_hijack
.
model_hijack
.
embedding_db
.
word_embeddings
):
path
,
ext
=
os
.
path
.
splitext
(
embedding
.
filename
)
yield
self
.
create_item
(
name
,
index
)
yield
{
"name"
:
embedding
.
name
,
"filename"
:
embedding
.
filename
,
"preview"
:
self
.
find_preview
(
path
),
"description"
:
self
.
find_description
(
path
),
"search_term"
:
self
.
search_terms_from_path
(
embedding
.
filename
),
"prompt"
:
json
.
dumps
(
embedding
.
name
),
"local_preview"
:
f
"
{
path
}
.preview.
{
shared
.
opts
.
samples_format
}
"
,
"sort_keys"
:
{
'default'
:
index
,
**
self
.
get_sort_keys
(
embedding
.
filename
)},
}
def
allowed_directories_for_previews
(
self
):
def
allowed_directories_for_previews
(
self
):
return
list
(
sd_hijack
.
model_hijack
.
embedding_db
.
embedding_dirs
)
return
list
(
sd_hijack
.
model_hijack
.
embedding_db
.
embedding_dirs
)
modules/ui_extra_networks_user_metadata.py
浏览文件 @
a1d6ada6
...
@@ -23,8 +23,10 @@ class UserMetadataEditor:
...
@@ -23,8 +23,10 @@ class UserMetadataEditor:
self
.
edit_name
=
None
self
.
edit_name
=
None
self
.
edit_description
=
None
self
.
edit_description
=
None
self
.
edit_notes
=
None
self
.
html_filedata
=
None
self
.
html_filedata
=
None
self
.
html_preview
=
None
self
.
html_preview
=
None
self
.
html_status
=
None
self
.
button_cancel
=
None
self
.
button_cancel
=
None
self
.
button_replace_preview
=
None
self
.
button_replace_preview
=
None
...
@@ -57,6 +59,8 @@ class UserMetadataEditor:
...
@@ -57,6 +59,8 @@ class UserMetadataEditor:
self
.
button_replace_preview
=
gr
.
Button
(
'Replace preview'
,
variant
=
'primary'
)
self
.
button_replace_preview
=
gr
.
Button
(
'Replace preview'
,
variant
=
'primary'
)
self
.
button_save
=
gr
.
Button
(
'Save'
,
variant
=
'primary'
)
self
.
button_save
=
gr
.
Button
(
'Save'
,
variant
=
'primary'
)
self
.
html_status
=
gr
.
HTML
(
elem_classes
=
"edit-user-metadata-status"
)
self
.
button_cancel
.
click
(
fn
=
None
,
_js
=
"closePopup"
)
self
.
button_cancel
.
click
(
fn
=
None
,
_js
=
"closePopup"
)
def
get_card_html
(
self
,
name
):
def
get_card_html
(
self
,
name
):
...
@@ -107,7 +111,7 @@ class UserMetadataEditor:
...
@@ -107,7 +111,7 @@ class UserMetadataEditor:
table
=
'<table class="file-metadata">'
+
""
.
join
(
f
"<tr><th>
{
name
}
</th><td>
{
value
}
</td></tr>"
for
name
,
value
in
params
)
+
'</table>'
table
=
'<table class="file-metadata">'
+
""
.
join
(
f
"<tr><th>
{
name
}
</th><td>
{
value
}
</td></tr>"
for
name
,
value
in
params
)
+
'</table>'
return
html
.
escape
(
name
),
user_metadata
.
get
(
'description'
,
''
),
table
,
self
.
get_card_html
(
name
)
return
html
.
escape
(
name
),
user_metadata
.
get
(
'description'
,
''
),
table
,
self
.
get_card_html
(
name
)
,
user_metadata
.
get
(
'notes'
,
''
),
def
write_user_metadata
(
self
,
name
,
metadata
):
def
write_user_metadata
(
self
,
name
,
metadata
):
item
=
self
.
page
.
items
.
get
(
name
,
{})
item
=
self
.
page
.
items
.
get
(
name
,
{})
...
@@ -117,24 +121,30 @@ class UserMetadataEditor:
...
@@ -117,24 +121,30 @@ class UserMetadataEditor:
with
open
(
basename
+
'.json'
,
"w"
,
encoding
=
"utf8"
)
as
file
:
with
open
(
basename
+
'.json'
,
"w"
,
encoding
=
"utf8"
)
as
file
:
json
.
dump
(
metadata
,
file
)
json
.
dump
(
metadata
,
file
)
def
save_user_metadata
(
self
,
name
,
desc
):
def
save_user_metadata
(
self
,
name
,
desc
,
notes
):
user_metadata
=
self
.
get_user_metadata
(
name
)
user_metadata
=
self
.
get_user_metadata
(
name
)
user_metadata
[
"description"
]
=
desc
user_metadata
[
"description"
]
=
desc
user_metadata
[
"notes"
]
=
notes
self
.
write_user_metadata
(
name
,
user_metadata
)
self
.
write_user_metadata
(
name
,
user_metadata
)
def
setup_save_handler
(
self
,
button
,
func
,
components
):
button
\
.
click
(
fn
=
func
,
inputs
=
[
self
.
edit_name_input
,
*
components
],
outputs
=
[])
\
.
then
(
fn
=
None
,
_js
=
"function(name){closePopup(); extraNetworksRefreshSingleCard("
+
json
.
dumps
(
self
.
page
.
name
)
+
","
+
json
.
dumps
(
self
.
tabname
)
+
", name);}"
,
inputs
=
[
self
.
edit_name_input
],
outputs
=
[])
def
create_editor
(
self
):
def
create_editor
(
self
):
self
.
create_default_editor_elems
()
self
.
create_default_editor_elems
()
self
.
edit_notes
=
gr
.
TextArea
(
label
=
'Notes'
,
lines
=
4
)
self
.
create_default_buttons
()
self
.
create_default_buttons
()
self
.
button_edit
\
self
.
button_edit
\
.
click
(
fn
=
self
.
put_values_into_components
,
inputs
=
[
self
.
edit_name_input
],
outputs
=
[
self
.
edit_name
,
self
.
edit_description
,
self
.
html_filedata
,
self
.
html_preview
])
\
.
click
(
fn
=
self
.
put_values_into_components
,
inputs
=
[
self
.
edit_name_input
],
outputs
=
[
self
.
edit_name
,
self
.
edit_description
,
self
.
html_filedata
,
self
.
html_preview
,
self
.
edit_notes
])
\
.
then
(
fn
=
lambda
:
gr
.
update
(
visible
=
True
),
inputs
=
[],
outputs
=
[
self
.
box
])
.
then
(
fn
=
lambda
:
gr
.
update
(
visible
=
True
),
inputs
=
[],
outputs
=
[
self
.
box
])
self
.
button_save
\
self
.
setup_save_handler
(
self
.
button_save
,
self
.
save_user_metadata
,
[
self
.
edit_description
,
self
.
edit_notes
])
.
click
(
fn
=
self
.
save_user_metadata
,
inputs
=
[
self
.
edit_name_input
,
self
.
edit_description
],
outputs
=
[])
\
.
then
(
fn
=
None
,
_js
=
"extraNetworksReloadAll"
)
def
create_ui
(
self
):
def
create_ui
(
self
):
with
gr
.
Box
(
visible
=
False
,
elem_id
=
self
.
id_part
,
elem_classes
=
"edit-user-metadata"
)
as
box
:
with
gr
.
Box
(
visible
=
False
,
elem_id
=
self
.
id_part
,
elem_classes
=
"edit-user-metadata"
)
as
box
:
...
@@ -147,8 +157,7 @@ class UserMetadataEditor:
...
@@ -147,8 +157,7 @@ class UserMetadataEditor:
def
save_preview
(
self
,
index
,
gallery
,
name
):
def
save_preview
(
self
,
index
,
gallery
,
name
):
if
len
(
gallery
)
==
0
:
if
len
(
gallery
)
==
0
:
print
(
"There is no image in gallery to save as a preview."
)
return
self
.
get_card_html
(
name
),
"There is no image in gallery to save as a preview."
return
[
self
.
get_card_html
(
name
)]
+
self
.
regenerate_ui_pages
()
item
=
self
.
page
.
items
.
get
(
name
,
{})
item
=
self
.
page
.
items
.
get
(
name
,
{})
...
@@ -162,17 +171,20 @@ class UserMetadataEditor:
...
@@ -162,17 +171,20 @@ class UserMetadataEditor:
images
.
save_image_with_geninfo
(
image
,
geninfo
,
item
[
"local_preview"
])
images
.
save_image_with_geninfo
(
image
,
geninfo
,
item
[
"local_preview"
])
return
[
self
.
get_card_html
(
name
)]
+
self
.
regenerate_ui_pages
()
return
self
.
get_card_html
(
name
),
''
def
regenerate_ui_pages
(
self
):
return
[
page
.
create_html
(
self
.
tabname
)
for
page
in
self
.
ui
.
stored_extra_pages
]
def
setup_ui
(
self
,
gallery
):
def
setup_ui
(
self
,
gallery
):
self
.
button_replace_preview
.
click
(
self
.
button_replace_preview
.
click
(
fn
=
self
.
save_preview
,
fn
=
self
.
save_preview
,
_js
=
"function(x, y, z){return [selected_gallery_index(), y, z]}"
,
_js
=
"function(x, y, z){return [selected_gallery_index(), y, z]}"
,
inputs
=
[
self
.
edit_name_input
,
gallery
,
self
.
edit_name_input
],
inputs
=
[
self
.
edit_name_input
,
gallery
,
self
.
edit_name_input
],
outputs
=
[
self
.
html_preview
,
*
self
.
ui
.
pages
]
outputs
=
[
self
.
html_preview
,
self
.
html_status
]
).
then
(
fn
=
None
,
_js
=
"function(name){extraNetworksRefreshSingleCard("
+
json
.
dumps
(
self
.
page
.
name
)
+
","
+
json
.
dumps
(
self
.
tabname
)
+
", name);}"
,
inputs
=
[
self
.
edit_name_input
],
outputs
=
[]
)
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录