lyimo commited on
Commit
ba641d2
Β·
1 Parent(s): 5c6c2d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -59,13 +59,16 @@ def generate_text(message, history):
59
 
60
 
61
  def predict(img):
62
- img = PILImage.create(img)
 
 
 
63
  pred,pred_idx,probs = learn.predict(img)
64
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
65
 
66
  title = "Bird Detector"
67
  description = "Bird Detector."
68
- examples = ['BIRD.png']
69
  interpretation='default'
70
  enable_queue=True
71
 
@@ -78,6 +81,4 @@ def combined(img, message):
78
  return response
79
 
80
 
81
-
82
-
83
- gr.Interface(fn=combined,inputs=Image(shape=(512, 512)),outputs=Text(),title=title,description=description,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
 
59
 
60
 
61
  def predict(img):
62
+ try:
63
+ img = PILImage.create(img)
64
+ except:
65
+ return {"bird": "Unknown"}
66
  pred,pred_idx,probs = learn.predict(img)
67
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
68
 
69
  title = "Bird Detector"
70
  description = "Bird Detector."
71
+ examples = ['BIRD.jpg']
72
  interpretation='default'
73
  enable_queue=True
74
 
 
81
  return response
82
 
83
 
84
+ gr.Interface(fn=combined,inputs=Image(shape=(512, 512)),outputs=Text(),title=title,description=description,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()