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
368f4cc4
Commit
368f4cc4
authored
Oct 14, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set firstpass w/h to 0 by default and rever to old behavior when any are 0
parent
cd58e440
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
21 deletions
+32
-21
modules/processing.py
modules/processing.py
+30
-19
modules/ui.py
modules/ui.py
+2
-2
No files found.
modules/processing.py
View file @
368f4cc4
...
...
@@ -501,17 +501,15 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
class
StableDiffusionProcessingTxt2Img
(
StableDiffusionProcessing
):
sampler
=
None
firstphase_width
=
0
firstphase_height
=
0
firstphase_width_truncated
=
0
firstphase_height_truncated
=
0
def
__init__
(
self
,
enable_hr
=
False
,
denoising_strength
=
0.75
,
firstphase_width
=
512
,
firstphase_height
=
512
,
**
kwargs
):
def
__init__
(
self
,
enable_hr
=
False
,
denoising_strength
=
0.75
,
firstphase_width
=
0
,
firstphase_height
=
0
,
**
kwargs
):
super
()
.
__init__
(
**
kwargs
)
self
.
enable_hr
=
enable_hr
self
.
denoising_strength
=
denoising_strength
self
.
firstphase_width
=
firstphase_width
self
.
firstphase_height
=
firstphase_height
self
.
truncate_x
=
0
self
.
truncate_y
=
0
def
init
(
self
,
all_prompts
,
all_seeds
,
all_subseeds
):
if
self
.
enable_hr
:
...
...
@@ -520,6 +518,32 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
else
:
state
.
job_count
=
state
.
job_count
*
2
if
self
.
firstphase_width
==
0
or
self
.
firstphase_height
==
0
:
desired_pixel_count
=
512
*
512
actual_pixel_count
=
self
.
width
*
self
.
height
scale
=
math
.
sqrt
(
desired_pixel_count
/
actual_pixel_count
)
self
.
firstphase_width
=
math
.
ceil
(
scale
*
self
.
width
/
64
)
*
64
self
.
firstphase_height
=
math
.
ceil
(
scale
*
self
.
height
/
64
)
*
64
firstphase_width_truncated
=
int
(
scale
*
self
.
width
)
firstphase_height_truncated
=
int
(
scale
*
self
.
height
)
else
:
self
.
extra_generation_params
[
"First pass size"
]
=
f
"{self.firstphase_width}x{self.firstphase_height}"
width_ratio
=
self
.
width
/
self
.
firstphase_width
height_ratio
=
self
.
height
/
self
.
firstphase_height
if
width_ratio
>
height_ratio
:
firstphase_width_truncated
=
self
.
firstphase_width
firstphase_height_truncated
=
self
.
firstphase_width
*
self
.
height
/
self
.
width
else
:
firstphase_width_truncated
=
self
.
firstphase_height
*
self
.
width
/
self
.
height
firstphase_height_truncated
=
self
.
firstphase_height
self
.
truncate_x
=
int
(
self
.
firstphase_width
-
firstphase_width_truncated
)
//
opt_f
self
.
truncate_y
=
int
(
self
.
firstphase_height
-
firstphase_height_truncated
)
//
opt_f
def
sample
(
self
,
conditioning
,
unconditional_conditioning
,
seeds
,
subseeds
,
subseed_strength
):
self
.
sampler
=
sd_samplers
.
create_sampler_with_index
(
sd_samplers
.
samplers
,
self
.
sampler_index
,
self
.
sd_model
)
...
...
@@ -528,23 +552,10 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
samples
=
self
.
sampler
.
sample
(
self
,
x
,
conditioning
,
unconditional_conditioning
)
return
samples
self
.
extra_generation_params
[
"First pass size"
]
=
f
"{self.firstphase_width}x{self.firstphase_height}"
x
=
create_random_tensors
([
opt_C
,
self
.
firstphase_height
//
opt_f
,
self
.
firstphase_width
//
opt_f
],
seeds
=
seeds
,
subseeds
=
subseeds
,
subseed_strength
=
self
.
subseed_strength
,
seed_resize_from_h
=
self
.
seed_resize_from_h
,
seed_resize_from_w
=
self
.
seed_resize_from_w
,
p
=
self
)
samples
=
self
.
sampler
.
sample
(
self
,
x
,
conditioning
,
unconditional_conditioning
)
truncate_x
=
0
truncate_y
=
0
width_ratio
=
self
.
width
/
self
.
firstphase_width
height_ratio
=
self
.
height
/
self
.
firstphase_height
if
width_ratio
>
height_ratio
:
truncate_y
=
int
((
self
.
width
-
self
.
firstphase_width
)
/
width_ratio
/
height_ratio
/
opt_f
)
elif
width_ratio
<
height_ratio
:
truncate_x
=
int
((
self
.
height
-
self
.
firstphase_height
)
/
width_ratio
/
height_ratio
/
opt_f
)
samples
=
samples
[:,
:,
truncate_y
//
2
:
samples
.
shape
[
2
]
-
truncate_y
//
2
,
truncate_x
//
2
:
samples
.
shape
[
3
]
-
truncate_x
//
2
]
samples
=
samples
[:,
:,
self
.
truncate_y
//
2
:
samples
.
shape
[
2
]
-
self
.
truncate_y
//
2
,
self
.
truncate_x
//
2
:
samples
.
shape
[
3
]
-
self
.
truncate_x
//
2
]
decoded_samples
=
decode_first_stage
(
self
.
sd_model
,
samples
)
...
...
modules/ui.py
View file @
368f4cc4
...
...
@@ -567,8 +567,8 @@ def create_ui(wrap_gradio_gpu_call):
enable_hr
=
gr
.
Checkbox
(
label
=
'Highres. fix'
,
value
=
False
)
with
gr
.
Row
(
visible
=
False
)
as
hr_options
:
firstphase_width
=
gr
.
Slider
(
minimum
=
64
,
maximum
=
1024
,
step
=
64
,
label
=
"First pass width"
,
value
=
512
)
firstphase_height
=
gr
.
Slider
(
minimum
=
64
,
maximum
=
1024
,
step
=
64
,
label
=
"First pass height"
,
value
=
512
)
firstphase_width
=
gr
.
Slider
(
minimum
=
0
,
maximum
=
1024
,
step
=
64
,
label
=
"First pass width"
,
value
=
0
)
firstphase_height
=
gr
.
Slider
(
minimum
=
0
,
maximum
=
1024
,
step
=
64
,
label
=
"First pass height"
,
value
=
0
)
denoising_strength
=
gr
.
Slider
(
minimum
=
0.0
,
maximum
=
1.0
,
step
=
0.01
,
label
=
'Denoising strength'
,
value
=
0.7
)
with
gr
.
Row
(
equal_height
=
True
):
...
...
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