Spaces:
Runtime error
Runtime error
Download app.py from Re1e9/Flower_Classification_using_InceptionV3: direct link, hf CLI and curl.
- Browser
- Download file 802 Bytes
-
https://huggingface.co/spaces/Re1e9/Flower_Classification_using_InceptionV3/resolve/a2bd6d8f66fcaaefd44de1c994485fdefaf0ac7d/app.py
- Command line
-
hf download hf://spaces/Re1e9/Flower_Classification_using_InceptionV3@a2bd6d8f66fcaaefd44de1c994485fdefaf0ac7d/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Re1e9/Flower_Classification_using_InceptionV3/resolve/a2bd6d8f66fcaaefd44de1c994485fdefaf0ac7d/app.py
802 Bytes
| import tensorflow | |
| from tensorflow import keras | |
| from keras.models import load_model | |
| model1 = load_model("inception.h5") | |
| img_width, img_height = 180, 180 | |
| class_names = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips'] | |
| num_classes = len(class_names) | |
| def predict_image(img): | |
| img_4d = img.reshape(-1, img_width, img_height, 3) # 4D coz model trained on multiple 3Ds | |
| prediction = model1.predict(img_4d)[0] | |
| return {class_names[i]: float(prediction[i]) for i in range(num_classes)} | |
| import gradio as gr | |
| image = gr.inputs.Image(shape=(img_height, img_width)) | |
| label = gr.outputs.Label(num_top_classes=num_classes) | |
| gr.Interface(fn=predict_image, inputs=image, outputs=label, title="Flower Classification using InceptionV3", interpretation='default').launch(debug='True', share='True') | |