Final Project
Browse files- app.py +19 -5
- inception.h5 +3 -0
app.py
CHANGED
@@ -1,7 +1,21 @@
|
|
1 |
-
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
iface.launch()
|
|
|
|
|
1 |
|
2 |
+
import tensorflow
|
3 |
+
from tensorflow import keras
|
4 |
+
from keras.models import load_model
|
5 |
+
model1 = load_model("inception.h5")
|
6 |
+
|
7 |
+
img_width, img_height = 180, 180
|
8 |
+
class_names = ['daisy', 'dandelion', 'roses', 'sunflowers', 'tulips']
|
9 |
+
num_classes = len(class_names)
|
10 |
+
|
11 |
+
def predict_image(img):
|
12 |
+
img_4d = img.reshape(-1, img_width, img_height, 3) # 4D coz model trained on multiple 3Ds
|
13 |
+
prediction = model1.predict(img_4d)[0]
|
14 |
+
return {class_names[i]: float(prediction[i]) for i in range(num_classes)}
|
15 |
+
|
16 |
+
|
17 |
+
import gradio as gr
|
18 |
+
image = gr.inputs.Image(shape=(img_height, img_width))
|
19 |
+
label = gr.outputs.Label(num_top_classes=num_classes)
|
20 |
|
21 |
+
gr.Interface(fn=predict_image, inputs=image, outputs=label, title="Flower Classification using InceptionV3", interpretation='default').launch(debug='True', share='True')
|
|
inception.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d75cab7598d7b20a3c1e8c2a53b5b87dd60fc71c2ebbdb7f8fda7767ac46981e
|
3 |
+
size 94556992
|