MCPcopy
hub / github.com/XPixelGroup/DiffBIR / expand2square

Function expand2square

llava/mm_utils.py:152–163  ·  view source on GitHub ↗
(pil_img, background_color)

Source from the content-addressed store, hash-verified

150
151
152def expand2square(pil_img, background_color):
153 width, height = pil_img.size
154 if width == height:
155 return pil_img
156 elif width > height:
157 result = Image.new(pil_img.mode, (width, width), background_color)
158 result.paste(pil_img, (0, (width - height) // 2))
159 return result
160 else:
161 result = Image.new(pil_img.mode, (height, height), background_color)
162 result.paste(pil_img, ((height - width) // 2, 0))
163 return result
164
165
166def process_images(images, image_processor, model_cfg):

Callers 3

process_imageMethod · 0.85
process_imagesFunction · 0.85
__getitem__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected