martinbadrous commited on
Commit
8a2d5b7
·
1 Parent(s): d08526c

fix: add None check for image input to avoid AttributeError

Browse files
Files changed (1) hide show
  1. app.py +2 -0
app.py CHANGED
@@ -42,6 +42,8 @@ load_model()
42
  def predict(image):
43
  if model is None:
44
  return "⚠️ Model could not be loaded.", {}
 
 
45
 
46
  image = image.convert("L").resize((48, 48))
47
  arr = np.array(image, dtype=np.float32) / 255.0
 
42
  def predict(image):
43
  if model is None:
44
  return "⚠️ Model could not be loaded.", {}
45
+ if image is None:
46
+ return "⚠️ Please upload an image first.", {}
47
 
48
  image = image.convert("L").resize((48, 48))
49
  arr = np.array(image, dtype=np.float32) / 255.0