Spaces:
Runtime error
Runtime error
aar2dee2
commited on
Commit
•
aeeccc7
1
Parent(s):
4fe3d5b
upload files
Browse files- app.py +56 -0
- car2.jpeg +3 -0
- car3.jpeg +3 -0
- car4.jpeg +3 -0
- car5.jpg +3 -0
- car6.jpg +3 -0
- car7.jpg +3 -0
- export.pkl +3 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../lesson_2.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
import gradio as gr
|
5 |
+
__all__ = ['learn_inf', 'labels', 'title', 'description', 'article',
|
6 |
+
'examples', 'interpretation', 'enable_queue', 'predict']
|
7 |
+
|
8 |
+
# %% ../../lesson_2.ipynb 0
|
9 |
+
import fastai
|
10 |
+
|
11 |
+
# %% ../../lesson_2.ipynb 1
|
12 |
+
import pandas
|
13 |
+
|
14 |
+
# %% ../../lesson_2.ipynb 2
|
15 |
+
from fastai.vision.widgets import *
|
16 |
+
|
17 |
+
# %% ../../lesson_2.ipynb 3
|
18 |
+
from fastai.vision.all import *
|
19 |
+
|
20 |
+
# %% ../../lesson_2.ipynb 4
|
21 |
+
learn_inf = load_learner("./export.pkl")
|
22 |
+
|
23 |
+
# %% ../../lesson_2.ipynb 6
|
24 |
+
labels = learn_inf.dls.vocab
|
25 |
+
|
26 |
+
# %% ../../lesson_2.ipynb 7
|
27 |
+
|
28 |
+
|
29 |
+
def predict(img):
|
30 |
+
img = PILImage.create(img)
|
31 |
+
pred, pred_idx, probs = learn_inf.predict(img)
|
32 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
33 |
+
|
34 |
+
|
35 |
+
# %% ../../lesson_2.ipynb 8
|
36 |
+
|
37 |
+
# %% ../../lesson_2.ipynb 9
|
38 |
+
title = "Car Classifier"
|
39 |
+
description = "Upload the image of a car to get its type. The model uses the resnet18 trained on a variety of images of cars."
|
40 |
+
article = "<p style='text-align: center'><a href='https://github.com/aar2dee2' target='_blank'>Made by aar2dee2</a></p>"
|
41 |
+
examples = ['car2.jpeg', 'car3.jpeg', 'car4.jpeg',
|
42 |
+
'car5.jpg', 'car6.jpg', 'car7.jpg']
|
43 |
+
interpretation = 'default'
|
44 |
+
enable_queue = True
|
45 |
+
|
46 |
+
# %% ../../lesson_2.ipynb 10
|
47 |
+
gr.Interface(
|
48 |
+
fn=predict,
|
49 |
+
inputs=gr.inputs.Image(shape=(512, 512)),
|
50 |
+
outputs=gr.outputs.Label(num_top_classes=3),
|
51 |
+
title=title,
|
52 |
+
description=description,
|
53 |
+
article=article,
|
54 |
+
examples=examples,
|
55 |
+
interpretation=interpretation,
|
56 |
+
enable_queue=enable_queue).launch(share=True)
|
car2.jpeg
ADDED
Git LFS Details
|
car3.jpeg
ADDED
Git LFS Details
|
car4.jpeg
ADDED
Git LFS Details
|
car5.jpg
ADDED
Git LFS Details
|
car6.jpg
ADDED
Git LFS Details
|
car7.jpg
ADDED
Git LFS Details
|
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:03e957b52ed457b7dc7bef736871089df633e0a0c7174099b89e7f37f0bc5caa
|
3 |
+
size 47023631
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|