File size: 931 Bytes
205ae77
d8e4c27
 
205ae77
d8e4c27
 
 
 
 
 
 
 
205ae77
 
 
 
 
 
 
03f72e6
205ae77
 
 
 
 
d8e4c27
205ae77
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
import gradio as gr
#from transformers import pipeline
from tensorflow.keras.models import load_model

#pipe = pipeline(task="image-classification", model="SuperSecureHuman/Flower-CNN")

model=load_model('./model.h5')

def predict_image(img):
    img_4d = img.reshape(-1,300,300,3)
    prediction = model.predict(img_4d)[0]
    return {class_names[i]: float(prediction[i]) for i in range(5)}

class_names = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']

image = gr.inputs.Image(shape=(300,300))

label = gr.outputs.Label(num_top_classes=5)

gr.Interface(fn=predict_image, 
                           title="Flower Classification",
                           description="Flower CNN",
                           inputs = image,
                           outputs = label,
                           live=True,
                           interpretation='default',
                           allow_flagging="never").launch()