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
3bd898b6
Commit
3bd898b6
authored
Jan 21, 2023
by
invincibledude
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First test of different sampler for hi-res fix
parent
f53527f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
+14
-2
modules/processing.py
modules/processing.py
+6
-1
modules/txt2img.py
modules/txt2img.py
+3
-1
modules/ui.py
modules/ui.py
+5
-0
No files found.
modules/processing.py
View file @
3bd898b6
...
...
@@ -710,7 +710,7 @@ def old_hires_fix_first_pass_dimensions(width, height):
class
StableDiffusionProcessingTxt2Img
(
StableDiffusionProcessing
):
sampler
=
None
def
__init__
(
self
,
enable_hr
:
bool
=
False
,
denoising_strength
:
float
=
0.75
,
firstphase_width
:
int
=
0
,
firstphase_height
:
int
=
0
,
hr_scale
:
float
=
2.0
,
hr_upscaler
:
str
=
None
,
hr_second_pass_steps
:
int
=
0
,
hr_resize_x
:
int
=
0
,
hr_resize_y
:
int
=
0
,
**
kwargs
):
def
__init__
(
self
,
enable_hr
:
bool
=
False
,
denoising_strength
:
float
=
0.75
,
firstphase_width
:
int
=
0
,
firstphase_height
:
int
=
0
,
hr_scale
:
float
=
2.0
,
hr_upscaler
:
str
=
None
,
hr_second_pass_steps
:
int
=
0
,
hr_resize_x
:
int
=
0
,
hr_resize_y
:
int
=
0
,
hr_sampler
:
int
=
0
,
**
kwargs
):
super
()
.
__init__
(
**
kwargs
)
self
.
enable_hr
=
enable_hr
self
.
denoising_strength
=
denoising_strength
...
...
@@ -721,6 +721,7 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
self
.
hr_resize_y
=
hr_resize_y
self
.
hr_upscale_to_x
=
hr_resize_x
self
.
hr_upscale_to_y
=
hr_resize_y
self
.
hr_sampler
=
hr_sampler
if
firstphase_width
!=
0
or
firstphase_height
!=
0
:
self
.
hr_upscale_to_x
=
self
.
width
...
...
@@ -862,6 +863,10 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
shared
.
state
.
nextjob
()
img2img_sampler_name
=
self
.
sampler_name
if
self
.
sampler_name
!=
'PLMS'
else
'DDIM'
# PLMS does not support img2img so we just silently switch ot DDIM
if
self
.
hr_sampler
!=
0
and
sd_samplers
.
samplers
[
self
.
hr_sampler
]
.
name
!=
'PLMS'
:
img2img_sampler_name
=
sd_samplers
.
samplers
[
self
.
hr_sampler
]
.
name
self
.
sampler
=
sd_samplers
.
create_sampler
(
img2img_sampler_name
,
self
.
sd_model
)
samples
=
samples
[:,
:,
self
.
truncate_y
//
2
:
samples
.
shape
[
2
]
-
(
self
.
truncate_y
+
1
)
//
2
,
self
.
truncate_x
//
2
:
samples
.
shape
[
3
]
-
(
self
.
truncate_x
+
1
)
//
2
]
...
...
modules/txt2img.py
View file @
3bd898b6
...
...
@@ -8,7 +8,7 @@ import modules.processing as processing
from
modules.ui
import
plaintext_to_html
def
txt2img
(
id_task
:
str
,
prompt
:
str
,
negative_prompt
:
str
,
prompt_styles
,
steps
:
int
,
sampler_index
:
int
,
restore_faces
:
bool
,
tiling
:
bool
,
n_iter
:
int
,
batch_size
:
int
,
cfg_scale
:
float
,
seed
:
int
,
subseed
:
int
,
subseed_strength
:
float
,
seed_resize_from_h
:
int
,
seed_resize_from_w
:
int
,
seed_enable_extras
:
bool
,
height
:
int
,
width
:
int
,
enable_hr
:
bool
,
denoising_strength
:
float
,
hr_scale
:
float
,
hr_upscaler
:
str
,
hr_second_pass_steps
:
int
,
hr_resize_x
:
int
,
hr_resize_y
:
int
,
*
args
):
def
txt2img
(
id_task
:
str
,
prompt
:
str
,
negative_prompt
:
str
,
prompt_styles
,
steps
:
int
,
sampler_index
:
int
,
restore_faces
:
bool
,
tiling
:
bool
,
n_iter
:
int
,
batch_size
:
int
,
cfg_scale
:
float
,
seed
:
int
,
subseed
:
int
,
subseed_strength
:
float
,
seed_resize_from_h
:
int
,
seed_resize_from_w
:
int
,
seed_enable_extras
:
bool
,
height
:
int
,
width
:
int
,
enable_hr
:
bool
,
denoising_strength
:
float
,
hr_scale
:
float
,
hr_upscaler
:
str
,
hr_second_pass_steps
:
int
,
hr_resize_x
:
int
,
hr_resize_y
:
int
,
hr_sampler_index
:
int
,
*
args
):
p
=
StableDiffusionProcessingTxt2Img
(
sd_model
=
shared
.
sd_model
,
outpath_samples
=
opts
.
outdir_samples
or
opts
.
outdir_txt2img_samples
,
...
...
@@ -38,6 +38,8 @@ def txt2img(id_task: str, prompt: str, negative_prompt: str, prompt_styles, step
hr_second_pass_steps
=
hr_second_pass_steps
,
hr_resize_x
=
hr_resize_x
,
hr_resize_y
=
hr_resize_y
,
hr_sampler
=
sd_samplers
.
samplers
[
hr_sampler_index
]
.
name
if
hr_sampler_index
!=
0
else
sd_samplers
.
samplers
[
sampler_index
]
.
name
)
p
.
scripts
=
modules
.
scripts
.
scripts_txt2img
...
...
modules/ui.py
View file @
3bd898b6
...
...
@@ -672,6 +672,9 @@ def create_ui():
hr_resize_x
=
gr
.
Slider
(
minimum
=
0
,
maximum
=
2048
,
step
=
8
,
label
=
"Resize width to"
,
value
=
0
,
elem_id
=
"txt2img_hr_resize_x"
)
hr_resize_y
=
gr
.
Slider
(
minimum
=
0
,
maximum
=
2048
,
step
=
8
,
label
=
"Resize height to"
,
value
=
0
,
elem_id
=
"txt2img_hr_resize_y"
)
with
FormRow
(
elem_id
=
"txt2img_hires_fix_row3"
,
variant
=
"compact"
):
hr_sampler_index
=
gr
.
Dropdown
(
label
=
'Hires sampling method'
,
elem_id
=
f
"hr_sampler"
,
choices
=
[
"---"
]
+
[
x
.
name
for
x
in
samplers
],
value
=
"---"
,
type
=
"index"
)
elif
category
==
"batch"
:
if
not
opts
.
dimensions_and_batch_together
:
with
FormRow
(
elem_id
=
"txt2img_column_batch"
):
...
...
@@ -730,6 +733,7 @@ def create_ui():
hr_second_pass_steps
,
hr_resize_x
,
hr_resize_y
,
hr_sampler_index
,
]
+
custom_inputs
,
outputs
=
[
...
...
@@ -785,6 +789,7 @@ def create_ui():
(
hr_second_pass_steps
,
"Hires steps"
),
(
hr_resize_x
,
"Hires resize-1"
),
(
hr_resize_y
,
"Hires resize-2"
),
(
hr_sampler_index
,
"Hires sampling method"
),
*
modules
.
scripts
.
scripts_txt2img
.
infotext_fields
]
parameters_copypaste
.
add_paste_fields
(
"txt2img"
,
None
,
txt2img_paste_fields
)
...
...
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