dheerajsannidhi/PythonProject
0
1import requests2import gradio as gr3from tensorflow import keras4from keras.models import Model5from tensorflow.keras import Model6 7 8 9#loading the model10model1=load_model('model.h5')11 12#providing the labels of our dataset13 14labels = ['rain', 'glaze', 'rime', 'snow', 'fogsmog', 'frost', 'lightning', 'rainbow', 'hail', 'sandstorm', 'dew']15print(labels)16 17#function to classify the image18from gc import set_debug19def classify_image(inp):20 inp = inp.reshape((-1, 300, 300, 3))21 prediction = model1.predict(inp).flatten()22 confidences = {labels[i]: float(prediction[i]) for i in range(10)}23 print(confidences)24 return confidences25 26 27#gradio interface to check/test the classification of the images28gr.Interface(fn=classify_image, 29 inputs=gr.inputs.Image(shape=(300, 300)),30 outputs=gr.outputs.Label(num_top_classes=3),31 examples=["banana.jpg", "car.jpg"]).launch(debug=False)32 33 