wizzseen commited on
Commit
d242d54
1 Parent(s): 6371512

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -9
app.py CHANGED
@@ -12,14 +12,8 @@ import numpy as np
12
  # Load the trained model
13
  model = load_model('cat_classifier_model.h5')
14
 
15
- # Function to predict whether an image contains a cat
16
- def predict_cat(image_content):
17
- # Convert image content to PIL Image
18
- img = Image.open(BytesIO(image_content))
19
- img = img.convert('RGB')
20
- img = img.resize((224, 224))
21
-
22
- img_array = np.array(img)
23
  img_array = np.expand_dims(img_array, axis=0)
24
  img_array = img_array / 255.0 # Rescale to values between 0 and 1 (same as during training)
25
 
@@ -32,7 +26,7 @@ def predict_cat(image_content):
32
  # Create a Gradio interface
33
  iface = gr.Interface(
34
  fn=predict_cat,
35
- inputs=gr.Image(type='file', label='Upload an image of a tablet'),
36
  outputs='text'
37
  )
38
 
 
12
  # Load the trained model
13
  model = load_model('cat_classifier_model.h5')
14
 
15
+ def predict_cat(image_pil):
16
+ img_array = np.array(image_pil)
 
 
 
 
 
 
17
  img_array = np.expand_dims(img_array, axis=0)
18
  img_array = img_array / 255.0 # Rescale to values between 0 and 1 (same as during training)
19
 
 
26
  # Create a Gradio interface
27
  iface = gr.Interface(
28
  fn=predict_cat,
29
+ inputs=gr.Image(type='pil', label='Upload an image of a tablet'),
30
  outputs='text'
31
  )
32