Spaces:
Runtime error
Runtime error
Update app
Browse files- .gitattributes +1 -0
- 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 |
-
|
8 |
-
|
9 |
-
|
10 |
-
""
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
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)
|