aar2dee2 commited on
Commit
aeeccc7
1 Parent(s): 4fe3d5b

upload files

Browse files
Files changed (9) hide show
  1. app.py +56 -0
  2. car2.jpeg +3 -0
  3. car3.jpeg +3 -0
  4. car4.jpeg +3 -0
  5. car5.jpg +3 -0
  6. car6.jpg +3 -0
  7. car7.jpg +3 -0
  8. export.pkl +3 -0
  9. 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

  • SHA256: 246ef49803f735455b20f54a7fcac1154d44d28a163f94b9ed3b554994b3b1b4
  • Pointer size: 130 Bytes
  • Size of remote file: 49.3 kB
car3.jpeg ADDED

Git LFS Details

  • SHA256: b2a882eae11f93c4f1ceba04c5e3b86d45f948531c8dd67b2f8118b3e279cb71
  • Pointer size: 131 Bytes
  • Size of remote file: 418 kB
car4.jpeg ADDED

Git LFS Details

  • SHA256: 32726937eb6d35dee33ca90df96a6d1dba61ece50795f73af225e0880df4a72f
  • Pointer size: 130 Bytes
  • Size of remote file: 41.8 kB
car5.jpg ADDED

Git LFS Details

  • SHA256: 319ee0524cd6ac0ff68cb64e801dade92747851ba4909fa4e3d0d299bac15257
  • Pointer size: 132 Bytes
  • Size of remote file: 1.03 MB
car6.jpg ADDED

Git LFS Details

  • SHA256: a9c8f5daf223e5b1746327460d90917dd62df01df2432e32b866aac141bb9831
  • Pointer size: 132 Bytes
  • Size of remote file: 1.94 MB
car7.jpg ADDED

Git LFS Details

  • SHA256: 7ac975408a4bf05c0207b23afc6505626cc7afd1097db2400893f280b57bb873
  • Pointer size: 132 Bytes
  • Size of remote file: 1.26 MB
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