Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
81d1f00d
Commit
81d1f00d
authored
Apr 15, 2023
by
comfyanonymous
Browse files
Some refactoring: from_tokens -> encode_from_tokens
parent
719c26c3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
9 deletions
+9
-9
comfy/sd.py
comfy/sd.py
+5
-5
comfy/sd1_clip.py
comfy/sd1_clip.py
+3
-3
comfy/sd2_clip.py
comfy/sd2_clip.py
+1
-1
No files found.
comfy/sd.py
View file @
81d1f00d
...
@@ -375,13 +375,9 @@ class CLIP:
...
@@ -375,13 +375,9 @@ class CLIP:
def
tokenize
(
self
,
text
,
return_word_ids
=
False
):
def
tokenize
(
self
,
text
,
return_word_ids
=
False
):
return
self
.
tokenizer
.
tokenize_with_weights
(
text
,
return_word_ids
)
return
self
.
tokenizer
.
tokenize_with_weights
(
text
,
return_word_ids
)
def
encode
(
self
,
text
,
from_tokens
=
False
):
def
encode
_from_tokens
(
self
,
tokens
):
if
self
.
layer_idx
is
not
None
:
if
self
.
layer_idx
is
not
None
:
self
.
cond_stage_model
.
clip_layer
(
self
.
layer_idx
)
self
.
cond_stage_model
.
clip_layer
(
self
.
layer_idx
)
if
from_tokens
:
tokens
=
text
else
:
tokens
=
self
.
tokenizer
.
tokenize_with_weights
(
text
)
try
:
try
:
self
.
patcher
.
patch_model
()
self
.
patcher
.
patch_model
()
cond
=
self
.
cond_stage_model
.
encode_token_weights
(
tokens
)
cond
=
self
.
cond_stage_model
.
encode_token_weights
(
tokens
)
...
@@ -391,6 +387,10 @@ class CLIP:
...
@@ -391,6 +387,10 @@ class CLIP:
raise
e
raise
e
return
cond
return
cond
def
encode
(
self
,
text
):
tokens
=
self
.
tokenizer
.
tokenize_with_weights
(
text
)
return
self
.
encode_from_tokens
(
tokens
)
class
VAE
:
class
VAE
:
def
__init__
(
self
,
ckpt_path
=
None
,
scale_factor
=
0.18215
,
device
=
None
,
config
=
None
):
def
__init__
(
self
,
ckpt_path
=
None
,
scale_factor
=
0.18215
,
device
=
None
,
config
=
None
):
if
config
is
None
:
if
config
is
None
:
...
...
comfy/sd1_clip.py
View file @
81d1f00d
comfy/sd2_clip.py
View file @
81d1f00d
import
sd1_clip
from
comfy
import
sd1_clip
import
torch
import
torch
import
os
import
os
...
...
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