Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
983d48a9
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
11 个月 前同步成功
通知
1754
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
983d48a9
编写于
3月 25, 2023
作者:
A
AUTOMATIC1111
提交者:
GitHub
3月 25, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #8772 from mcmonkey4eva/img2img-alt-sd2-fix
Fix img2img-alternative-test script for SD v2.x
上级
b7c14ed0
c9c692c4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
14 deletion
+16
-14
scripts/img2imgalt.py
scripts/img2imgalt.py
+16
-14
未找到文件。
scripts/img2imgalt.py
浏览文件 @
983d48a9
...
@@ -6,23 +6,21 @@ from tqdm import trange
...
@@ -6,23 +6,21 @@ from tqdm import trange
import
modules.scripts
as
scripts
import
modules.scripts
as
scripts
import
gradio
as
gr
import
gradio
as
gr
from
modules
import
processing
,
shared
,
sd_samplers
,
prompt_parser
,
sd_samplers_common
from
modules
import
processing
,
shared
,
sd_samplers
,
sd_samplers_common
from
modules.processing
import
Processed
from
modules.shared
import
opts
,
cmd_opts
,
state
import
torch
import
torch
import
k_diffusion
as
K
import
k_diffusion
as
K
from
PIL
import
Image
from
torch
import
autocast
from
einops
import
rearrange
,
repeat
def
find_noise_for_image
(
p
,
cond
,
uncond
,
cfg_scale
,
steps
):
def
find_noise_for_image
(
p
,
cond
,
uncond
,
cfg_scale
,
steps
):
x
=
p
.
init_latent
x
=
p
.
init_latent
s_in
=
x
.
new_ones
([
x
.
shape
[
0
]])
s_in
=
x
.
new_ones
([
x
.
shape
[
0
]])
dnw
=
K
.
external
.
CompVisDenoiser
(
shared
.
sd_model
)
if
shared
.
sd_model
.
parameterization
==
"v"
:
dnw
=
K
.
external
.
CompVisVDenoiser
(
shared
.
sd_model
)
skip
=
1
else
:
dnw
=
K
.
external
.
CompVisDenoiser
(
shared
.
sd_model
)
skip
=
0
sigmas
=
dnw
.
get_sigmas
(
steps
).
flip
(
0
)
sigmas
=
dnw
.
get_sigmas
(
steps
).
flip
(
0
)
shared
.
state
.
sampling_steps
=
steps
shared
.
state
.
sampling_steps
=
steps
...
@@ -37,7 +35,7 @@ def find_noise_for_image(p, cond, uncond, cfg_scale, steps):
...
@@ -37,7 +35,7 @@ def find_noise_for_image(p, cond, uncond, cfg_scale, steps):
image_conditioning
=
torch
.
cat
([
p
.
image_conditioning
]
*
2
)
image_conditioning
=
torch
.
cat
([
p
.
image_conditioning
]
*
2
)
cond_in
=
{
"c_concat"
:
[
image_conditioning
],
"c_crossattn"
:
[
cond_in
]}
cond_in
=
{
"c_concat"
:
[
image_conditioning
],
"c_crossattn"
:
[
cond_in
]}
c_out
,
c_in
=
[
K
.
utils
.
append_dims
(
k
,
x_in
.
ndim
)
for
k
in
dnw
.
get_scalings
(
sigma_in
)]
c_out
,
c_in
=
[
K
.
utils
.
append_dims
(
k
,
x_in
.
ndim
)
for
k
in
dnw
.
get_scalings
(
sigma_in
)
[
skip
:]
]
t
=
dnw
.
sigma_to_t
(
sigma_in
)
t
=
dnw
.
sigma_to_t
(
sigma_in
)
eps
=
shared
.
sd_model
.
apply_model
(
x_in
*
c_in
,
t
,
cond
=
cond_in
)
eps
=
shared
.
sd_model
.
apply_model
(
x_in
*
c_in
,
t
,
cond
=
cond_in
)
...
@@ -69,7 +67,12 @@ def find_noise_for_image_sigma_adjustment(p, cond, uncond, cfg_scale, steps):
...
@@ -69,7 +67,12 @@ def find_noise_for_image_sigma_adjustment(p, cond, uncond, cfg_scale, steps):
x
=
p
.
init_latent
x
=
p
.
init_latent
s_in
=
x
.
new_ones
([
x
.
shape
[
0
]])
s_in
=
x
.
new_ones
([
x
.
shape
[
0
]])
dnw
=
K
.
external
.
CompVisDenoiser
(
shared
.
sd_model
)
if
shared
.
sd_model
.
parameterization
==
"v"
:
dnw
=
K
.
external
.
CompVisVDenoiser
(
shared
.
sd_model
)
skip
=
1
else
:
dnw
=
K
.
external
.
CompVisDenoiser
(
shared
.
sd_model
)
skip
=
0
sigmas
=
dnw
.
get_sigmas
(
steps
).
flip
(
0
)
sigmas
=
dnw
.
get_sigmas
(
steps
).
flip
(
0
)
shared
.
state
.
sampling_steps
=
steps
shared
.
state
.
sampling_steps
=
steps
...
@@ -84,7 +87,7 @@ def find_noise_for_image_sigma_adjustment(p, cond, uncond, cfg_scale, steps):
...
@@ -84,7 +87,7 @@ def find_noise_for_image_sigma_adjustment(p, cond, uncond, cfg_scale, steps):
image_conditioning
=
torch
.
cat
([
p
.
image_conditioning
]
*
2
)
image_conditioning
=
torch
.
cat
([
p
.
image_conditioning
]
*
2
)
cond_in
=
{
"c_concat"
:
[
image_conditioning
],
"c_crossattn"
:
[
cond_in
]}
cond_in
=
{
"c_concat"
:
[
image_conditioning
],
"c_crossattn"
:
[
cond_in
]}
c_out
,
c_in
=
[
K
.
utils
.
append_dims
(
k
,
x_in
.
ndim
)
for
k
in
dnw
.
get_scalings
(
sigma_in
)]
c_out
,
c_in
=
[
K
.
utils
.
append_dims
(
k
,
x_in
.
ndim
)
for
k
in
dnw
.
get_scalings
(
sigma_in
)
[
skip
:]
]
if
i
==
1
:
if
i
==
1
:
t
=
dnw
.
sigma_to_t
(
torch
.
cat
([
sigmas
[
i
]
*
s_in
]
*
2
))
t
=
dnw
.
sigma_to_t
(
torch
.
cat
([
sigmas
[
i
]
*
s_in
]
*
2
))
...
@@ -125,7 +128,7 @@ class Script(scripts.Script):
...
@@ -125,7 +128,7 @@ class Script(scripts.Script):
def
show
(
self
,
is_img2img
):
def
show
(
self
,
is_img2img
):
return
is_img2img
return
is_img2img
def
ui
(
self
,
is_img2img
):
def
ui
(
self
,
is_img2img
):
info
=
gr
.
Markdown
(
'''
info
=
gr
.
Markdown
(
'''
* `CFG Scale` should be 2 or lower.
* `CFG Scale` should be 2 or lower.
'''
)
'''
)
...
@@ -213,4 +216,3 @@ class Script(scripts.Script):
...
@@ -213,4 +216,3 @@ class Script(scripts.Script):
processed
=
processing
.
process_images
(
p
)
processed
=
processing
.
process_images
(
p
)
return
processed
return
processed
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录