Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
9c674080
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
10 个月 前同步成功
通知
1744
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
9c674080
编写于
11月 02, 2022
作者:
T
timntorres
提交者:
GitHub
11月 02, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow saving "before-highres-fix. (#4150)
* Save image/s before doing highres fix.
上级
4a8cf01f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
5 deletion
+18
-5
modules/processing.py
modules/processing.py
+15
-2
modules/sd_samplers.py
modules/sd_samplers.py
+2
-3
modules/shared.py
modules/shared.py
+1
-0
未找到文件。
modules/processing.py
浏览文件 @
9c674080
...
...
@@ -521,7 +521,11 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
shared
.
state
.
job
=
f
"Batch
{
n
+
1
}
out of
{
p
.
n_iter
}
"
with
devices
.
autocast
():
samples_ddim
=
p
.
sample
(
conditioning
=
c
,
unconditional_conditioning
=
uc
,
seeds
=
seeds
,
subseeds
=
subseeds
,
subseed_strength
=
p
.
subseed_strength
)
# Only Txt2Img needs an extra argument, n, when saving intermediate images pre highres fix.
if
isinstance
(
p
,
StableDiffusionProcessingTxt2Img
):
samples_ddim
=
p
.
sample
(
conditioning
=
c
,
unconditional_conditioning
=
uc
,
seeds
=
seeds
,
subseeds
=
subseeds
,
subseed_strength
=
p
.
subseed_strength
,
n
=
n
)
else
:
samples_ddim
=
p
.
sample
(
conditioning
=
c
,
unconditional_conditioning
=
uc
,
seeds
=
seeds
,
subseeds
=
subseeds
,
subseed_strength
=
p
.
subseed_strength
)
samples_ddim
=
samples_ddim
.
to
(
devices
.
dtype_vae
)
x_samples_ddim
=
decode_first_stage
(
p
.
sd_model
,
samples_ddim
)
...
...
@@ -649,7 +653,7 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
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
):
def
sample
(
self
,
conditioning
,
unconditional_conditioning
,
seeds
,
subseeds
,
subseed_strength
,
n
=
0
):
self
.
sampler
=
sd_samplers
.
create_sampler_with_index
(
sd_samplers
.
samplers
,
self
.
sampler_index
,
self
.
sd_model
)
if
not
self
.
enable_hr
:
...
...
@@ -685,6 +689,15 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
samples
=
self
.
sd_model
.
get_first_stage_encoding
(
self
.
sd_model
.
encode_first_stage
(
decoded_samples
))
# Save a copy of the image/s before doing highres fix, if applicable.
if
opts
.
save
and
not
self
.
do_not_save_samples
and
opts
.
save_images_before_highres_fix
:
for
i
in
range
(
self
.
batch_size
):
# This batch's ith image.
img
=
sd_samplers
.
sample_to_image
(
samples
,
i
)
# Index that accounts for both batch size and batch count.
ind
=
i
+
self
.
batch_size
*
n
images
.
save_image
(
img
,
self
.
outpath_samples
,
""
,
self
.
all_seeds
[
ind
],
self
.
all_prompts
[
ind
],
opts
.
samples_format
,
suffix
=
f
"-before-highres-fix"
)
shared
.
state
.
nextjob
()
self
.
sampler
=
sd_samplers
.
create_sampler_with_index
(
sd_samplers
.
samplers
,
self
.
sampler_index
,
self
.
sd_model
)
...
...
modules/sd_samplers.py
浏览文件 @
9c674080
...
...
@@ -93,9 +93,8 @@ def single_sample_to_image(sample):
return
Image
.
fromarray
(
x_sample
)
def
sample_to_image
(
samples
):
return
single_sample_to_image
(
samples
[
0
])
def
sample_to_image
(
samples
,
index
=
0
):
return
single_sample_to_image
(
samples
[
index
])
def
samples_to_image_grid
(
samples
):
return
images
.
image_grid
([
single_sample_to_image
(
sample
)
for
sample
in
samples
])
...
...
modules/shared.py
浏览文件 @
9c674080
...
...
@@ -255,6 +255,7 @@ options_templates.update(options_section(('saving-images', "Saving images/grids"
"enable_pnginfo"
:
OptionInfo
(
True
,
"Save text information about generation parameters as chunks to png files"
),
"save_txt"
:
OptionInfo
(
False
,
"Create a text file next to every image with generation parameters."
),
"save_images_before_face_restoration"
:
OptionInfo
(
False
,
"Save a copy of image before doing face restoration."
),
"save_images_before_highres_fix"
:
OptionInfo
(
False
,
"Save a copy of image before applying highres fix."
),
"jpeg_quality"
:
OptionInfo
(
80
,
"Quality for saved jpeg images"
,
gr
.
Slider
,
{
"minimum"
:
1
,
"maximum"
:
100
,
"step"
:
1
}),
"export_for_4chan"
:
OptionInfo
(
True
,
"If PNG image is larger than 4MB or any dimension is larger than 4000, downscale and save copy as JPG"
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录