(pil_img, background_color)
| 150 | |
| 151 | |
| 152 | def 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 | |
| 166 | def process_images(images, image_processor, model_cfg): |
no outgoing calls
no test coverage detected