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
851bb87c
Commit
851bb87c
authored
Oct 10, 2023
by
comfyanonymous
Browse files
Merge branch 'taesd_safetensors' of
https://github.com/mochiya98/ComfyUI
parents
be903eb2
9eb621c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
comfy/latent_formats.py
comfy/latent_formats.py
+2
-2
comfy/taesd/taesd.py
comfy/taesd/taesd.py
+10
-2
latent_preview.py
latent_preview.py
+6
-1
No files found.
comfy/latent_formats.py
View file @
851bb87c
...
@@ -20,7 +20,7 @@ class SD15(LatentFormat):
...
@@ -20,7 +20,7 @@ class SD15(LatentFormat):
[
-
0.2829
,
0.1762
,
0.2721
],
[
-
0.2829
,
0.1762
,
0.2721
],
[
-
0.2120
,
-
0.2616
,
-
0.7177
]
[
-
0.2120
,
-
0.2616
,
-
0.7177
]
]
]
self
.
taesd_decoder_name
=
"taesd_decoder
.pth
"
self
.
taesd_decoder_name
=
"taesd_decoder"
class
SDXL
(
LatentFormat
):
class
SDXL
(
LatentFormat
):
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -32,4 +32,4 @@ class SDXL(LatentFormat):
...
@@ -32,4 +32,4 @@ class SDXL(LatentFormat):
[
0.0568
,
0.1687
,
-
0.0755
],
[
0.0568
,
0.1687
,
-
0.0755
],
[
-
0.3112
,
-
0.2359
,
-
0.2076
]
[
-
0.3112
,
-
0.2359
,
-
0.2076
]
]
]
self
.
taesd_decoder_name
=
"taesdxl_decoder
.pth
"
self
.
taesd_decoder_name
=
"taesdxl_decoder"
comfy/taesd/taesd.py
View file @
851bb87c
...
@@ -50,9 +50,17 @@ class TAESD(nn.Module):
...
@@ -50,9 +50,17 @@ class TAESD(nn.Module):
self
.
encoder
=
Encoder
()
self
.
encoder
=
Encoder
()
self
.
decoder
=
Decoder
()
self
.
decoder
=
Decoder
()
if
encoder_path
is
not
None
:
if
encoder_path
is
not
None
:
self
.
encoder
.
load_state_dict
(
torch
.
load
(
encoder_path
,
map_location
=
"cpu"
,
weights_only
=
True
))
if
encoder_path
.
lower
().
endswith
(
".safetensors"
):
import
safetensors.torch
self
.
encoder
.
load_state_dict
(
safetensors
.
torch
.
load_file
(
encoder_path
,
device
=
"cpu"
))
else
:
self
.
encoder
.
load_state_dict
(
torch
.
load
(
encoder_path
,
map_location
=
"cpu"
,
weights_only
=
True
))
if
decoder_path
is
not
None
:
if
decoder_path
is
not
None
:
self
.
decoder
.
load_state_dict
(
torch
.
load
(
decoder_path
,
map_location
=
"cpu"
,
weights_only
=
True
))
if
decoder_path
.
lower
().
endswith
(
".safetensors"
):
import
safetensors.torch
self
.
decoder
.
load_state_dict
(
safetensors
.
torch
.
load_file
(
decoder_path
,
device
=
"cpu"
))
else
:
self
.
decoder
.
load_state_dict
(
torch
.
load
(
decoder_path
,
map_location
=
"cpu"
,
weights_only
=
True
))
@
staticmethod
@
staticmethod
def
scale_latents
(
x
):
def
scale_latents
(
x
):
...
...
latent_preview.py
View file @
851bb87c
...
@@ -56,7 +56,12 @@ def get_previewer(device, latent_format):
...
@@ -56,7 +56,12 @@ def get_previewer(device, latent_format):
# TODO previewer methods
# TODO previewer methods
taesd_decoder_path
=
None
taesd_decoder_path
=
None
if
latent_format
.
taesd_decoder_name
is
not
None
:
if
latent_format
.
taesd_decoder_name
is
not
None
:
taesd_decoder_path
=
folder_paths
.
get_full_path
(
"vae_approx"
,
latent_format
.
taesd_decoder_name
)
taesd_decoder_path
=
next
(
(
fn
for
fn
in
folder_paths
.
get_filename_list
(
"vae_approx"
)
if
fn
.
startswith
(
latent_format
.
taesd_decoder_name
)),
""
)
taesd_decoder_path
=
folder_paths
.
get_full_path
(
"vae_approx"
,
taesd_decoder_path
)
if
method
==
LatentPreviewMethod
.
Auto
:
if
method
==
LatentPreviewMethod
.
Auto
:
method
=
LatentPreviewMethod
.
Latent2RGB
method
=
LatentPreviewMethod
.
Latent2RGB
...
...
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