File size: 698 Bytes
aced369
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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', 
             title = 'Flower Recognition App', 
             description= 'Get probability for input image among 5 classes')
iface.launch()