thebestteamever commited on
Commit
6e34432
1 Parent(s): 2928fe1

Add application file

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from tensorflow import keras
3
+ import tensorflow as tf
4
+
5
+ model = tf.keras.models.load_model("thebestteamever/fire_detection_project/model.h5")
6
+
7
+ #return a dictionary of labels and probabilities
8
+ def fire_or_non_fire(img):
9
+ img = img.reshape((-1 ,105, 165, 3))
10
+ #img = np.array(img)
11
+ prediction = model.predict(img).tolist()[0]
12
+ labels = ["Fire", "Non Fire"]
13
+ return {labels[i]: prediction[i] for i in range(2)}
14
+
15
+ im = gr.inputs.Image(shape=(105, 165), source="upload")
16
+ iface = gr.Interface(
17
+ fn = fire_or_non_fire,
18
+ inputs = im,
19
+ outputs = gr.outputs.Label(),
20
+ )
21
+
22
+ iface.launch(share=True, debug=False)