Spaces:
Sleeping
Sleeping
David Sosa
commited on
Commit
•
bfc8bab
1
Parent(s):
d5c45f6
Added models and images
Browse files- app.py +25 -4
- bonfire.jpg +0 -0
- fire_indoor.png +0 -0
- fireplace.jpg +0 -0
- lithium.jpg +0 -0
- model.pkl +3 -0
- wildfire.jpg +0 -0
app.py
CHANGED
@@ -1,9 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
|
5 |
-
|
|
|
|
|
6 |
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
iface.launch()
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../fire_detector_gradio.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learner', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
|
5 |
+
|
6 |
+
# %% ../fire_detector_gradio.ipynb 1
|
7 |
+
from fastai.vision.all import load_learner
|
8 |
import gradio as gr
|
9 |
|
10 |
+
# %% ../fire_detector_gradio.ipynb 3
|
11 |
+
learner = load_learner("model.pkl")
|
12 |
+
|
13 |
+
# %% ../fire_detector_gradio.ipynb 4
|
14 |
+
categories = ('fireplace fire', "building fire", "wild fire", "lithium battery fire", "bonfire")
|
15 |
+
|
16 |
+
|
17 |
+
def classify_image(im):
|
18 |
+
pred, idx, probs = learner.predict(im)
|
19 |
+
return dict(zip(categories, map(float, probs)))
|
20 |
+
|
21 |
|
22 |
+
# %% ../fire_detector_gradio.ipynb 6
|
23 |
+
image = gr.inputs.Image(shape=(256, 256))
|
24 |
+
label = gr.outputs.Label()
|
25 |
+
examples = ["wildfire.jpg", "bonfire.jpg", "fireplace.jpg", "lithium.jpg"]
|
26 |
|
27 |
+
intf = gr.Interface(fn=classify_image, inputs=image,
|
28 |
+
outputs=label, examples=examples)
|
29 |
|
30 |
+
intf.launch(inline=False)
|
|
bonfire.jpg
ADDED
fire_indoor.png
ADDED
fireplace.jpg
ADDED
lithium.jpg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6ed2906ec88c71483873cb691799f1d2efae2da827ce9c263c95bd3f77b32af8
|
3 |
+
size 46989931
|
wildfire.jpg
ADDED