Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
a1489f94
Commit
a1489f94
authored
Oct 13, 2022
by
yfszzx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
images history fix all known bug
parent
0186db17
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
42 deletions
+40
-42
.gitignore
.gitignore
+1
-0
images_history.js
javascript/images_history.js
+9
-14
images_history.py
modules/images_history.py
+27
-24
repositorieslatent-diffusion
repositorieslatent-diffusion
+0
-1
style.css
style.css
+3
-3
No files found.
.gitignore
View file @
a1489f94
...
@@ -27,3 +27,4 @@ notification.mp3
...
@@ -27,3 +27,4 @@ notification.mp3
/SwinIR
/SwinIR
/textual_inversion
/textual_inversion
/images_history_testui.py
/images_history_testui.py
/repositorieslatent-diffusion
javascript/images_history.js
View file @
a1489f94
...
@@ -25,11 +25,6 @@ var images_history_click_tab = function(){
...
@@ -25,11 +25,6 @@ var images_history_click_tab = function(){
}
}
}
}
var
images_history_close_full_view
=
function
(){
var
box
=
images_history_get_parent_by_class
(
this
,
"images_history_cantainor"
);
box
.
querySelector
(
".images_history_del_button"
).
setAttribute
(
"disabled"
,
"disabled"
);
}
function
images_history_disabled_del
(){
function
images_history_disabled_del
(){
gradioApp
().
querySelectorAll
(
".images_history_del_button"
).
forEach
(
function
(
btn
){
gradioApp
().
querySelectorAll
(
".images_history_del_button"
).
forEach
(
function
(
btn
){
btn
.
setAttribute
(
'disabled'
,
'disabled'
);
btn
.
setAttribute
(
'disabled'
,
'disabled'
);
...
@@ -182,18 +177,18 @@ setTimeout(images_history_init, 500);
...
@@ -182,18 +177,18 @@ setTimeout(images_history_init, 500);
document
.
addEventListener
(
"DOMContentLoaded"
,
function
()
{
document
.
addEventListener
(
"DOMContentLoaded"
,
function
()
{
var
mutationObserver
=
new
MutationObserver
(
function
(
m
){
var
mutationObserver
=
new
MutationObserver
(
function
(
m
){
for
(
var
i
in
images_history_tab_list
){
for
(
var
i
in
images_history_tab_list
){
var
buttons
=
gradioApp
().
querySelectorAll
(
'#'
+
images_history_tab_list
[
i
]
+
'_images_history .gallery-item'
);
let
tabname
=
images_history_tab_list
[
i
]
var
buttons
=
gradioApp
().
querySelectorAll
(
'#'
+
tabname
+
'_images_history .gallery-item'
);
buttons
.
forEach
(
function
(
bnt
){
buttons
.
forEach
(
function
(
bnt
){
bnt
.
addEventListener
(
'click'
,
images_history_click_image
,
true
);
bnt
.
addEventListener
(
'click'
,
images_history_click_image
,
true
);
});
});
// var cls_btn = gradioApp().getElementById(tabname + '_images_history_gallery').querySelector("svg");
var
cls_btn
=
gradioApp
().
getElementById
(
tabname
+
'_images_history_gallery'
).
querySelector
(
"svg"
);
// if (cls_btn){
if
(
cls_btn
){
// cls_btn.addEventListener('click', images_history_close_full_view, false);
cls_btn
.
addEventListener
(
'click'
,
function
(){
// }
gradioApp
().
getElementById
(
tabname
+
'_images_history_renew_page'
).
click
();
// console.log(cls_btn, cls_btn.parentElement.parentElement)
},
false
);
// if (cls_btn) {
}
// cls_btn = images_history_get_parent_by_tagname(cls_btn, "BUTTON");
// cls_btn.addEventListener('click', images_history_close_full_view, true);
}
}
});
});
mutationObserver
.
observe
(
gradioApp
(),
{
childList
:
true
,
subtree
:
true
});
mutationObserver
.
observe
(
gradioApp
(),
{
childList
:
true
,
subtree
:
true
});
...
...
modules/images_history.py
View file @
a1489f94
...
@@ -38,7 +38,7 @@ def get_recent_images(dir_name, page_index, step, image_index, tabname):
...
@@ -38,7 +38,7 @@ def get_recent_images(dir_name, page_index, step, image_index, tabname):
else
:
else
:
current_file
=
file_list
[
int
(
image_index
)]
current_file
=
file_list
[
int
(
image_index
)]
hide_image
=
os
.
path
.
join
(
dir_name
,
current_file
)
hide_image
=
os
.
path
.
join
(
dir_name
,
current_file
)
return
[
os
.
path
.
join
(
dir_name
,
file
)
for
file
in
file_list
],
page_index
,
file_list
,
current_file
,
hide_image
return
[
os
.
path
.
join
(
dir_name
,
file
)
for
file
in
file_list
],
page_index
,
file_list
,
current_file
,
hide_image
,
""
def
first_page_click
(
dir_name
,
page_index
,
image_index
,
tabname
):
def
first_page_click
(
dir_name
,
page_index
,
image_index
,
tabname
):
return
get_recent_images
(
dir_name
,
1
,
0
,
image_index
,
tabname
)
return
get_recent_images
(
dir_name
,
1
,
0
,
image_index
,
tabname
)
def
end_page_click
(
dir_name
,
page_index
,
image_index
,
tabname
):
def
end_page_click
(
dir_name
,
page_index
,
image_index
,
tabname
):
...
@@ -55,25 +55,28 @@ def show_image_info(num, image_path, filenames):
...
@@ -55,25 +55,28 @@ def show_image_info(num, image_path, filenames):
file
=
filenames
[
int
(
num
)]
file
=
filenames
[
int
(
num
)]
return
file
,
num
,
os
.
path
.
join
(
image_path
,
file
)
return
file
,
num
,
os
.
path
.
join
(
image_path
,
file
)
def
delete_image
(
delete_num
,
tabname
,
dir_name
,
name
,
page_index
,
filenames
,
image_index
):
def
delete_image
(
delete_num
,
tabname
,
dir_name
,
name
,
page_index
,
filenames
,
image_index
):
delete_num
=
int
(
delete_num
)
if
name
==
""
:
index
=
list
(
filenames
)
.
index
(
name
)
return
filenames
,
delete_num
i
=
0
else
:
new_file_list
=
[]
delete_num
=
int
(
delete_num
)
for
name
in
filenames
:
index
=
list
(
filenames
)
.
index
(
name
)
if
i
>=
index
and
i
<
index
+
delete_num
:
i
=
0
path
=
os
.
path
.
join
(
dir_name
,
name
)
new_file_list
=
[]
if
os
.
path
.
exists
(
path
):
for
name
in
filenames
:
print
(
f
"Delete file {path}"
)
if
i
>=
index
and
i
<
index
+
delete_num
:
os
.
remove
(
path
)
path
=
os
.
path
.
join
(
dir_name
,
name
)
txt_file
=
os
.
path
.
splitext
(
path
)[
0
]
+
".txt"
if
os
.
path
.
exists
(
path
):
if
os
.
path
.
exists
(
txt_file
):
print
(
f
"Delete file {path}"
)
os
.
remove
(
txt_file
)
os
.
remove
(
path
)
txt_file
=
os
.
path
.
splitext
(
path
)[
0
]
+
".txt"
if
os
.
path
.
exists
(
txt_file
):
os
.
remove
(
txt_file
)
else
:
print
(
f
"Not exists file {path}"
)
else
:
else
:
print
(
f
"Not exists file {path}"
)
new_file_list
.
append
(
name
)
else
:
i
+=
1
new_file_list
.
append
(
name
)
return
new_file_list
,
1
i
+=
1
return
page_index
,
new_file_list
,
1
def
show_images_history
(
gr
,
opts
,
tabname
,
run_pnginfo
,
switch_dict
):
def
show_images_history
(
gr
,
opts
,
tabname
,
run_pnginfo
,
switch_dict
):
if
tabname
==
"txt2img"
:
if
tabname
==
"txt2img"
:
...
@@ -93,9 +96,9 @@ def show_images_history(gr, opts, tabname, run_pnginfo, switch_dict):
...
@@ -93,9 +96,9 @@ def show_images_history(gr, opts, tabname, run_pnginfo, switch_dict):
with
gr
.
Row
():
with
gr
.
Row
():
with
gr
.
Column
(
scale
=
2
):
with
gr
.
Column
(
scale
=
2
):
history_gallery
=
gr
.
Gallery
(
show_label
=
False
,
elem_id
=
tabname
+
"_images_history_gallery"
)
.
style
(
grid
=
6
)
history_gallery
=
gr
.
Gallery
(
show_label
=
False
,
elem_id
=
tabname
+
"_images_history_gallery"
)
.
style
(
grid
=
6
)
with
gr
.
Row
():
with
gr
.
Row
():
delete
=
gr
.
Button
(
'Delete'
,
elem_id
=
tabname
+
"_images_history_del_button"
)
delete
_num
=
gr
.
Number
(
value
=
1
,
interactive
=
True
,
label
=
"number of images to delete consecutively next"
)
delete
_num
=
gr
.
Number
(
value
=
1
,
interactive
=
True
,
label
=
"number of images to delete consecutively next"
)
delete
=
gr
.
Button
(
'Delete'
,
elem_id
=
tabname
+
"_images_history_del_button"
)
with
gr
.
Column
():
with
gr
.
Column
():
with
gr
.
Row
():
with
gr
.
Row
():
pnginfo_send_to_txt2img
=
gr
.
Button
(
'Send to txt2img'
)
pnginfo_send_to_txt2img
=
gr
.
Button
(
'Send to txt2img'
)
...
@@ -118,7 +121,7 @@ def show_images_history(gr, opts, tabname, run_pnginfo, switch_dict):
...
@@ -118,7 +121,7 @@ def show_images_history(gr, opts, tabname, run_pnginfo, switch_dict):
# turn pages
# turn pages
gallery_inputs
=
[
img_path
,
page_index
,
image_index
,
tabname_box
]
gallery_inputs
=
[
img_path
,
page_index
,
image_index
,
tabname_box
]
gallery_outputs
=
[
history_gallery
,
page_index
,
filenames
,
img_file_name
,
hide_image
]
gallery_outputs
=
[
history_gallery
,
page_index
,
filenames
,
img_file_name
,
hide_image
,
img_file_name
]
first_page
.
click
(
first_page_click
,
_js
=
"images_history_turnpage"
,
inputs
=
gallery_inputs
,
outputs
=
gallery_outputs
)
first_page
.
click
(
first_page_click
,
_js
=
"images_history_turnpage"
,
inputs
=
gallery_inputs
,
outputs
=
gallery_outputs
)
next_page
.
click
(
next_page_click
,
_js
=
"images_history_turnpage"
,
inputs
=
gallery_inputs
,
outputs
=
gallery_outputs
)
next_page
.
click
(
next_page_click
,
_js
=
"images_history_turnpage"
,
inputs
=
gallery_inputs
,
outputs
=
gallery_outputs
)
...
@@ -131,7 +134,7 @@ def show_images_history(gr, opts, tabname, run_pnginfo, switch_dict):
...
@@ -131,7 +134,7 @@ def show_images_history(gr, opts, tabname, run_pnginfo, switch_dict):
#other funcitons
#other funcitons
set_index
.
click
(
show_image_info
,
_js
=
"images_history_get_current_img"
,
inputs
=
[
tabname_box
,
img_path
,
filenames
],
outputs
=
[
img_file_name
,
image_index
,
hide_image
])
set_index
.
click
(
show_image_info
,
_js
=
"images_history_get_current_img"
,
inputs
=
[
tabname_box
,
img_path
,
filenames
],
outputs
=
[
img_file_name
,
image_index
,
hide_image
])
img_file_name
.
change
(
fn
=
None
,
_js
=
"images_history_enable_del_buttons"
,
inputs
=
None
,
outputs
=
None
)
img_file_name
.
change
(
fn
=
None
,
_js
=
"images_history_enable_del_buttons"
,
inputs
=
None
,
outputs
=
None
)
delete
.
click
(
delete_image
,
_js
=
"images_history_delete"
,
inputs
=
[
delete_num
,
tabname_box
,
img_path
,
img_file_name
,
page_index
,
filenames
,
image_index
],
outputs
=
[
page_index
,
filenames
,
delete_num
])
delete
.
click
(
delete_image
,
_js
=
"images_history_delete"
,
inputs
=
[
delete_num
,
tabname_box
,
img_path
,
img_file_name
,
page_index
,
filenames
,
image_index
],
outputs
=
[
filenames
,
delete_num
])
hide_image
.
change
(
fn
=
run_pnginfo
,
inputs
=
[
hide_image
],
outputs
=
[
info1
,
img_file_info
,
info2
])
hide_image
.
change
(
fn
=
run_pnginfo
,
inputs
=
[
hide_image
],
outputs
=
[
info1
,
img_file_info
,
info2
])
#pnginfo.click(fn=run_pnginfo, inputs=[hide_image], outputs=[info1, img_file_info, info2])
#pnginfo.click(fn=run_pnginfo, inputs=[hide_image], outputs=[info1, img_file_info, info2])
...
...
repositorieslatent-diffusion
@
abf33e70
Subproject commit abf33e7002d59d9085081bce93ec798dcabd49af
style.css
View file @
a1489f94
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
padding-right
:
0.25em
;
padding-right
:
0.25em
;
margin
:
0.1em
0
;
margin
:
0.1em
0
;
opacity
:
0%
;
opacity
:
0%
;
cursor
:
default
;
cursor
:
default
;
}
}
.output-html
p
{
margin
:
0
0.5em
;}
.output-html
p
{
margin
:
0
0.5em
;}
...
@@ -442,7 +442,7 @@ input[type="range"]{
...
@@ -442,7 +442,7 @@ input[type="range"]{
}
}
.red
{
.red
{
color
:
red
;
color
:
red
;
}
}
.gallery-item
{
.gallery-item
{
...
@@ -505,4 +505,4 @@ canvas[key="mask"] {
...
@@ -505,4 +505,4 @@ canvas[key="mask"] {
top
:
-0.6em
;
top
:
-0.6em
;
z-index
:
200
;
z-index
:
200
;
width
:
8em
;
width
:
8em
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment