CoolFace
Apppublic

SuperSecureHuman/Flower-CNN

sourceHugging Facemitupdated 4y agoView on Hugging Face
0likes
app.py27 linesDownload Raw Back to root
1import gradio as gr2#from transformers import pipeline3from tensorflow.keras.models import load_model4 5#pipe = pipeline(task="image-classification", model="SuperSecureHuman/Flower-CNN")6 7model=load_model('./model.h5')8 9def predict_image(img):10    img_4d = img.reshape(-1,300,300,3)11    prediction = model.predict(img_4d)[0]12    return {class_names[i]: float(prediction[i]) for i in range(5)}13 14class_names = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']15 16image = gr.inputs.Image(shape=(300,300))17 18label = gr.outputs.Label(num_top_classes=5)19 20gr.Interface(fn=predict_image, 21                           title="Flower Classification",22                           description="Flower CNN",23                           inputs = image,24                           outputs = label,25                           live=True,26                           interpretation='default',27                           allow_flagging="never").launch()