Team Ai
Apppublic

sabre-code/Flower-Classification

sourceHugging Faceupdated 4y agoView on Hugging Face
2likes
app.py26 linesDownload Raw Back to root
1import os2os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'3import tensorflow as tf4from tensorflow.keras.models import load_model5model = load_model('myModel.hdf5')6 7import gradio as gr8from gradio import inputs9 10class_names = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']11 12def classify(img):13  img_array = tf.keras.utils.img_to_array(img)14  img_array = tf.expand_dims(img_array, 0) # Create a batch15  predictions = model.predict(img_array)16  score = tf.nn.softmax(predictions[0])17  confidences = {class_names[i]: float(score[i]) for i in range(5)}18  return confidences19  20 21 22gr.Interface(title="Flower Classification App [Sunflower, Rose, Daisy, Dandelion, Tulips]",23             fn=classify,24             inputs=gr.Image(shape=(180, 180)),25             outputs=gr.Label(num_top_classes=5),examples=["Dandelion.jpg", "rose.jpeg","sunflower.jpg", "tulips.jpeg"]).launch(debug=True)26