File size: 929 Bytes
11f119a
 
7ee6e13
e098490
b76f338
 
 
11f119a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import requests
import gradio as gr
from tensorflow import keras
from keras.models import Model
from tensorflow.keras import Model



#loading the model
model1=load_model('model.h5')

#providing the labels of our dataset

labels = ['rain', 'glaze', 'rime', 'snow', 'fogsmog', 'frost', 'lightning', 'rainbow', 'hail', 'sandstorm', 'dew']
print(labels)

#function to classify the image
from gc import set_debug
def classify_image(inp):
  inp = inp.reshape((-1, 300, 300, 3))
  prediction = model1.predict(inp).flatten()
  confidences = {labels[i]: float(prediction[i]) for i in range(10)}
  print(confidences)
  return confidences
  
  
#gradio interface to check/test the classification of the images
gr.Interface(fn=classify_image, 
             inputs=gr.inputs.Image(shape=(300, 300)),
             outputs=gr.outputs.Label(num_top_classes=3),
             examples=["banana.jpg", "car.jpg"]).launch(debug=False)