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
716a9e03
Commit
716a9e03
authored
Oct 13, 2022
by
yfszzx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
images history delete a number of images consecutively next
parent
df97947b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
29 deletions
+39
-29
images_history.js
javascript/images_history.js
+15
-9
images_history.py
modules/images_history.py
+24
-20
No files found.
javascript/images_history.js
View file @
716a9e03
...
...
@@ -101,7 +101,7 @@ function images_history_get_current_img(tabname, image_path, files){
];
}
function
images_history_delete
(
tabname
,
img_path
,
img_file_name
,
page_index
,
filenames
,
image_index
){
function
images_history_delete
(
del_num
,
tabname
,
img_path
,
img_file_name
,
page_index
,
filenames
,
image_index
){
image_index
=
parseInt
(
image_index
);
var
tab
=
gradioApp
().
getElementById
(
tabname
+
'_images_history'
);
var
set_btn
=
tab
.
querySelector
(
".images_history_set_index"
);
...
...
@@ -112,23 +112,29 @@ function images_history_delete(tabname, img_path, img_file_name, page_index, fil
}
});
var
img_num
=
buttons
.
length
/
2
;
if
(
img_num
===
1
){
if
(
img_num
<=
del_num
){
setTimeout
(
function
(
tabname
){
gradioApp
().
getElementById
(
tabname
+
'_images_history_renew_page'
).
click
();
},
30
,
tabname
);
}
else
{
buttons
[
image_index
].
style
.
display
=
'none'
;
buttons
[
image_index
+
img_num
].
style
.
display
=
'none'
;
}
else
{
var
next_img
for
(
var
i
=
0
;
i
<
del_num
;
i
++
){
if
(
image_index
+
i
<
image_index
+
img_num
){
buttons
[
image_index
+
i
].
style
.
display
=
'none'
;
buttons
[
image_index
+
img_num
+
1
].
style
.
display
=
'none'
;
next_img
=
image_index
+
i
+
1
}
}
var
bnt
;
if
(
image_index
>=
img_num
-
1
){
btn
=
buttons
[
im
g_num
-
2
];
if
(
next_img
>=
img_num
){
btn
=
buttons
[
im
age_index
-
del_num
];
}
else
{
btn
=
buttons
[
image_index
+
1
]
;
btn
=
buttons
[
next_img
]
;
}
setTimeout
(
function
(
btn
){
btn
.
click
()},
30
,
btn
);
}
images_history_disabled_del
();
return
[
tabname
,
img_path
,
img_file_name
,
page_index
,
filenames
,
image_index
];
return
[
del_num
,
tabname
,
img_path
,
img_file_name
,
page_index
,
filenames
,
image_index
];
}
function
images_history_turnpage
(
img_path
,
page_index
,
image_index
,
tabname
){
...
...
modules/images_history.py
View file @
716a9e03
...
...
@@ -54,23 +54,26 @@ def show_image_info(num, image_path, filenames):
#print(f"select image {num}")
file
=
filenames
[
int
(
num
)]
return
file
,
num
,
os
.
path
.
join
(
image_path
,
file
)
def
delete_image
(
tabname
,
dir_name
,
name
,
page_index
,
filenames
,
image_index
):
path
=
os
.
path
.
join
(
dir_name
,
name
)
if
os
.
path
.
exists
(
path
):
print
(
f
"Delete file {path}"
)
os
.
remove
(
path
)
txt_file
=
os
.
path
.
splitext
(
path
)[
0
]
+
".txt"
if
os
.
path
.
exists
(
txt_file
):
os
.
remove
(
txt_file
)
new_file_list
=
[]
for
f
in
filenames
:
if
f
==
name
:
continue
new_file_list
.
append
(
f
)
else
:
print
(
f
"Not exists file {path}"
)
new_file_list
=
filenames
return
page_index
,
new_file_list
def
delete_image
(
delete_num
,
tabname
,
dir_name
,
name
,
page_index
,
filenames
,
image_index
):
delete_num
=
int
(
delete_num
)
index
=
list
(
filenames
)
.
index
(
name
)
i
=
0
new_file_list
=
[]
for
name
in
filenames
:
if
i
>=
index
and
i
<
index
+
delete_num
:
path
=
os
.
path
.
join
(
dir_name
,
name
)
if
os
.
path
.
exists
(
path
):
print
(
f
"Delete file {path}"
)
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
:
new_file_list
.
append
(
name
)
i
+=
1
return
page_index
,
new_file_list
,
1
def
show_images_history
(
gr
,
opts
,
tabname
,
run_pnginfo
,
switch_dict
):
if
tabname
==
"txt2img"
:
...
...
@@ -90,10 +93,11 @@ def show_images_history(gr, opts, tabname, run_pnginfo, switch_dict):
with
gr
.
Row
():
with
gr
.
Column
(
scale
=
2
):
history_gallery
=
gr
.
Gallery
(
show_label
=
False
,
elem_id
=
tabname
+
"_images_history_gallery"
)
.
style
(
grid
=
6
)
delete
=
gr
.
Button
(
'Delete'
,
elem_id
=
tabname
+
"_images_history_del_button"
)
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"
)
with
gr
.
Column
():
with
gr
.
Row
():
#pnginfo = gr.Button('PNG info')
pnginfo_send_to_txt2img
=
gr
.
Button
(
'Send to txt2img'
)
pnginfo_send_to_img2img
=
gr
.
Button
(
'Send to img2img'
)
with
gr
.
Row
():
...
...
@@ -127,7 +131,7 @@ def show_images_history(gr, opts, tabname, run_pnginfo, switch_dict):
#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
])
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
=
[
tabname_box
,
img_path
,
img_file_name
,
page_index
,
filenames
,
image_index
],
outputs
=
[
page_index
,
filenames
])
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
])
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])
...
...
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