Spaces:
Sleeping
Sleeping
hanna-harding
commited on
Commit
•
db8c95d
1
Parent(s):
c3edd22
Upload files
Browse files- .gitattributes +1 -0
- app.py +23 -0
- model.pkl +3 -0
- requirements.txt +3 -0
- whale.jpeg +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
whale.jpeg filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
|
5 |
+
# load model
|
6 |
+
learn = load_learner('model.pkl')
|
7 |
+
|
8 |
+
# prediction function for model
|
9 |
+
labels = learn.dls.vocab
|
10 |
+
def predict(img):
|
11 |
+
img = PILImage.create(img)
|
12 |
+
pred,pred_idx,probs = learn.predict(img)
|
13 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
14 |
+
|
15 |
+
# gradio app
|
16 |
+
title = "Whale model"
|
17 |
+
description = "Demo Gradio app for a ML image classifier using fast.ai"
|
18 |
+
examples = ['whale.jpeg']
|
19 |
+
interpretation='default' # so users can understand what parts of the input are responsible for the output
|
20 |
+
enable_queue=True # for lots of traffic
|
21 |
+
|
22 |
+
app = gr.Interface(fn=predict,inputs="image",outputs="label",title=title,description=description,examples=examples, interpretation=interpretation,enable_queue=enable_queue)
|
23 |
+
app.launch()
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4d08a5327faaeb852473a3580f10bfa79d857dfb528c25bb9558795ac82127f2
|
3 |
+
size 46954649
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|
3 |
+
gradio
|
whale.jpeg
ADDED
Git LFS Details
|