Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -26,7 +26,12 @@ def predict(img):
|
|
26 |
if isinstance(img, Image.Image):
|
27 |
img = np.array(img)
|
28 |
|
29 |
-
# If the
|
|
|
|
|
|
|
|
|
|
|
30 |
if not isinstance(img, np.ndarray):
|
31 |
raise ValueError("Input is not a valid image")
|
32 |
|
|
|
26 |
if isinstance(img, Image.Image):
|
27 |
img = np.array(img)
|
28 |
|
29 |
+
# If the image is base64, convert it to a PIL image and then to a NumPy array
|
30 |
+
elif isinstance(img, str): # base64 image
|
31 |
+
img = Image.open(io.BytesIO(base64.b64decode(img.split(',')[1])))
|
32 |
+
img = np.array(img)
|
33 |
+
|
34 |
+
# If the input is still not a NumPy array, raise an error
|
35 |
if not isinstance(img, np.ndarray):
|
36 |
raise ValueError("Input is not a valid image")
|
37 |
|