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
7c9a92f5
Commit
7c9a92f5
authored
Sep 19, 2023
by
comfyanonymous
Browse files
Don't depend on torchvision.
parent
2b6b1781
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
comfy/utils.py
comfy/utils.py
+3
-3
No files found.
comfy/utils.py
View file @
7c9a92f5
import
torch
import
torchvision
import
math
import
struct
import
comfy.checkpoint_pickle
import
safetensors.torch
import
numpy
as
np
from
PIL
import
Image
def
load_torch_file
(
ckpt
,
safe_load
=
False
,
device
=
None
):
...
...
@@ -349,9 +349,9 @@ def bislerp(samples, width, height):
return
result
def
lanczos
(
samples
,
width
,
height
):
images
=
[
torchvision
.
transforms
.
functional
.
to_pil_image
(
image
)
for
image
in
samples
]
images
=
[
Image
.
fromarray
(
np
.
clip
(
255.
*
image
.
movedim
(
0
,
-
1
).
cpu
().
numpy
(),
0
,
255
).
astype
(
np
.
uint8
)
)
for
image
in
samples
]
images
=
[
image
.
resize
((
width
,
height
),
resample
=
Image
.
Resampling
.
LANCZOS
)
for
image
in
images
]
images
=
[
torch
vision
.
transforms
.
functional
.
to_tensor
(
image
)
for
image
in
images
]
images
=
[
torch
.
from_numpy
(
np
.
array
(
image
).
astype
(
np
.
float32
)
/
255.0
).
movedim
(
-
1
,
0
)
for
image
in
images
]
result
=
torch
.
stack
(
images
)
return
result
...
...
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