Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
S
Stable Diffusion Webui
管理
动态
成员
代码
仓库
分支
提交
标签
仓库图
比较修订版本
部署
模型注册表
分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
Hunter0726
Stable Diffusion Webui
提交
095830e1
提交
095830e1
编辑于
2 years ago
作者:
AUTOMATIC
浏览文件
操作
下载
补丁
差异文件
Prompts from file. How to? #248
上级
482a6ce8
No related branches found
No related tags found
无相关合并请求
变更
1
隐藏空白变更内容
行内
左右并排
显示
1 个更改的文件
scripts/prompts_from_file.py
+42
-0
42 个添加, 0 个删除
scripts/prompts_from_file.py
有
42 个添加
和
0 个删除
scripts/prompts_from_file.py
0 → 100644
+
42
−
0
浏览文件 @
095830e1
import
math
import
os
import
sys
import
traceback
import
modules.scripts
as
scripts
import
gradio
as
gr
from
modules.processing
import
Processed
,
process_images
from
PIL
import
Image
from
modules.shared
import
opts
,
cmd_opts
,
state
class
Script
(
scripts
.
Script
):
def
title
(
self
):
return
"
Prompts from file
"
def
ui
(
self
,
is_img2img
):
file
=
gr
.
File
(
label
=
"
File with inputs
"
,
type
=
'
bytes
'
)
return
[
file
]
def
run
(
self
,
p
,
data
:
bytes
):
lines
=
[
x
.
strip
()
for
x
in
data
.
decode
(
'
utf8
'
,
errors
=
'
ignore
'
).
split
(
"
\n
"
)]
lines
=
[
x
for
x
in
lines
if
len
(
x
)
>
0
]
batch_count
=
math
.
ceil
(
len
(
lines
)
/
p
.
batch_size
)
print
(
f
"
Will process
{
len
(
lines
)
}
images in
{
batch_count
}
batches.
"
)
p
.
batch_count
=
1
p
.
do_not_save_grid
=
True
state
.
job_count
=
batch_count
images
=
[]
for
batch_no
in
range
(
batch_count
):
state
.
job
=
f
"
{
batch_no
}
out of
{
batch_count
}
"
p
.
prompt
=
lines
[
batch_no
*
p
.
batch_size
:(
batch_no
+
1
)
*
p
.
batch_size
]
proc
=
process_images
(
p
)
images
+=
proc
.
images
return
Processed
(
p
,
images
,
p
.
seed
,
""
)
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录