|
import gradio as gr |
|
from keras.models import load_model,Sequential |
|
model = load_model("./Model_2.h5") |
|
class_names = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips'] |
|
|
|
def predict_image(img): |
|
img_4d=img.reshape(-1,331,331,3) |
|
prediction=model.predict(img_4d)[0] |
|
return {class_names[i]: float(prediction[i]) for i in range(5)} |
|
|
|
image = gr.inputs.Image(shape=(331,331)) |
|
label = gr.outputs.Label(num_top_classes=5) |
|
iface = gr.Interface(fn=predict_image, |
|
inputs=image, |
|
outputs=label, |
|
interpretation='default', |
|
examples=['2480569557_f4e1f0dcb8_n.jpg','3464015936_6845f46f64.jpg','4746668678_0e2693b1b9_n.jpg','4764674741_82b8f93359_n.jpg','5470898169_52a5ab876c_n.jpg'], |
|
title = 'Flower Recognition App', |
|
description= 'Get probability for input image among daisy, dandelion, roses, sunflowers, tulips') |
|
iface.launch() |