miracle01's picture
Update app.py
9321751 verified
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)
texts = ["Hey Tolulope, the model predicted: "]
prediction = model1.predict(img_4d)[0]
return {texts[0] + 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)
details = [
["NAME: OLUMIDE TOLULOPE SAMUEL,"],
["MATRIC NO: HNDCOM/22/037"],
["CLASS: HND2"],
["LEVEL: 400L"],
["DEPARTMENT: COMPUTER SCIENCE"],
]
article = """<b>NAME: OLUMIDE TOLULOPE SAMUEL</b> </br>
<b>MATRIC NO: HNDCOM/22/037</b> </br>
<b>CLASS: HND2</b> </br>
<b>LEVEL: 400L</b> </br>
<b>DEPARTMENT: COMPUTER SCIENCE</b>
`To get samples of images to test this project;`
check for available images here @
`1. - "https://www.kaggle.com/datasets/kausthubkannan/5-flower-types-classification-dataset"
`2. - "https://public.roboflow.com/classification/flowers"
"""
gr.Interface(fn=predict_image, inputs=image, outputs=label,
title="A Flower Classification Project using python ",
description="A flower classification app built using python and deployed using gradio",
article=article,
interpretation='default').launch()