Spaces:
Sleeping
Sleeping
IreNkweke commited on
Commit ·
d9d52b8
1
Parent(s): 0c6105c
added model and app
Browse files- train.py +26 -0
- train_model.pkl +3 -0
train.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: Train_class.ipynb.
|
| 3 |
+
|
| 4 |
+
# %% auto 0
|
| 5 |
+
__all__ = ['model', 'cat', 'image', 'label', 'eg', 'classify_vehicle']
|
| 6 |
+
|
| 7 |
+
# %% Train_class.ipynb 1
|
| 8 |
+
from fastai.vision.all import *
|
| 9 |
+
import gradio as gr
|
| 10 |
+
|
| 11 |
+
# %% Train_class.ipynb 2
|
| 12 |
+
model = load_learner('train_model.pkl')
|
| 13 |
+
|
| 14 |
+
# %% Train_class.ipynb 3
|
| 15 |
+
cat = ('Bus','Train')
|
| 16 |
+
def classify_vehicle(img):
|
| 17 |
+
pred, idx, probs = model.predict(img)
|
| 18 |
+
return dict(zip(cat, map(lambda x: f"{float(x):.7f}", probs)))
|
| 19 |
+
|
| 20 |
+
# %% Train_class.ipynb 8
|
| 21 |
+
image = gr.Image()
|
| 22 |
+
label = gr.Label()
|
| 23 |
+
eg = ['train.jpg','bike.jpg','bus.jpg','car.jpeg']
|
| 24 |
+
|
| 25 |
+
gr.Interface(fn=classify_vehicle, inputs=image, outputs=label, examples=eg).launch(inline = False)
|
| 26 |
+
|
train_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:77a4e131585d51d56cc6949b7129de25a91085401cbaf5b0b3d8f743fecf1a55
|
| 3 |
+
size 46969684
|