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
eb4bd771
Commit
eb4bd771
authored
May 25, 2023
by
comfyanonymous
Browse files
Remove einops.
parent
87ab25fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
comfy/utils.py
comfy/utils.py
+8
-9
No files found.
comfy/utils.py
View file @
eb4bd771
import
torch
import
torch
import
math
import
math
import
einops
def
load_torch_file
(
ckpt
,
safe_load
=
False
):
def
load_torch_file
(
ckpt
,
safe_load
=
False
):
if
ckpt
.
lower
().
endswith
(
".safetensors"
):
if
ckpt
.
lower
().
endswith
(
".safetensors"
):
...
@@ -104,12 +103,12 @@ def bislerp(samples, width, height):
...
@@ -104,12 +103,12 @@ def bislerp(samples, width, height):
coords_2
=
coords_2
.
expand
((
n
,
c
,
h
,
-
1
))
coords_2
=
coords_2
.
expand
((
n
,
c
,
h
,
-
1
))
ratios
=
ratios
.
expand
((
n
,
1
,
h
,
-
1
))
ratios
=
ratios
.
expand
((
n
,
1
,
h
,
-
1
))
pass_1
=
einops
.
rearrange
(
samples
.
gather
(
-
1
,
coords_1
)
,
'n c h w -> (n h w) c'
)
pass_1
=
samples
.
gather
(
-
1
,
coords_1
)
.
movedim
(
1
,
-
1
).
reshape
((
-
1
,
c
)
)
pass_2
=
einops
.
rearrange
(
samples
.
gather
(
-
1
,
coords_2
)
,
'n c h w -> (n h w) c'
)
pass_2
=
samples
.
gather
(
-
1
,
coords_2
)
.
movedim
(
1
,
-
1
).
reshape
((
-
1
,
c
)
)
ratios
=
einops
.
rearrange
(
ratios
,
'n c h w -> (n h w) c'
)
ratios
=
ratios
.
movedim
(
1
,
-
1
).
reshape
((
-
1
,
1
)
)
result
=
slerp
(
pass_1
,
pass_2
,
ratios
)
result
=
slerp
(
pass_1
,
pass_2
,
ratios
)
result
=
einops
.
rearrange
(
result
,
'
(n h w
) c -> n c h w'
,
n
=
n
,
h
=
h
,
w
=
w_new
)
result
=
result
.
reshape
(
n
,
h
,
w
_new
,
c
).
movedim
(
-
1
,
1
)
#linear h
#linear h
ratios
,
coords_1
,
coords_2
=
generate_bilinear_data
(
h
,
h_new
)
ratios
,
coords_1
,
coords_2
=
generate_bilinear_data
(
h
,
h_new
)
...
@@ -117,12 +116,12 @@ def bislerp(samples, width, height):
...
@@ -117,12 +116,12 @@ def bislerp(samples, width, height):
coords_2
=
coords_2
.
reshape
((
1
,
1
,
-
1
,
1
)).
expand
((
n
,
c
,
-
1
,
w_new
))
coords_2
=
coords_2
.
reshape
((
1
,
1
,
-
1
,
1
)).
expand
((
n
,
c
,
-
1
,
w_new
))
ratios
=
ratios
.
reshape
((
1
,
1
,
-
1
,
1
)).
expand
((
n
,
1
,
-
1
,
w_new
))
ratios
=
ratios
.
reshape
((
1
,
1
,
-
1
,
1
)).
expand
((
n
,
1
,
-
1
,
w_new
))
pass_1
=
einops
.
rearrange
(
result
.
gather
(
-
2
,
coords_1
)
,
'n c h w -> (n h w) c'
)
pass_1
=
result
.
gather
(
-
2
,
coords_1
)
.
movedim
(
1
,
-
1
).
reshape
((
-
1
,
c
)
)
pass_2
=
einops
.
rearrange
(
result
.
gather
(
-
2
,
coords_2
)
,
'n c h w -> (n h w) c'
)
pass_2
=
result
.
gather
(
-
2
,
coords_2
)
.
movedim
(
1
,
-
1
).
reshape
((
-
1
,
c
)
)
ratios
=
einops
.
rearrange
(
ratios
,
'n c h w -> (n h w) c'
)
ratios
=
ratios
.
movedim
(
1
,
-
1
).
reshape
((
-
1
,
1
)
)
result
=
slerp
(
pass_1
,
pass_2
,
ratios
)
result
=
slerp
(
pass_1
,
pass_2
,
ratios
)
result
=
einops
.
rearrange
(
result
,
'(n h w) c -> n c h w'
,
n
=
n
,
h
=
h_new
,
w
=
w_new
)
result
=
result
.
reshape
(
n
,
h_new
,
w_new
,
c
).
movedim
(
-
1
,
1
)
return
result
return
result
def
common_upscale
(
samples
,
width
,
height
,
upscale_method
,
crop
):
def
common_upscale
(
samples
,
width
,
height
,
upscale_method
,
crop
):
...
...
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