Spaces:
Configuration error
Configuration error
File size: 569 Bytes
9f26583 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import os
from typing import Tuple
from PIL import Image
def resize_image(
input_path: str,
output_path: str,
size: Tuple[int, int] = (300, 300),
) -> str:
"""
Resize grayscale image to fixed size for model input.
"""
if not os.path.isfile(input_path):
raise FileNotFoundError(f"Image not found: {input_path}")
os.makedirs(os.path.dirname(output_path), exist_ok=True)
with Image.open(input_path) as img:
img = img.convert("L")
img = img.resize(size)
img.save(output_path)
return output_path |