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
change
sglang
Commits
0c457bae
Unverified
Commit
0c457bae
authored
Jan 24, 2024
by
isaac-vidas
Committed by
GitHub
Jan 24, 2024
Browse files
Handle grayscale images in expand2square (#97)
parent
d3fc86a4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
python/sglang/srt/mm_utils.py
python/sglang/srt/mm_utils.py
+3
-1
No files found.
python/sglang/srt/mm_utils.py
View file @
0c457bae
...
...
@@ -163,7 +163,9 @@ def expand2square(pil_img, background_color):
width
,
height
=
pil_img
.
size
if
width
==
height
:
return
pil_img
elif
width
>
height
:
if
pil_img
.
mode
==
"L"
:
pil_img
=
pil_img
.
convert
(
"RGB"
)
if
width
>
height
:
result
=
Image
.
new
(
pil_img
.
mode
,
(
width
,
width
),
background_color
)
result
.
paste
(
pil_img
,
(
0
,
(
width
-
height
)
//
2
))
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