Spaces:
Runtime error
Runtime error
Alice Heiman commited on
Commit ·
60bc679
1
Parent(s): cea761f
add model
Browse files
app.py
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 1 |
+
# import gradio as gr
|
| 2 |
+
|
| 3 |
+
# def greet(name):
|
| 4 |
+
# return "Hello " + name + "!!"
|
| 5 |
+
|
| 6 |
+
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
+
# demo.launch()
|
| 8 |
+
|
| 9 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
| 10 |
+
|
| 11 |
+
# %% auto 0
|
| 12 |
+
__all__ = ["learn", "categories", "image", "label", "examples", "intf", "classify_bike"]
|
| 13 |
+
|
| 14 |
+
# %% app.ipynb 5
|
| 15 |
+
from fastai.vision.all import *
|
| 16 |
import gradio as gr
|
| 17 |
|
| 18 |
+
# %% app.ipynb 9
|
| 19 |
+
learn = load_learner("model.pkl")
|
| 20 |
+
|
| 21 |
+
# %% app.ipynb 11
|
| 22 |
+
categories = ["giant", "specialized", "trek"]
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def classify_bike(image):
|
| 26 |
+
pred, idx, probs = learn.predict(image)
|
| 27 |
+
return dict(zip(categories, map(float, probs)))
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# %% app.ipynb 13
|
| 31 |
+
image = gr.Image(height=192, width=192, label="Bike Image")
|
| 32 |
+
label = gr.Label(label="Predicted Bike Type")
|
| 33 |
+
examples = ["trek.jpg", "specialized.jpg"]
|
| 34 |
|
| 35 |
+
intf = gr.Interface(fn=classify_bike, inputs=image, outputs=label, examples=examples)
|
| 36 |
+
intf.launch(inline=False)
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:201a1e00727bf13a4bb17e353776d9920917d63679ec2eb43e55fba7971b0351
|
| 3 |
+
size 46984062
|