eng-himanshu commited on
Commit
c3b11dd
·
verified ·
1 Parent(s): 9bb6bfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -1,11 +1,18 @@
1
  from fastai.vision.all import *
2
  import gradio as gr
3
 
4
- # Load the model and define categories
5
  categories = ['dog', 'cat']
 
 
 
 
 
 
6
  learn = load_learner('model.pkl')
7
 
8
- def is_cat(img):
 
9
  pred, idx, probs = learn.predict(img)
10
  return {categories[i]: float(probs[i]) for i in range(len(categories))}
11
 
@@ -16,7 +23,7 @@ examples = [['dog.jpg'], ['cat.jpg']]
16
 
17
  # Create and launch the interface
18
  interface = gr.Interface(
19
- fn=is_cat,
20
  inputs=image,
21
  outputs=label,
22
  examples=examples,
 
1
  from fastai.vision.all import *
2
  import gradio as gr
3
 
4
+ # Define categories
5
  categories = ['dog', 'cat']
6
+
7
+ # Define the function that was used during training
8
+ def is_cat(x):
9
+ return x[0].isupper()
10
+
11
+ # Load the model
12
  learn = load_learner('model.pkl')
13
 
14
+ # Gradio prediction function
15
+ def predict_image(img):
16
  pred, idx, probs = learn.predict(img)
17
  return {categories[i]: float(probs[i]) for i in range(len(categories))}
18
 
 
23
 
24
  # Create and launch the interface
25
  interface = gr.Interface(
26
+ fn=predict_image,
27
  inputs=image,
28
  outputs=label,
29
  examples=examples,