miracle01 commited on
Commit
4388482
1 Parent(s): 69625cd

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)
13
+ texts = ["Hey Tolulope, the model predicted: "]
14
+ prediction = model1.predict(img_4d)[0]
15
+ return {texts[0] + class_names[i]: float(prediction[i]) for i in range(num_classes)}
16
+
17
+
18
+ import gradio as gr
19
+ image = gr.inputs.Image(shape=(img_height, img_width))
20
+ label = gr.outputs.Label(num_top_classes=num_classes)
21
+ details = [
22
+ ["NAME: OLUMIDE TOLULOPE SAMUEL,"],
23
+ ["MATRIC NO: HNDCOM/22/037"],
24
+ ["CLASS: HND2"],
25
+ ["LEVEL: 400L"],
26
+ ["DEPARTMENT: COMPUTER SCIENCE"],
27
+ ]
28
+
29
+ article = """<b>NAME: OLUMIDE TOLULOPE SAMUEL</b> </br>
30
+ <b>MATRIC NO: HNDCOM/22/037</b> </br>
31
+ <b>CLASS: HND2</b> </br>
32
+ <b>LEVEL: 400L</b> </br>
33
+ <b>DEPARTMENT: COMPUTER SCIENCE</b>
34
+
35
+ `To run this program locally, follow these steps;`
36
+ """
37
+
38
+
39
+ gr.Interface(fn=predict_image, inputs=image, outputs=label,
40
+ title="A Flower Classification Project using python ",
41
+ description="A flower classification app built using python and deployed using gradio",
42
+ article=article,
43
+ interpretation='default').launch()