Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,24 +2,20 @@ import gradio as gr
|
|
2 |
import tensorflow as tf
|
3 |
import numpy as np
|
4 |
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
model = tf.keras.models.load_model('bird_modelv2.h5')
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
model =
|
20 |
|
21 |
def image_classifier(inp):
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import tensorflow as tf
|
3 |
import numpy as np
|
4 |
|
5 |
+
model = tf.keras.models.load_model(r'C:\Users\thesu\anaconda3\envs\bird_modelV2.h5')
|
6 |
|
7 |
+
label = ['Asian-Green-Bee-Eater', 'Brown-Headed-Barbet', 'Cattle-Egret', 'Common-Kingfisher', 'Common-Myna', 'Common-Rosefinch', 'Common-Tailorbird', 'Coppersmith-Barbet', 'Forest-Wagtail', 'Gray-Wagtail', 'Hoopoe', 'House-Crow', 'Indian-Grey-Hornbill', 'Indian-Peacock', 'Indian-Pitta', 'Indian-Roller', 'Jungle-Babbler', 'Northern-Lapwing', 'Red-Wattled-Lapwing', 'Ruddy-Shelduck', 'Rufous-Treepie', 'Sarus-Crane', 'White-Breasted-Kingfisher', 'White-Breasted-Waterhen', 'White-Wagtail']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def image_classifier(inp):
|
10 |
+
img = tf.image.resize(inp, (224, 224))
|
11 |
+
img = tf.keras.preprocessing.image.img_to_array(img)
|
12 |
+
img = np.expand_dims(img, axis=0)
|
13 |
+
|
14 |
+
predictions = model.predict(img)[0]
|
15 |
+
|
16 |
+
return {label[i]: float(predictions[i]) for i in range(25)}
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
demo = gr.Interface(fn=image_classifier, inputs='image',outputs=gr.Label(num_top_classes=5))
|
21 |
+
demo.launch(debug=True)
|