Spaces:
Runtime error
Runtime error
Download core/preprocessing.py from sharifIslam/MV3DR: direct link, hf CLI and curl.
- Browser
- Download file 736 Bytes
-
https://huggingface.co/spaces/sharifIslam/MV3DR/resolve/main/core/preprocessing.py
- Command line
-
hf download hf://spaces/sharifIslam/MV3DR/core/preprocessing.py
-
curl -L -o preprocessing.py https://huggingface.co/spaces/sharifIslam/MV3DR/resolve/main/core/preprocessing.py
736 Bytes
| import os | |
| import tempfile | |
| from PIL import Image, ImageEnhance | |
| from typing import List | |
| from config import CONTRAST_ENHANCEMENT, SHARPNESS_ENHANCEMENT | |
| def preprocess_images(image_paths: List[str]) -> List[str]: | |
| cleaned_paths = [] | |
| for i, path in enumerate(image_paths): | |
| img = Image.open(path).convert("RGB") | |
| enhancer = ImageEnhance.Contrast(img) | |
| img = enhancer.enhance(CONTRAST_ENHANCEMENT) | |
| enhancer = ImageEnhance.Sharpness(img) | |
| img = enhancer.enhance(SHARPNESS_ENHANCEMENT) | |
| save_path = os.path.join(tempfile.gettempdir(), f"input_refined_{i}.png") | |
| img.save(save_path) | |
| cleaned_paths.append(save_path) | |
| return cleaned_paths | |