dheerajsannidhi commited on
Commit
11f119a
1 Parent(s): 16b785a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import gradio as gr
3
+
4
+ #loading the model
5
+ model1=load_model('model.h5')
6
+
7
+ #providing the labels of our dataset
8
+
9
+ labels = ['rain', 'glaze', 'rime', 'snow', 'fogsmog', 'frost', 'lightning', 'rainbow', 'hail', 'sandstorm', 'dew']
10
+ print(labels)
11
+
12
+ #function to classify the image
13
+ from gc import set_debug
14
+ def classify_image(inp):
15
+ inp = inp.reshape((-1, 300, 300, 3))
16
+ prediction = model1.predict(inp).flatten()
17
+ confidences = {labels[i]: float(prediction[i]) for i in range(10)}
18
+ print(confidences)
19
+ return confidences
20
+
21
+
22
+ #gradio interface to check/test the classification of the images
23
+ gr.Interface(fn=classify_image,
24
+ inputs=gr.inputs.Image(shape=(300, 300)),
25
+ outputs=gr.outputs.Label(num_top_classes=3),
26
+ examples=["banana.jpg", "car.jpg"]).launch(debug=False)
27
+