Tom commited on
Commit
de04ff2
1 Parent(s): 3f96d45

Add model and gradio interface

Browse files
Files changed (4) hide show
  1. app.ipynb +0 -0
  2. app.py +14 -4
  3. contrail.png +0 -0
  4. model.pkl +3 -0
app.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
app.py CHANGED
@@ -1,7 +1,17 @@
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()
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from fastai.vision.all import *
3
 
4
+ learn = load_learner("model.pkl")
 
5
 
6
+ categories = ("contrail", "no contrail")
7
+
8
+ def classify_image(image):
9
+ category, idx, probabilities = learn.predict(image)
10
+ return dict(zip(categories, map(float, probabilities)))
11
+
12
+ image = gr.Image(shape=(400, 400))
13
+ label = gr.outputs.Label()
14
+ examples = ["contrail.png"]
15
+
16
+ interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
17
+ interface.launch(inline=False)
contrail.png ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f94db3a32582cfd52708a1b96a22c0394ff6b3fa533688a153b26a08783476cf
3
+ size 46971777