Mr-Vicky-01 commited on
Commit
977eabe
1 Parent(s): 8ff9d76

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -7,16 +7,14 @@ labels = ['american_football', 'baseball', 'basketball', 'billiard_ball', 'bowli
7
  'football', 'golf_ball', 'hockey_ball', 'hockey_puck', 'rugby_ball', 'shuttlecock',
8
  'table_tennis_ball', 'tennis_ball', 'volleyball']
9
 
10
- def image_classifier(inp):
11
  img = tf.image.resize(inp, (224, 224))
12
  img = tf.keras.preprocessing.image.img_to_array(img)
13
  img = np.expand_dims(img, axis=0)
14
 
15
- predictions = model.predict(img)[0]
16
 
17
- return {label[i]: float(predictions[i]) for i in range(25)}
18
-
19
-
20
 
21
- demo = gr.Interface(fn=image_classifier, inputs='image',outputs=gr.Label(num_top_classes=5),title='Indian Bird Classification')
22
  demo.launch(debug=True,share=True)
 
7
  'football', 'golf_ball', 'hockey_ball', 'hockey_puck', 'rugby_ball', 'shuttlecock',
8
  'table_tennis_ball', 'tennis_ball', 'volleyball']
9
 
10
+ def predict_image(inp):
11
  img = tf.image.resize(inp, (224, 224))
12
  img = tf.keras.preprocessing.image.img_to_array(img)
13
  img = np.expand_dims(img, axis=0)
14
 
15
+ prediction = model.predict(img)[0]
16
 
17
+ return {labels[i]: float(prediction[i]) for i in range(len(labels))}
 
 
18
 
19
+ demo = gr.Interface(fn=predict_image, inputs='image',outputs=gr.Label(num_top_classes=3),title='Sports Ball Classification')
20
  demo.launch(debug=True,share=True)