Salman Naqvi commited on
Commit
e794969
·
1 Parent(s): 83c60e7

Created app.

Browse files
Files changed (2) hide show
  1. app.ipynb +0 -0
  2. app.py +22 -8
app.ipynb CHANGED
The diff for this file is too large to render. See raw diff
 
app.py CHANGED
@@ -1,14 +1,28 @@
1
- import gradio as gr
 
 
 
2
 
 
 
 
3
 
4
- def main():
 
5
 
6
- def greet(name):
7
- return "Hello " + name + "!!"
8
 
9
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
10
- iface.launch()
 
11
 
 
 
 
 
 
12
 
13
- if __name__ == '__main__':
14
- main()
 
 
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)