Frantz103 commited on
Commit
4db19d8
1 Parent(s): 0d1ddc6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -11,7 +11,12 @@ labels = ['Dog', 'Cat']
11
  def predict(img):
12
  img = PILImage.create(img)
13
  pred, pred_idx, probs = learn_inf.predict(img)
14
- return {labels[i]: float(probs[i]) for i in range(len(labels))}
 
 
 
 
 
15
 
16
  title = "Is this image of a cat?"
17
  iface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512,512)), outputs=gr.outputs.Label(num_top_classes=2), title=title)
 
11
  def predict(img):
12
  img = PILImage.create(img)
13
  pred, pred_idx, probs = learn_inf.predict(img)
14
+
15
+ # Check if the prediction is "Cat" and return the appropriate string
16
+ if pred == 'Cat':
17
+ return "This is a cat"
18
+ else:
19
+ return "This is not a cat"
20
 
21
  title = "Is this image of a cat?"
22
  iface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512,512)), outputs=gr.outputs.Label(num_top_classes=2), title=title)