Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
8e2aeee4
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
11 个月 前同步成功
通知
1768
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
8e2aeee4
编写于
1月 15, 2023
作者:
A
AUTOMATIC
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add BREAK keyword to end current text chunk and start the next
上级
205991df
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
5 deletion
+19
-5
modules/prompt_parser.py
modules/prompt_parser.py
+6
-1
modules/sd_hijack_clip.py
modules/sd_hijack_clip.py
+13
-4
未找到文件。
modules/prompt_parser.py
浏览文件 @
8e2aeee4
...
...
@@ -274,6 +274,7 @@ re_attention = re.compile(r"""
:
"""
,
re
.
X
)
re_break
=
re
.
compile
(
r
"\s*\bBREAK\b\s*"
,
re
.
S
)
def
parse_prompt_attention
(
text
):
"""
...
...
@@ -339,7 +340,11 @@ def parse_prompt_attention(text):
elif
text
==
']'
and
len
(
square_brackets
)
>
0
:
multiply_range
(
square_brackets
.
pop
(),
square_bracket_multiplier
)
else
:
res
.
append
([
text
,
1.0
])
parts
=
re
.
split
(
re_break
,
text
)
for
i
,
part
in
enumerate
(
parts
):
if
i
>
0
:
res
.
append
([
"BREAK"
,
-
1
])
res
.
append
([
part
,
1.0
])
for
pos
in
round_brackets
:
multiply_range
(
pos
,
round_bracket_multiplier
)
...
...
modules/sd_hijack_clip.py
浏览文件 @
8e2aeee4
...
...
@@ -96,13 +96,18 @@ class FrozenCLIPEmbedderWithCustomWordsBase(torch.nn.Module):
token_count
=
0
last_comma
=
-
1
def
next_chunk
():
"""puts current chunk into the list of results and produces the next one - empty"""
def
next_chunk
(
is_last
=
False
):
"""puts current chunk into the list of results and produces the next one - empty;
if is_last is true, tokens <end-of-text> tokens at the end won't add to token_count"""
nonlocal
token_count
nonlocal
last_comma
nonlocal
chunk
token_count
+=
len
(
chunk
.
tokens
)
if
is_last
:
token_count
+=
len
(
chunk
.
tokens
)
else
:
token_count
+=
self
.
chunk_length
to_add
=
self
.
chunk_length
-
len
(
chunk
.
tokens
)
if
to_add
>
0
:
chunk
.
tokens
+=
[
self
.
id_end
]
*
to_add
...
...
@@ -116,6 +121,10 @@ class FrozenCLIPEmbedderWithCustomWordsBase(torch.nn.Module):
chunk
=
PromptChunk
()
for
tokens
,
(
text
,
weight
)
in
zip
(
tokenized
,
parsed
):
if
text
==
'BREAK'
and
weight
==
-
1
:
next_chunk
()
continue
position
=
0
while
position
<
len
(
tokens
):
token
=
tokens
[
position
]
...
...
@@ -159,7 +168,7 @@ class FrozenCLIPEmbedderWithCustomWordsBase(torch.nn.Module):
position
+=
embedding_length_in_tokens
if
len
(
chunk
.
tokens
)
>
0
or
len
(
chunks
)
==
0
:
next_chunk
()
next_chunk
(
is_last
=
True
)
return
chunks
,
token_count
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录