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
251ecee6
Commit
251ecee6
authored
Jan 02, 2023
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make "send to" buttons send actual dimension of the sent image rather than fields
parent
8d12a729
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
20 deletions
+42
-20
ui.js
javascript/ui.js
+2
-2
generation_parameters_copypaste.py
modules/generation_parameters_copypaste.py
+40
-18
No files found.
javascript/ui.js
View file @
251ecee6
...
...
@@ -19,7 +19,7 @@ function selected_gallery_index(){
function
extract_image_from_gallery
(
gallery
){
if
(
gallery
.
length
==
1
){
return
gallery
[
0
]
return
[
gallery
[
0
]
]
}
index
=
selected_gallery_index
()
...
...
@@ -28,7 +28,7 @@ function extract_image_from_gallery(gallery){
return
[
null
]
}
return
gallery
[
index
];
return
[
gallery
[
index
]
];
}
function
args_to_array
(
args
){
...
...
modules/generation_parameters_copypaste.py
View file @
251ecee6
...
...
@@ -103,35 +103,57 @@ def bind_buttons(buttons, send_image, send_generate_info):
bind_list
.
append
([
buttons
,
send_image
,
send_generate_info
])
def
send_image_and_dimensions
(
x
):
if
isinstance
(
x
,
Image
.
Image
):
img
=
x
else
:
img
=
image_from_url_text
(
x
)
if
shared
.
opts
.
send_size
and
isinstance
(
img
,
Image
.
Image
):
w
=
img
.
width
h
=
img
.
height
else
:
w
=
gr
.
update
()
h
=
gr
.
update
()
return
img
,
w
,
h
def
run_bind
():
for
buttons
,
s
end_image
,
send_generate_info
in
bind_list
:
for
buttons
,
s
ource_image_component
,
send_generate_info
in
bind_list
:
for
tab
in
buttons
:
button
=
buttons
[
tab
]
if
send_image
and
paste_fields
[
tab
][
"init_img"
]:
if
type
(
send_image
)
==
gr
.
Gallery
:
button
.
click
(
fn
=
lambda
x
:
image_from_url_text
(
x
),
_js
=
"extract_image_from_gallery"
,
inputs
=
[
send_image
],
outputs
=
[
paste_fields
[
tab
][
"init_img"
]],
)
destination_image_component
=
paste_fields
[
tab
][
"init_img"
]
fields
=
paste_fields
[
tab
][
"fields"
]
destination_width_component
=
next
(
iter
([
field
for
field
,
name
in
fields
if
name
==
"Size-1"
]
if
fields
else
[]),
None
)
destination_height_component
=
next
(
iter
([
field
for
field
,
name
in
fields
if
name
==
"Size-2"
]
if
fields
else
[]),
None
)
if
source_image_component
and
destination_image_component
:
if
isinstance
(
source_image_component
,
gr
.
Gallery
):
func
=
send_image_and_dimensions
if
destination_width_component
else
image_from_url_text
jsfunc
=
"extract_image_from_gallery"
else
:
button
.
click
(
fn
=
lambda
x
:
x
,
inputs
=
[
send_image
],
outputs
=
[
paste_fields
[
tab
][
"init_img"
]],
)
func
=
send_image_and_dimensions
if
destination_width_component
else
lambda
x
:
x
jsfunc
=
None
button
.
click
(
fn
=
func
,
_js
=
jsfunc
,
inputs
=
[
source_image_component
],
outputs
=
[
destination_image_component
,
destination_width_component
,
destination_height_component
]
if
destination_width_component
else
[
destination_image_component
],
)
if
send_generate_info
and
paste_fields
[
tab
][
"fields"
]
is
not
None
:
if
send_generate_info
and
fields
is
not
None
:
if
send_generate_info
in
paste_fields
:
paste_field_names
=
[
'Prompt'
,
'Negative prompt'
,
'Steps'
,
'Face restoration'
]
+
([
'Size-1'
,
'Size-2'
]
if
shared
.
opts
.
send_size
else
[])
+
([
"Seed"
]
if
shared
.
opts
.
send_seed
else
[])
paste_field_names
=
[
'Prompt'
,
'Negative prompt'
,
'Steps'
,
'Face restoration'
]
+
([
"Seed"
]
if
shared
.
opts
.
send_seed
else
[])
button
.
click
(
fn
=
lambda
*
x
:
x
,
inputs
=
[
field
for
field
,
name
in
paste_fields
[
send_generate_info
][
"fields"
]
if
name
in
paste_field_names
],
outputs
=
[
field
for
field
,
name
in
paste_fields
[
tab
][
"fields"
]
if
name
in
paste_field_names
],
outputs
=
[
field
for
field
,
name
in
fields
if
name
in
paste_field_names
],
)
else
:
connect_paste
(
button
,
paste_fields
[
tab
][
"fields"
]
,
send_generate_info
)
connect_paste
(
button
,
fields
,
send_generate_info
)
button
.
click
(
fn
=
None
,
...
...
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