AravindSL1's picture
Upload with huggingface_hub
9e463c0
raw
history blame contribute delete
630 Bytes
import gradio as gr
import tensorflow as tf
model = tf.keras.models.load_model('fire_model.h5')
def predict_input_image(img):
class_names = ['fire_images', 'non_fire_images']
img_4d = img.reshape(-1, 196, 196, 3)
prediction = model.predict(img_4d)[0]
pred = [1-prediction, prediction]
# predlab = classes[pred]
confidences = {class_names[i]: float(pred[i]) for i in range(2)}
print()
return confidences
image = gr.inputs.Image(shape=(196, 196))
label = gr.outputs.Label(num_top_classes=1)
gr.Interface(fn=predict_input_image,
inputs=image, outputs=label,interpretation='default').launch()