Riwaj Bhurtel commited on
Commit
2674bc7
·
1 Parent(s): ee086c7

updated files

Browse files
Files changed (9) hide show
  1. .gitattributes +2 -0
  2. .gitignore +4 -0
  3. app.ipynb +0 -0
  4. app.py +70 -0
  5. cat.jpg +3 -0
  6. dog.png +3 -0
  7. export.pkl +3 -0
  8. requirements.txt +10 -0
  9. train.ipynb +0 -0
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.png filter=lfs diff=lfs merge=lfs -text
37
+ *.jpg filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Classifier/
2
+ .gradio
3
+ venv/
4
+ .env
app.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+ if __name__ == '__main__':
5
+ # | default_exp app
6
+
7
+ #---
8
+
9
+ ##%pip install gradio
10
+ ##%pip install fastai
11
+
12
+ #---
13
+
14
+ # | export
15
+
16
+ def is_cat(x): return x[0].isupper()
17
+
18
+ #---
19
+
20
+ # | export
21
+ learn = load_learner('export.pkl')
22
+
23
+ #---
24
+
25
+ im = PILImage.create('cat.jpg')
26
+ im.thumbnail((272,272))
27
+ im
28
+
29
+ #---
30
+
31
+ ##%time learn.predict(im)
32
+
33
+ #---
34
+
35
+ # | export
36
+ categories = ("cat", "dog")
37
+
38
+ def classify_image(img):
39
+ pred, idx, probs = learn.predict(img)
40
+ return dict(zip(categories, map(float, probs)))
41
+
42
+ #---
43
+
44
+ classify_image(im)
45
+
46
+ #---
47
+
48
+ # | export
49
+ image = gr.Image()
50
+ label = gr.Label()
51
+ examples = ['cat.jpg', 'dog.png']
52
+
53
+ #---
54
+
55
+ interface = gr.Interface(
56
+ fn=classify_image,
57
+ inputs=image,
58
+ outputs=label,
59
+ examples=examples
60
+ )
61
+ interface.launch(inline=False, share=True)
62
+
63
+ #---
64
+
65
+ m = learn.model
66
+
67
+ #---
68
+
69
+ ps = list(m.parameters())
70
+ ps
cat.jpg ADDED

Git LFS Details

  • SHA256: d3bfd183867aeccd81522b59bcc819a9c271d91d799a144d800fab7c23e256cd
  • Pointer size: 131 Bytes
  • Size of remote file: 106 kB
dog.png ADDED

Git LFS Details

  • SHA256: 746e1d1c92d2dbb7130d2a99f626f3f8e64ac79869709deba932beb2feebc296
  • Pointer size: 131 Bytes
  • Size of remote file: 149 kB
export.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:896b28cf678eeb01fb46c95c9f80b0d63c714985654de9d0b42698a2d4c6cc06
3
+ size 102885900
requirements.txt ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Match the local Python 3.14 model environment.
2
+ fastai==2.8.12
3
+ fastcore==2.2.30
4
+ fasttransform==0.0.5
5
+ cloudpickle==3.1.2
6
+ plum-dispatch==2.9.0
7
+ torch==2.14.0
8
+ torchvision==0.29.0
9
+ gradio==6.28.0
10
+ Pillow==12.3.0
train.ipynb ADDED
The diff for this file is too large to render. See raw diff