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
e45d920a
"...ldm/git@developer.sourcefind.cn:chenpangpang/ComfyUI.git" did not exist on "1daccf3678ceca503d3ddae178f2e06e2e927754"
Commit
e45d920a
authored
Dec 16, 2023
by
comfyanonymous
Browse files
Don't resize clip vision image when the size is already good.
parent
13e6d536
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
comfy/clip_vision.py
comfy/clip_vision.py
+7
-5
No files found.
comfy/clip_vision.py
View file @
e45d920a
...
...
@@ -19,11 +19,13 @@ class Output:
def
clip_preprocess
(
image
,
size
=
224
):
mean
=
torch
.
tensor
([
0.48145466
,
0.4578275
,
0.40821073
],
device
=
image
.
device
,
dtype
=
image
.
dtype
)
std
=
torch
.
tensor
([
0.26862954
,
0.26130258
,
0.27577711
],
device
=
image
.
device
,
dtype
=
image
.
dtype
)
scale
=
(
size
/
min
(
image
.
shape
[
1
],
image
.
shape
[
2
]))
image
=
torch
.
nn
.
functional
.
interpolate
(
image
.
movedim
(
-
1
,
1
),
size
=
(
round
(
scale
*
image
.
shape
[
1
]),
round
(
scale
*
image
.
shape
[
2
])),
mode
=
"bicubic"
,
antialias
=
True
)
h
=
(
image
.
shape
[
2
]
-
size
)
//
2
w
=
(
image
.
shape
[
3
]
-
size
)
//
2
image
=
image
[:,:,
h
:
h
+
size
,
w
:
w
+
size
]
image
=
image
.
movedim
(
-
1
,
1
)
if
not
(
image
.
shape
[
2
]
==
size
and
image
.
shape
[
3
]
==
size
):
scale
=
(
size
/
min
(
image
.
shape
[
2
],
image
.
shape
[
3
]))
image
=
torch
.
nn
.
functional
.
interpolate
(
image
,
size
=
(
round
(
scale
*
image
.
shape
[
2
]),
round
(
scale
*
image
.
shape
[
3
])),
mode
=
"bicubic"
,
antialias
=
True
)
h
=
(
image
.
shape
[
2
]
-
size
)
//
2
w
=
(
image
.
shape
[
3
]
-
size
)
//
2
image
=
image
[:,:,
h
:
h
+
size
,
w
:
w
+
size
]
image
=
torch
.
clip
((
255.
*
image
),
0
,
255
).
round
()
/
255.0
return
(
image
-
mean
.
view
([
3
,
1
,
1
]))
/
std
.
view
([
3
,
1
,
1
])
...
...
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