igauk commited on
Commit
76a852a
·
1 Parent(s): 32f69a7

Update app

Browse files
Files changed (2) hide show
  1. .gitattributes +1 -0
  2. app.py +23 -9
.gitattributes CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ model.pkl filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -2,16 +2,30 @@
2
  My first gradio application, used to practice the deployment of a deep learning model
3
  """
4
  import gradio as gr
 
5
 
6
 
7
- def greet(name):
8
- """
9
- Returns a welcome message
10
- """
11
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
12
 
13
 
14
- iface = gr.Interface(fn=greet, inputs="text", outputs="text") # An example of how to use Gradio to create a simple
15
- # text to text interface with a function, the inputs and outputs can be represented as different things as seen in
16
- # the gradio documentation
17
- iface.launch()
 
 
 
 
 
 
2
  My first gradio application, used to practice the deployment of a deep learning model
3
  """
4
  import gradio as gr
5
+ from fastai.vision.all import *
6
 
7
 
8
+ learn = load_learner('model.pkl')
9
+ devonian_invertebrates = (
10
+ "Agnostida",
11
+ "Ammonites",
12
+ "Brachiopods",
13
+ "Bryozoa",
14
+ "Cephalopods",
15
+ "Corals",
16
+ "Crinoids",
17
+ "Gastropods",
18
+ "Nautiloids",
19
+ "Trilobites",
20
+ )
21
 
22
 
23
+ def classify_image(image):
24
+ _,_,probs = learn.predict(image)
25
+ return dict(zip(devonian_invertebrates, map(float, probs)))
26
+
27
+
28
+ image = gr.inputs.Image(shape=(192, 192))
29
+ label = gr.outputs.Label()
30
+
31
+ interface = gr.Interface(fn=classify_image, inputs=image, outputs=label).launch(inline=False)