Spaces:
Runtime error
Runtime error
import gradio as gr | |
import tensorflow as tf | |
import numpy as np | |
model = tf.keras.models.load_model('bird_modelV2.h5') | |
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'] | |
def image_classifier(inp): | |
img = tf.image.resize(inp, (224, 224)) | |
img = tf.keras.preprocessing.image.img_to_array(img) | |
img = np.expand_dims(img, axis=0) | |
predictions = model.predict(img)[0] | |
return {label[i]: float(predictions[i]) for i in range(25)} | |
demo = gr.Interface(fn=image_classifier, inputs='image',outputs=gr.Label(num_top_classes=5),title='Indian Bird Classification') | |
demo.launch(debug=True,share=True) |