cisemh commited on
Commit
80396b1
·
verified ·
1 Parent(s): 2d99dd4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
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 input is still not a NumPy array, return an error
 
 
 
 
 
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