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
2e3a0f39
Commit
2e3a0f39
authored
Mar 12, 2024
by
Andray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move upscale postprocessing under input accordion
parent
3e0146f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
scripts/postprocessing_upscale.py
scripts/postprocessing_upscale.py
+15
-11
No files found.
scripts/postprocessing_upscale.py
View file @
2e3a0f39
...
...
@@ -4,7 +4,7 @@ import numpy as np
from
modules
import
scripts_postprocessing
,
shared
import
gradio
as
gr
from
modules.ui_components
import
FormRow
,
ToolButton
from
modules.ui_components
import
FormRow
,
ToolButton
,
InputAccordion
from
modules.ui
import
switch_values_symbol
upscale_cache
=
{}
...
...
@@ -17,7 +17,14 @@ class ScriptPostprocessingUpscale(scripts_postprocessing.ScriptPostprocessing):
def
ui
(
self
):
selected_tab
=
gr
.
Number
(
value
=
0
,
visible
=
False
)
with
gr
.
Column
():
with
InputAccordion
(
True
,
label
=
"Upscale"
,
elem_id
=
"extras_upscale"
)
as
upscale_enabled
:
with
FormRow
():
extras_upscaler_1
=
gr
.
Dropdown
(
label
=
'Upscaler 1'
,
elem_id
=
"extras_upscaler_1"
,
choices
=
[
x
.
name
for
x
in
shared
.
sd_upscalers
],
value
=
shared
.
sd_upscalers
[
0
]
.
name
)
with
FormRow
():
extras_upscaler_2
=
gr
.
Dropdown
(
label
=
'Upscaler 2'
,
elem_id
=
"extras_upscaler_2"
,
choices
=
[
x
.
name
for
x
in
shared
.
sd_upscalers
],
value
=
shared
.
sd_upscalers
[
0
]
.
name
)
extras_upscaler_2_visibility
=
gr
.
Slider
(
minimum
=
0.0
,
maximum
=
1.0
,
step
=
0.001
,
label
=
"Upscaler 2 visibility"
,
value
=
0.0
,
elem_id
=
"extras_upscaler_2_visibility"
)
with
FormRow
():
with
gr
.
Tabs
(
elem_id
=
"extras_resize_mode"
):
with
gr
.
TabItem
(
'Scale by'
,
elem_id
=
"extras_scale_by_tab"
)
as
tab_scale_by
:
...
...
@@ -32,18 +39,12 @@ class ScriptPostprocessingUpscale(scripts_postprocessing.ScriptPostprocessing):
upscaling_res_switch_btn
=
ToolButton
(
value
=
switch_values_symbol
,
elem_id
=
"upscaling_res_switch_btn"
,
tooltip
=
"Switch width/height"
)
upscaling_crop
=
gr
.
Checkbox
(
label
=
'Crop to fit'
,
value
=
True
,
elem_id
=
"extras_upscaling_crop"
)
with
FormRow
():
extras_upscaler_1
=
gr
.
Dropdown
(
label
=
'Upscaler 1'
,
elem_id
=
"extras_upscaler_1"
,
choices
=
[
x
.
name
for
x
in
shared
.
sd_upscalers
],
value
=
shared
.
sd_upscalers
[
0
]
.
name
)
with
FormRow
():
extras_upscaler_2
=
gr
.
Dropdown
(
label
=
'Upscaler 2'
,
elem_id
=
"extras_upscaler_2"
,
choices
=
[
x
.
name
for
x
in
shared
.
sd_upscalers
],
value
=
shared
.
sd_upscalers
[
0
]
.
name
)
extras_upscaler_2_visibility
=
gr
.
Slider
(
minimum
=
0.0
,
maximum
=
1.0
,
step
=
0.001
,
label
=
"Upscaler 2 visibility"
,
value
=
0.0
,
elem_id
=
"extras_upscaler_2_visibility"
)
upscaling_res_switch_btn
.
click
(
lambda
w
,
h
:
(
h
,
w
),
inputs
=
[
upscaling_resize_w
,
upscaling_resize_h
],
outputs
=
[
upscaling_resize_w
,
upscaling_resize_h
],
show_progress
=
False
)
tab_scale_by
.
select
(
fn
=
lambda
:
0
,
inputs
=
[],
outputs
=
[
selected_tab
])
tab_scale_to
.
select
(
fn
=
lambda
:
1
,
inputs
=
[],
outputs
=
[
selected_tab
])
return
{
"upscale_enabled"
:
upscale_enabled
,
"upscale_mode"
:
selected_tab
,
"upscale_by"
:
upscaling_resize
,
"upscale_to_width"
:
upscaling_resize_w
,
...
...
@@ -81,7 +82,7 @@ class ScriptPostprocessingUpscale(scripts_postprocessing.ScriptPostprocessing):
return
image
def
process_firstpass
(
self
,
pp
:
scripts_postprocessing
.
PostprocessedImage
,
upscale_mode
=
1
,
upscale_by
=
2.0
,
upscale_to_width
=
None
,
upscale_to_height
=
None
,
upscale_crop
=
False
,
upscaler_1_name
=
None
,
upscaler_2_name
=
None
,
upscaler_2_visibility
=
0.0
):
def
process_firstpass
(
self
,
pp
:
scripts_postprocessing
.
PostprocessedImage
,
upscale_
enabled
=
True
,
upscale_
mode
=
1
,
upscale_by
=
2.0
,
upscale_to_width
=
None
,
upscale_to_height
=
None
,
upscale_crop
=
False
,
upscaler_1_name
=
None
,
upscaler_2_name
=
None
,
upscaler_2_visibility
=
0.0
):
if
upscale_mode
==
1
:
pp
.
shared
.
target_width
=
upscale_to_width
pp
.
shared
.
target_height
=
upscale_to_height
...
...
@@ -89,7 +90,10 @@ class ScriptPostprocessingUpscale(scripts_postprocessing.ScriptPostprocessing):
pp
.
shared
.
target_width
=
int
(
pp
.
image
.
width
*
upscale_by
)
pp
.
shared
.
target_height
=
int
(
pp
.
image
.
height
*
upscale_by
)
def
process
(
self
,
pp
:
scripts_postprocessing
.
PostprocessedImage
,
upscale_mode
=
1
,
upscale_by
=
2.0
,
upscale_to_width
=
None
,
upscale_to_height
=
None
,
upscale_crop
=
False
,
upscaler_1_name
=
None
,
upscaler_2_name
=
None
,
upscaler_2_visibility
=
0.0
):
def
process
(
self
,
pp
:
scripts_postprocessing
.
PostprocessedImage
,
upscale_enabled
=
True
,
upscale_mode
=
1
,
upscale_by
=
2.0
,
upscale_to_width
=
None
,
upscale_to_height
=
None
,
upscale_crop
=
False
,
upscaler_1_name
=
None
,
upscaler_2_name
=
None
,
upscaler_2_visibility
=
0.0
):
if
not
upscale_enabled
:
return
if
upscaler_1_name
==
"None"
:
upscaler_1_name
=
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