diff --git a/python/sglang/srt/mm_utils.py b/python/sglang/srt/mm_utils.py index 4fdd5eb51..d444ff0b7 100644 --- a/python/sglang/srt/mm_utils.py +++ b/python/sglang/srt/mm_utils.py @@ -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