Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
e5dd4b4e
Commit
e5dd4b4e
authored
May 17, 2023
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove some code duplication from #9348
parent
1d1b5da4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
44 deletions
+19
-44
javascript/ui.js
javascript/ui.js
+15
-39
modules/ui.py
modules/ui.py
+4
-5
No files found.
javascript/ui.js
View file @
e5dd4b4e
...
@@ -441,51 +441,27 @@ function updateImg2imgResizeToTextAfterChangingImage(){
...
@@ -441,51 +441,27 @@ function updateImg2imgResizeToTextAfterChangingImage(){
}
}
function
setRandomSeed
(
target_interface
)
{
let
seed
=
gradioApp
().
querySelector
(
`#
${
target_interface
}
_seed input`
);
if
(
!
seed
)
{
return
[];
}
seed
.
value
=
"
-1
"
;
seed
.
dispatchEvent
(
new
Event
(
"
input
"
));
return
[];
}
function
setRandomSubseed
(
target_interface
)
{
let
subseed
=
gradioApp
().
querySelector
(
`#
${
target_interface
}
_subseed input`
);
if
(
!
subseed
)
{
return
[];
}
subseed
.
value
=
"
-1
"
;
subseed
.
dispatchEvent
(
new
Event
(
"
input
"
));
return
[];
}
function
switchWidthHeightTxt2Img
()
{
function
setRandomSeed
(
elem_id
)
{
let
width
=
gradioApp
().
querySelector
(
"
#txt2img_width input[type=number]
"
);
var
input
=
gradioApp
().
querySelector
(
"
#
"
+
elem_id
+
"
input
"
);
let
height
=
gradioApp
().
querySelector
(
"
#txt2img_height input[type=number]
"
);
if
(
!
input
)
return
[];
if
(
!
width
||
!
height
)
{
return
[];
input
.
value
=
"
-1
"
;
}
updateInput
(
input
);
let
tmp
=
width
.
value
;
width
.
value
=
height
.
value
;
height
.
value
=
tmp
;
width
.
dispatchEvent
(
new
Event
(
"
input
"
));
height
.
dispatchEvent
(
new
Event
(
"
input
"
));
return
[];
return
[];
}
}
function
switchWidthHeightImg2Img
()
{
function
switchWidthHeight
(
tabname
)
{
let
width
=
gradioApp
().
querySelector
(
"
#img2img_width input[type=number]
"
);
var
width
=
gradioApp
().
querySelector
(
"
#
"
+
tabname
+
"
_width input[type=number]
"
);
let
height
=
gradioApp
().
querySelector
(
"
#img2img_height input[type=number]
"
);
var
height
=
gradioApp
().
querySelector
(
"
#
"
+
tabname
+
"
_height input[type=number]
"
);
if
(
!
width
||
!
height
)
{
if
(
!
width
||
!
height
)
return
[];
return
[];
}
var
tmp
=
width
.
value
;
let
tmp
=
width
.
value
;
width
.
value
=
height
.
value
;
width
.
value
=
height
.
value
;
height
.
value
=
tmp
;
height
.
value
=
tmp
;
width
.
dispatchEvent
(
new
Event
(
"
input
"
));
height
.
dispatchEvent
(
new
Event
(
"
input
"
));
updateInput
(
width
);
updateInput
(
height
);
return
[];
return
[];
}
}
modules/ui.py
View file @
e5dd4b4e
...
@@ -189,9 +189,8 @@ def create_seed_inputs(target_interface):
...
@@ -189,9 +189,8 @@ def create_seed_inputs(target_interface):
seed_resize_from_w
=
gr
.
Slider
(
minimum
=
0
,
maximum
=
2048
,
step
=
8
,
label
=
"Resize seed from width"
,
value
=
0
,
elem_id
=
f
"{target_interface}_seed_resize_from_w"
)
seed_resize_from_w
=
gr
.
Slider
(
minimum
=
0
,
maximum
=
2048
,
step
=
8
,
label
=
"Resize seed from width"
,
value
=
0
,
elem_id
=
f
"{target_interface}_seed_resize_from_w"
)
seed_resize_from_h
=
gr
.
Slider
(
minimum
=
0
,
maximum
=
2048
,
step
=
8
,
label
=
"Resize seed from height"
,
value
=
0
,
elem_id
=
f
"{target_interface}_seed_resize_from_h"
)
seed_resize_from_h
=
gr
.
Slider
(
minimum
=
0
,
maximum
=
2048
,
step
=
8
,
label
=
"Resize seed from height"
,
value
=
0
,
elem_id
=
f
"{target_interface}_seed_resize_from_h"
)
target_interface_state
=
gr
.
Textbox
(
target_interface
,
visible
=
False
)
random_seed
.
click
(
fn
=
None
,
_js
=
"function(){setRandomSeed('"
+
target_interface
+
"_seed')}"
,
show_progress
=
False
,
inputs
=
[],
outputs
=
[])
random_seed
.
click
(
fn
=
None
,
_js
=
"setRandomSeed"
,
show_progress
=
False
,
inputs
=
[
target_interface_state
],
outputs
=
[])
random_subseed
.
click
(
fn
=
None
,
_js
=
"function(){setRandomSeed('"
+
target_interface
+
"_subseed')}"
,
show_progress
=
False
,
inputs
=
[],
outputs
=
[])
random_subseed
.
click
(
fn
=
None
,
_js
=
"setRandomSubseed"
,
show_progress
=
False
,
inputs
=
[
target_interface_state
],
outputs
=
[])
def
change_visibility
(
show
):
def
change_visibility
(
show
):
return
{
comp
:
gr_show
(
show
)
for
comp
in
seed_extras
}
return
{
comp
:
gr_show
(
show
)
for
comp
in
seed_extras
}
...
@@ -575,7 +574,7 @@ def create_ui():
...
@@ -575,7 +574,7 @@ def create_ui():
txt2img_prompt
.
submit
(
**
txt2img_args
)
txt2img_prompt
.
submit
(
**
txt2img_args
)
submit
.
click
(
**
txt2img_args
)
submit
.
click
(
**
txt2img_args
)
res_switch_btn
.
click
(
fn
=
None
,
_js
=
"
switchWidthHeightTxt2Img
"
,
inputs
=
None
,
outputs
=
None
,
show_progress
=
False
)
res_switch_btn
.
click
(
fn
=
None
,
_js
=
"
function(){switchWidthHeight('txt2img')}
"
,
inputs
=
None
,
outputs
=
None
,
show_progress
=
False
)
restore_progress_button
.
click
(
restore_progress_button
.
click
(
fn
=
progress
.
restore_progress
,
fn
=
progress
.
restore_progress
,
...
@@ -951,7 +950,7 @@ def create_ui():
...
@@ -951,7 +950,7 @@ def create_ui():
img2img_prompt
.
submit
(
**
img2img_args
)
img2img_prompt
.
submit
(
**
img2img_args
)
submit
.
click
(
**
img2img_args
)
submit
.
click
(
**
img2img_args
)
res_switch_btn
.
click
(
fn
=
None
,
_js
=
"
switchWidthHeightImg2Img
"
,
inputs
=
None
,
outputs
=
None
,
show_progress
=
False
)
res_switch_btn
.
click
(
fn
=
None
,
_js
=
"
function(){switchWidthHeight('img2img')}
"
,
inputs
=
None
,
outputs
=
None
,
show_progress
=
False
)
restore_progress_button
.
click
(
restore_progress_button
.
click
(
fn
=
progress
.
restore_progress
,
fn
=
progress
.
restore_progress
,
...
...
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