Spaces:
Running
on
Zero
Running
on
Zero
Add try_open_image
Browse files- modules/image_utils.py +7 -0
modules/image_utils.py
CHANGED
@@ -70,6 +70,13 @@ def get_image_from_dict(image_path):
|
|
70 |
else:
|
71 |
return image_path, False
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
def open_image(image_path):
|
74 |
"""
|
75 |
Opens an image from a file path or URL, or decodes a DataURL string into an image.
|
|
|
70 |
else:
|
71 |
return image_path, False
|
72 |
|
73 |
+
def try_open_image(image_path):
|
74 |
+
try:
|
75 |
+
return open_image(image_path)
|
76 |
+
except Exception as e:
|
77 |
+
print(f"Skipping image {image_path} due to error: {e}")
|
78 |
+
return None
|
79 |
+
|
80 |
def open_image(image_path):
|
81 |
"""
|
82 |
Opens an image from a file path or URL, or decodes a DataURL string into an image.
|