bobalbrecht commited on
Commit
47031ed
·
1 Parent(s): adf4963

changed app to use cloudds

Browse files
Files changed (1) hide show
  1. app.py +32 -4
app.py CHANGED
@@ -1,8 +1,36 @@
 
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
8
 
 
1
+ from fastai.vision import *
2
  import gradio as gr
3
+ from pathlib import Path
4
 
5
+ learn = load_learner('cloudmodel.pk1')
6
+
7
+ categories = (
8
+ 'Cirrus',
9
+ 'Cirrostratus',
10
+ 'Cirrocumulus',
11
+ 'Altostratus',
12
+ 'Altocumulus',
13
+ 'Stratus',
14
+ 'Stratocumulus',
15
+ 'Nimbostratus',
16
+ 'Cumulus',
17
+ 'Cumulonimbus',
18
+ 'Lenticular'
19
+ )
20
+
21
+ image = gr.inputs.Image(shape=(192,192))
22
+ label = gr.outputs.Label()
23
+ image_path = Path('images')
24
+ examples = [image_path / f"{c}.jpg" for c in categories]
25
+
26
+ def classify_image(img):
27
+ pred,idx,probs = learn.predict(img)
28
+ return dict(zip(categories, map(float, probs)))
29
+
30
+
31
+ iface = gr.Interface(fn=classify_image, inputs=image, outputs=label,
32
+ examples=examples)
33
+
34
+ # iface.launch()
35
 
 
 
36