File size: 630 Bytes
9e463c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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()