Max commited on
Commit
6a60e36
·
1 Parent(s): 32b2785

Rebasing for model.pkl

Browse files
Files changed (4) hide show
  1. app.py +23 -4
  2. humid_subtropical.jpg +0 -0
  3. mediterranean.jpg +0 -0
  4. polar.jpg +0 -0
app.py CHANGED
@@ -1,7 +1,26 @@
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
+ categories = ("alpine", "desert", "humid continental", "humid subtropical", "ice cap",
5
+ "oceanic plant", "subarctic plant", "semi-arid plant", "mediterranean", "tropical monsoon",
6
+ "tropical rainforest plant", "tropical savanna plant", "tundra plant", "polar")
7
 
8
+ learn = load_learner("model.pkl")
9
+
10
+ # Gradio needs a function
11
+ def classify_image(img):
12
+ pred, idx, probs = learn.predict(img)
13
+ return dict(zip(categories, map(float, probs)))
14
+
15
+ # Build the Gradio interface
16
+ image = gr.inputs.Image(shape=(192,192))
17
+ label = gr.outputs.label()
18
+ examples = ["polar.jpg", "mediterranean.jpg", "humid_subtropical.jpg"]
19
+
20
+ intf = gr.Interface(fn=classify_image,
21
+ inputs=image,
22
+ outputs=label,
23
+ examples=examples)
24
+
25
+ # This will give us a link to play with the model in app
26
+ intf.launch(inline=False)
humid_subtropical.jpg ADDED
mediterranean.jpg ADDED
polar.jpg ADDED