Spaces:
Build error
Build error
commit
Browse files
pp.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import tensorflow as tf
|
3 |
+
import numpy as np
|
4 |
+
from PIL import Image
|
5 |
+
import tensorflow.keras as keras
|
6 |
+
|
7 |
+
|
8 |
+
from tensorflow.keras.models import load_model
|
9 |
+
|
10 |
+
model=load_model("model1.h5")
|
11 |
+
|
12 |
+
classnames=["Fire","Non-Fire"]
|
13 |
+
|
14 |
+
def predict_image(img):
|
15 |
+
img_4d=img.reshape(-1,180,180,3)
|
16 |
+
prediction=model.predict(img_4d)[0]
|
17 |
+
return {classname[i]: float(prediction[i] for i in range(2))}
|
18 |
+
|
19 |
+
image=gr.inputs.Image(shape=(180,180))
|
20 |
+
label=gr.outputs.Label(num_top_classes=2)
|
21 |
+
|
22 |
+
article="<p style='text-align: center'>Made by Mahak xoxo</p>"
|
23 |
+
|
24 |
+
|
25 |
+
gr.Interface(fn=predict_image,inputs=image,title="Forest Fire Classifier",description="This is a forest fire classification model ",article=article,outputs=label,enable_queue=True,interpretation='default').launch(share=True)
|
26 |
+
|