Ubuntu
commited on
Commit
•
171c5a2
1
Parent(s):
ef7049d
initial commit
Browse files- .gitattributes +1 -0
- app.py +33 -0
- bear.png +0 -0
- cartoon.png +0 -0
- export.pkl +3 -0
- horse.png +0 -0
.gitattributes
CHANGED
@@ -29,3 +29,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
29 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
29 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
32 |
+
export.pkl filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../bear_detector_using_gradio.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['path', 'learn_inf', 'image', 'label', 'ui', 'classify_image']
|
5 |
+
|
6 |
+
# %% ../bear_detector_using_gradio.ipynb 1
|
7 |
+
import fastbook
|
8 |
+
from fastbook import *
|
9 |
+
import gradio as gr
|
10 |
+
|
11 |
+
# %% ../bear_detector_using_gradio.ipynb 2
|
12 |
+
# Load the model
|
13 |
+
path = Path()
|
14 |
+
learn_inf = load_learner(path/'export.pkl')
|
15 |
+
|
16 |
+
# %% ../bear_detector_using_gradio.ipynb 3
|
17 |
+
# Setup the UI
|
18 |
+
image = gr.components.Image(shape=(192,192))
|
19 |
+
label = gr.components.Label()
|
20 |
+
|
21 |
+
def classify_image(image):
|
22 |
+
pred,pred_idx,probs = learn_inf.predict(image)
|
23 |
+
return f'Prediction: {pred}; Probability: {probs[pred_idx]:.04f}'
|
24 |
+
|
25 |
+
ui = gr.Interface(
|
26 |
+
fn=classify_image,
|
27 |
+
inputs=image,
|
28 |
+
outputs=label,
|
29 |
+
examples=['horse.png', 'bear.png', 'cartoon.png'],
|
30 |
+
title='Bear Classifier',
|
31 |
+
description='A demo of exposing a model to the world with gradio and huggingfaces')
|
32 |
+
|
33 |
+
ui.launch(inline=False)
|
bear.png
ADDED
cartoon.png
ADDED
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:85b83b561521330a03bc5b2c30513dad898a3e479ed0bfdff7476e5d62ff750c
|
3 |
+
size 46973985
|
horse.png
ADDED