Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -126,9 +126,12 @@ def load_image_from_data_url(data_url: str) -> Image.Image:
|
|
126 |
"""Load image from base64 data URL"""
|
127 |
if data_url.startswith("data:image/"):
|
128 |
# Extract base64 data after the comma
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
132 |
else:
|
133 |
# Regular URL, use existing load_img function
|
134 |
return load_img(data_url, output_type="pil")
|
|
|
126 |
"""Load image from base64 data URL"""
|
127 |
if data_url.startswith("data:image/"):
|
128 |
# Extract base64 data after the comma
|
129 |
+
if "," in data_url:
|
130 |
+
header, encoded = data_url.split(",", 1)
|
131 |
+
image_data = base64.b64decode(encoded)
|
132 |
+
return Image.open(BytesIO(image_data))
|
133 |
+
else:
|
134 |
+
raise ValueError(f"Invalid data URL format: {data_url[:50]}...")
|
135 |
else:
|
136 |
# Regular URL, use existing load_img function
|
137 |
return load_img(data_url, output_type="pil")
|