Spaces:
Runtime error
Runtime error
AravindSL1
commited on
Commit
•
9e463c0
1
Parent(s):
c22b183
Upload with huggingface_hub
Browse files- app.py +24 -0
- fire_model.h5 +3 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
|
4 |
+
|
5 |
+
model = tf.keras.models.load_model('fire_model.h5')
|
6 |
+
|
7 |
+
def predict_input_image(img):
|
8 |
+
class_names = ['fire_images', 'non_fire_images']
|
9 |
+
img_4d = img.reshape(-1, 196, 196, 3)
|
10 |
+
prediction = model.predict(img_4d)[0]
|
11 |
+
pred = [1-prediction, prediction]
|
12 |
+
# predlab = classes[pred]
|
13 |
+
|
14 |
+
confidences = {class_names[i]: float(pred[i]) for i in range(2)}
|
15 |
+
print()
|
16 |
+
return confidences
|
17 |
+
|
18 |
+
|
19 |
+
image = gr.inputs.Image(shape=(196, 196))
|
20 |
+
label = gr.outputs.Label(num_top_classes=1)
|
21 |
+
|
22 |
+
|
23 |
+
gr.Interface(fn=predict_input_image,
|
24 |
+
inputs=image, outputs=label,interpretation='default').launch()
|
fire_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bc0e885b634d6ecfbc0caf1c55dd2bff4ee8a81ff1af2d4fd85adcb27c543a8b
|
3 |
+
size 5423712
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio==3.27.0
|
2 |
+
tensorflow==2.10.0
|