hudson-dev commited on
Commit
32b4dd7
·
1 Parent(s): bd9c4c0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -0
app.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #/export
2
+ from fastai.vision.all import *
3
+ import gradio as gr
4
+
5
+ learn = load_learner('tta_res.pkl')
6
+ categories = ('primary', 'clear', 'agriculture', 'road', 'water', 'partly_cloudly', 'cultivation', 'habitation', 'haze', 'cloudy', 'bare_ground', 'selective_logging', 'artisinal_mine', 'blooming', 'slash_burn', 'blow_down', 'conventional_mine')
7
+ def classify_image(img):
8
+ pred, idx, probs = learn.predict(img)
9
+ return dict(zip(categories, map(float,probs)))
10
+
11
+ image = gr.inputs.Image(shape=(192, 192))
12
+ label = gr.outputs.Label()
13
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label)
14
+ intf.launch(inline=False)