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
xuwx1
LightX2V
Commits
0f408885
Commit
0f408885
authored
Jul 14, 2025
by
PengGao
Committed by
GitHub
Jul 14, 2025
Browse files
Refactor cpu_offload checks to ensure attribute existence before accessing (#115)
parent
f893a269
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
lightx2v/models/input_encoders/hf/xlm_roberta/model.py
lightx2v/models/input_encoders/hf/xlm_roberta/model.py
+2
-2
lightx2v/models/video_encoders/hf/wan/vae.py
lightx2v/models/video_encoders/hf/wan/vae.py
+2
-2
No files found.
lightx2v/models/input_encoders/hf/xlm_roberta/model.py
View file @
0f408885
...
@@ -434,7 +434,7 @@ class CLIPModel:
...
@@ -434,7 +434,7 @@ class CLIPModel:
logger
.
info
(
f
"End Loading weights from
{
self
.
checkpoint_path
}
"
)
logger
.
info
(
f
"End Loading weights from
{
self
.
checkpoint_path
}
"
)
def
visual
(
self
,
videos
,
args
):
def
visual
(
self
,
videos
,
args
):
if
args
.
cpu_offload
:
if
hasattr
(
args
,
"cpu_offload"
)
and
args
.
cpu_offload
:
self
.
to_cuda
()
self
.
to_cuda
()
# preprocess
# preprocess
size
=
(
self
.
model
.
image_size
,)
*
2
size
=
(
self
.
model
.
image_size
,)
*
2
...
@@ -445,7 +445,7 @@ class CLIPModel:
...
@@ -445,7 +445,7 @@ class CLIPModel:
with
torch
.
amp
.
autocast
(
"cuda"
,
dtype
=
self
.
dtype
):
with
torch
.
amp
.
autocast
(
"cuda"
,
dtype
=
self
.
dtype
):
out
=
self
.
model
.
visual
(
videos
,
use_31_block
=
True
)
out
=
self
.
model
.
visual
(
videos
,
use_31_block
=
True
)
if
args
.
cpu_offload
:
if
hasattr
(
args
,
"cpu_offload"
)
and
args
.
cpu_offload
:
self
.
to_cpu
()
self
.
to_cpu
()
return
out
return
out
...
...
lightx2v/models/video_encoders/hf/wan/vae.py
View file @
0f408885
...
@@ -868,7 +868,7 @@ class WanVAE:
...
@@ -868,7 +868,7 @@ class WanVAE:
"""
"""
videos: A list of videos each with shape [C, T, H, W].
videos: A list of videos each with shape [C, T, H, W].
"""
"""
if
args
.
cpu_offload
:
if
hasattr
(
args
,
"cpu_offload"
)
and
args
.
cpu_offload
:
self
.
to_cuda
()
self
.
to_cuda
()
if
self
.
use_tiling
:
if
self
.
use_tiling
:
...
@@ -876,7 +876,7 @@ class WanVAE:
...
@@ -876,7 +876,7 @@ class WanVAE:
else
:
else
:
out
=
[
self
.
model
.
encode
(
u
.
unsqueeze
(
0
),
self
.
scale
).
float
().
squeeze
(
0
)
for
u
in
videos
]
out
=
[
self
.
model
.
encode
(
u
.
unsqueeze
(
0
),
self
.
scale
).
float
().
squeeze
(
0
)
for
u
in
videos
]
if
args
.
cpu_offload
:
if
hasattr
(
args
,
"cpu_offload"
)
and
args
.
cpu_offload
:
self
.
to_cpu
()
self
.
to_cpu
()
return
out
return
out
...
...
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