Spaces:
Runtime error
Runtime error
Mr-Vicky-01
commited on
Update app.py
Browse files
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
|
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 |
-
|
16 |
|
17 |
-
return {
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
demo = gr.Interface(fn=
|
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)
|