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
2aec11d2
Commit
2aec11d2
authored
Sep 16, 2022
by
Elias Sundqvist
Committed by
AUTOMATIC1111
Sep 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add randomness and denoising strength support to alternative img2img
parent
b8cf2ea8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
8 deletions
+30
-8
scripts/img2imgalt.py
scripts/img2imgalt.py
+30
-8
No files found.
scripts/img2imgalt.py
View file @
2aec11d2
...
...
@@ -76,10 +76,10 @@ class Script(scripts.Script):
original_prompt
=
gr
.
Textbox
(
label
=
"Original prompt"
,
lines
=
1
)
cfg
=
gr
.
Slider
(
label
=
"Decode CFG scale"
,
minimum
=
0.0
,
maximum
=
15.0
,
step
=
0.1
,
value
=
1.0
)
st
=
gr
.
Slider
(
label
=
"Decode steps"
,
minimum
=
1
,
maximum
=
150
,
step
=
1
,
value
=
50
)
randomness
=
gr
.
Slider
(
label
=
"randomness"
,
minimum
=
0.0
,
maximum
=
1.0
,
step
=
0.01
,
value
=
0.0
)
return
[
original_prompt
,
cfg
,
st
,
randomness
]
return
[
original_prompt
,
cfg
,
st
]
def
run
(
self
,
p
,
original_prompt
,
cfg
,
st
):
def
run
(
self
,
p
,
original_prompt
,
cfg
,
st
,
randomness
):
p
.
batch_size
=
1
p
.
batch_count
=
1
...
...
@@ -90,18 +90,40 @@ class Script(scripts.Script):
same_everything
=
same_params
and
self
.
cache
.
latent
.
shape
==
lat
.
shape
and
np
.
abs
(
self
.
cache
.
latent
-
lat
)
.
sum
()
<
100
if
same_everything
:
noise
=
self
.
cache
.
noise
rec_
noise
=
self
.
cache
.
noise
else
:
shared
.
state
.
job_count
+=
1
cond
=
p
.
sd_model
.
get_learned_conditioning
(
p
.
batch_size
*
[
original_prompt
])
uncond
=
p
.
sd_model
.
get_learned_conditioning
(
p
.
batch_size
*
[
""
])
noise
=
find_noise_for_image
(
p
,
cond
,
uncond
,
cfg
,
st
)
self
.
cache
=
Cached
(
noise
,
cfg
,
st
,
lat
,
original_prompt
)
rec_
noise
=
find_noise_for_image
(
p
,
cond
,
uncond
,
cfg
,
st
)
self
.
cache
=
Cached
(
rec_
noise
,
cfg
,
st
,
lat
,
original_prompt
)
rand_noise
=
processing
.
create_random_tensors
(
p
.
init_latent
.
shape
[
1
:],
[
p
.
seed
+
x
+
1
for
x
in
range
(
p
.
init_latent
.
shape
[
0
])])
combined_noise
=
((
1
-
randomness
)
*
rec_noise
+
randomness
*
rand_noise
)
/
((
randomness
**
2
+
(
1
-
randomness
)
**
2
)
**
0.5
)
sampler
=
samplers
[
p
.
sampler_index
]
.
constructor
(
p
.
sd_model
)
samples_ddim
=
sampler
.
sample
(
p
,
noise
,
conditioning
,
unconditional_conditioning
)
return
samples_ddim
sigmas
=
sampler
.
model_wrap
.
get_sigmas
(
p
.
steps
)
t_enc
=
int
(
min
(
p
.
denoising_strength
,
0.999
)
*
p
.
steps
)
noise_dt
=
combined_noise
-
(
p
.
init_latent
/
sigmas
[
0
]
)
noise_dt
=
noise_dt
*
sigmas
[
p
.
steps
-
t_enc
-
1
]
noise
=
p
.
init_latent
+
noise_dt
sigma_sched
=
sigmas
[
p
.
steps
-
t_enc
-
1
:]
sampler
.
model_wrap_cfg
.
mask
=
p
.
mask
sampler
.
model_wrap_cfg
.
nmask
=
p
.
nmask
sampler
.
model_wrap_cfg
.
init_latent
=
p
.
init_latent
if
hasattr
(
K
.
sampling
,
'trange'
):
K
.
sampling
.
trange
=
lambda
*
args
,
**
kwargs
:
sd_samplers
.
extended_trange
(
*
args
,
**
kwargs
)
p
.
seed
=
p
.
seed
+
1
return
sampler
.
func
(
sampler
.
model_wrap_cfg
,
noise
,
sigma_sched
,
extra_args
=
{
'cond'
:
conditioning
,
'uncond'
:
unconditional_conditioning
,
'cond_scale'
:
p
.
cfg_scale
},
disable
=
False
,
callback
=
sampler
.
callback_state
)
p
.
sample
=
sample_extra
...
...
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