Spaces:
Runtime error
Runtime error
Salman Naqvi
commited on
Commit
·
e794969
1
Parent(s):
83c60e7
Created app.
Browse files
app.ipynb
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
app.py
CHANGED
@@ -1,14 +1,28 @@
|
|
1 |
-
|
|
|
|
|
|
|
2 |
|
|
|
|
|
|
|
3 |
|
4 |
-
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
|
9 |
-
|
10 |
-
|
|
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
|
14 |
-
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learner', 'categories', 'image', 'label', 'examples', 'interface', 'classify_image']
|
5 |
|
6 |
+
# %% app.ipynb 2
|
7 |
+
import gradio as gr
|
8 |
+
from fastai.vision.all import *
|
9 |
|
10 |
+
# %% app.ipynb 5
|
11 |
+
learner = load_learner('model/flood_classifier.pkl')
|
12 |
|
13 |
+
# %% app.ipynb 7
|
14 |
+
categories = ('Not Flooded', 'Flooded')
|
15 |
|
16 |
+
def classify_image(image):
|
17 |
+
prediction, index, probabilities = learner.predict(image)
|
18 |
+
return dict(zip(categories, map(float, probabilities)))
|
19 |
|
20 |
+
# %% app.ipynb 9
|
21 |
+
image = gr.Image()
|
22 |
+
label = gr.Label()
|
23 |
+
examples = [str(image_path) for image_path in Path('images/example_images')
|
24 |
+
.rglob('*.jpeg')]
|
25 |
|
26 |
+
# %% app.ipynb 11
|
27 |
+
interface = gr.Interface(fn=classify_image, inputs='image', outputs='label', examples=examples)
|
28 |
+
interface.launch(inline=False)
|