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
ec95ced6
Unverified
Commit
ec95ced6
authored
Nov 11, 2022
by
AUTOMATIC1111
Committed by
GitHub
Nov 11, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4573 from liamkerr/4415-update-generation-info
4415 update generation info
parents
73776907
b9874012
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
1 deletion
+62
-1
generationParams.js
javascript/generationParams.js
+33
-0
ui.py
modules/ui.py
+22
-0
prompt_matrix.py
scripts/prompt_matrix.py
+2
-0
prompts_from_file.py
scripts/prompts_from_file.py
+5
-1
No files found.
javascript/generationParams.js
0 → 100644
View file @
ec95ced6
// attaches listeners to the txt2img and img2img galleries to update displayed generation param text when the image changes
let
txt2img_gallery
,
img2img_gallery
,
modal
=
undefined
;
onUiUpdate
(
function
(){
if
(
!
txt2img_gallery
)
{
txt2img_gallery
=
attachGalleryListeners
(
"txt2img"
)
}
if
(
!
img2img_gallery
)
{
img2img_gallery
=
attachGalleryListeners
(
"img2img"
)
}
if
(
!
modal
)
{
modal
=
gradioApp
().
getElementById
(
'lightboxModal'
)
modalObserver
.
observe
(
modal
,
{
attributes
:
true
,
attributeFilter
:
[
'style'
]
});
}
});
let
modalObserver
=
new
MutationObserver
(
function
(
mutations
)
{
mutations
.
forEach
(
function
(
mutationRecord
)
{
let
selectedTab
=
gradioApp
().
querySelector
(
'#tabs div button.bg-white'
)?.
innerText
if
(
mutationRecord
.
target
.
style
.
display
===
'none'
&&
selectedTab
===
'txt2img'
||
selectedTab
===
'img2img'
)
gradioApp
().
getElementById
(
selectedTab
+
"_generation_info_button"
).
click
()
});
});
function
attachGalleryListeners
(
tab_name
)
{
gallery
=
gradioApp
().
querySelector
(
'#'
+
tab_name
+
'_gallery'
)
gallery
?.
addEventListener
(
'click'
,
()
=>
gradioApp
().
getElementById
(
tab_name
+
"_generation_info_button"
).
click
());
gallery
?.
addEventListener
(
'keydown'
,
(
e
)
=>
{
if
(
e
.
keyCode
==
37
||
e
.
keyCode
==
39
)
// left or right arrow
gradioApp
().
getElementById
(
tab_name
+
"_generation_info_button"
).
click
()
});
return
gallery
;
}
modules/ui.py
View file @
ec95ced6
...
@@ -566,6 +566,19 @@ def apply_setting(key, value):
...
@@ -566,6 +566,19 @@ def apply_setting(key, value):
return
value
return
value
def
update_generation_info
(
args
):
generation_info
,
html_info
,
img_index
=
args
try
:
generation_info
=
json
.
loads
(
generation_info
)
if
img_index
<
0
or
img_index
>=
len
(
generation_info
[
"infotexts"
]):
return
html_info
return
plaintext_to_html
(
generation_info
[
"infotexts"
][
img_index
])
except
Exception
:
pass
# if the json parse or anything else fails, just return the old html_info
return
html_info
def
create_refresh_button
(
refresh_component
,
refresh_method
,
refreshed_args
,
elem_id
):
def
create_refresh_button
(
refresh_component
,
refresh_method
,
refreshed_args
,
elem_id
):
def
refresh
():
def
refresh
():
refresh_method
()
refresh_method
()
...
@@ -638,6 +651,15 @@ Requested path was: {f}
...
@@ -638,6 +651,15 @@ Requested path was: {f}
with
gr
.
Group
():
with
gr
.
Group
():
html_info
=
gr
.
HTML
()
html_info
=
gr
.
HTML
()
generation_info
=
gr
.
Textbox
(
visible
=
False
)
generation_info
=
gr
.
Textbox
(
visible
=
False
)
if
tabname
==
'txt2img'
or
tabname
==
'img2img'
:
generation_info_button
=
gr
.
Button
(
visible
=
False
,
elem_id
=
f
"{tabname}_generation_info_button"
)
generation_info_button
.
click
(
fn
=
update_generation_info
,
_js
=
"(x, y) => [x, y, selected_gallery_index()]"
,
inputs
=
[
generation_info
,
html_info
],
outputs
=
[
html_info
],
preprocess
=
False
)
save
.
click
(
save
.
click
(
fn
=
wrap_gradio_call
(
save_files
),
fn
=
wrap_gradio_call
(
save_files
),
...
...
scripts/prompt_matrix.py
View file @
ec95ced6
...
@@ -80,6 +80,8 @@ class Script(scripts.Script):
...
@@ -80,6 +80,8 @@ class Script(scripts.Script):
grid
=
images
.
image_grid
(
processed
.
images
,
p
.
batch_size
,
rows
=
1
<<
((
len
(
prompt_matrix_parts
)
-
1
)
//
2
))
grid
=
images
.
image_grid
(
processed
.
images
,
p
.
batch_size
,
rows
=
1
<<
((
len
(
prompt_matrix_parts
)
-
1
)
//
2
))
grid
=
images
.
draw_prompt_matrix
(
grid
,
p
.
width
,
p
.
height
,
prompt_matrix_parts
)
grid
=
images
.
draw_prompt_matrix
(
grid
,
p
.
width
,
p
.
height
,
prompt_matrix_parts
)
processed
.
images
.
insert
(
0
,
grid
)
processed
.
images
.
insert
(
0
,
grid
)
processed
.
index_of_first_image
=
1
processed
.
infotexts
.
insert
(
0
,
processed
.
infotexts
[
0
])
if
opts
.
grid_save
:
if
opts
.
grid_save
:
images
.
save_image
(
processed
.
images
[
0
],
p
.
outpath_grids
,
"prompt_matrix"
,
prompt
=
original_prompt
,
seed
=
processed
.
seed
,
grid
=
True
,
p
=
p
)
images
.
save_image
(
processed
.
images
[
0
],
p
.
outpath_grids
,
"prompt_matrix"
,
prompt
=
original_prompt
,
seed
=
processed
.
seed
,
grid
=
True
,
p
=
p
)
...
...
scripts/prompts_from_file.py
View file @
ec95ced6
...
@@ -145,6 +145,8 @@ class Script(scripts.Script):
...
@@ -145,6 +145,8 @@ class Script(scripts.Script):
state
.
job_count
=
job_count
state
.
job_count
=
job_count
images
=
[]
images
=
[]
all_prompts
=
[]
infotexts
=
[]
for
n
,
args
in
enumerate
(
jobs
):
for
n
,
args
in
enumerate
(
jobs
):
state
.
job
=
f
"{state.job_no + 1} out of {state.job_count}"
state
.
job
=
f
"{state.job_no + 1} out of {state.job_count}"
...
@@ -157,5 +159,7 @@ class Script(scripts.Script):
...
@@ -157,5 +159,7 @@ class Script(scripts.Script):
if
checkbox_iterate
:
if
checkbox_iterate
:
p
.
seed
=
p
.
seed
+
(
p
.
batch_size
*
p
.
n_iter
)
p
.
seed
=
p
.
seed
+
(
p
.
batch_size
*
p
.
n_iter
)
all_prompts
+=
proc
.
all_prompts
infotexts
+=
proc
.
infotexts
return
Processed
(
p
,
images
,
p
.
seed
,
""
)
return
Processed
(
p
,
images
,
p
.
seed
,
""
,
all_prompts
=
all_prompts
,
infotexts
=
infotexts
)
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