CoolFace
Apppublic

Re1e9/Flower_Classification_using_InceptionV3

sourceHugging Faceupdated 4y agoView on Hugging Face
3likes
app.py22 linesDownload Raw Back to root
1 2import tensorflow3from tensorflow import keras4from keras.models import load_model5model1 = load_model("inception.h5")6 7img_width, img_height = 180, 1808class_names = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']9num_classes = len(class_names)10 11def predict_image(img):12    img_4d = img.reshape(-1, img_width, img_height, 3)      # 4D coz model trained on multiple 3Ds13    prediction = model1.predict(img_4d)[0]14    return {class_names[i]: float(prediction[i]) for i in range(num_classes)}15 16 17import gradio as gr18image = gr.inputs.Image(shape=(img_height, img_width))19label = gr.outputs.Label(num_top_classes=num_classes)20 21gr.Interface(fn=predict_image, inputs=image, outputs=label, title="Flower Classification using InceptionV3", interpretation='default').launch()22