Spaces:
No application file
No application file
File size: 1,180 Bytes
7f73507 36bcbd2 a2bd9bf c0ae9a1 48bbe67 a2bd9bf cedcda9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import tensorflow
from tensorflow import keras
from keras.models import load_model
model1 = load_model("inception.h5")
img_width, img_height = 180, 180
class_names = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']
num_classes = len(class_names)
def predict_image(img):
img_4d = img.reshape(-1, img_width, img_height, 3) # 4D coz model trained on multiple 3Ds
prediction = model1.predict(img_4d)[0]
return {class_names[i]: float(prediction[i]) for i in range(num_classes)}
import gradio as gr
image = gr.inputs.Image(shape=(img_height, img_width))
label = gr.outputs.Label(num_top_classes=num_classes)
examples = [
["NAME: OLUMIDE TOLULOPE SAMUEL,"],
["MATRIC NO: HNDCOM/22/037"],
["CLASS: HND1"],
["LEVEL: 300L"],
["DEPARTMENT: COMPUTER SCIENCE"],
],
gr.Interface(fn=predict_image, inputs=image, outputs=label,
title="Flower Classification using InceptionV3",
description="A flower classification app built using python and deployed using gradio",
examples=examples,
interpretation='default').launch()
|