Spaces:
Sleeping
Sleeping
Download utils/image_utils.py from seed-image-ai/image_ai: direct link, hf CLI and curl.
- Browser
- Download file 435 Bytes
-
https://huggingface.co/spaces/seed-image-ai/image_ai/resolve/main/utils/image_utils.py
- Command line
-
hf download hf://spaces/seed-image-ai/image_ai/utils/image_utils.py
-
curl -L -o image_utils.py https://huggingface.co/spaces/seed-image-ai/image_ai/resolve/main/utils/image_utils.py
435 Bytes
| from PIL import ( | |
| Image, | |
| ImageOps | |
| ) | |
| def load_image( | |
| image_path | |
| ): | |
| return ( | |
| ImageOps.exif_transpose( | |
| Image.open( | |
| image_path | |
| ) | |
| ).convert("RGB") | |
| ) | |
| def is_valid_image( | |
| image_path | |
| ): | |
| try: | |
| with Image.open( | |
| image_path | |
| ) as image: | |
| image.verify() | |
| return True | |
| except Exception: | |
| return False |