Joshyvibe commited on
Commit
28ef3e5
·
1 Parent(s): 4a685ff

Add binary files, app.py and track with Git LFS

Browse files
Files changed (6) hide show
  1. .gitattributes +1 -0
  2. app.py +44 -0
  3. cat.jpg +3 -0
  4. dog.jpg +3 -0
  5. model.pkl +3 -0
  6. requirements.txt +1 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ 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
+ *.jpg filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image']
5
+
6
+ # %% ../app.ipynb 6
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+
10
+ def is_cat(x): return x[0].isupper()
11
+
12
+
13
+ # %% ../app.ipynb 9
14
+ #EXPORT_PATH = pathlib.Path("model.pkl")
15
+
16
+ #with set_posix_windows():
17
+ #learn = load_learner(EXPORT_PATH)
18
+
19
+ learn = load_learner('model.pkl')
20
+
21
+ # %% ../app.ipynb 11
22
+ categories = ('Dog', 'Cat')
23
+ def classify_image(img):
24
+ img = img.resize((192, 192))
25
+ img = PILImage.create(img)
26
+
27
+ if not isinstance(img, Image.Image):
28
+ return "Error: The input is not a valid image."
29
+
30
+ # Make the prediction using the pre-trained model
31
+ pred, idx, probs = learn.predict(img)
32
+
33
+ # Return the probabilities as a dictionary of categories and their respective probabilities
34
+ return dict(zip(categories, map(float, probs)))
35
+
36
+
37
+
38
+ # %% ../app.ipynb 13
39
+ image = gr.Image(type="pil")
40
+ label = gr.Label()
41
+ examples = ['dog.jpg', 'cat.jpg']
42
+
43
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
44
+ intf.launch(inline=False)
cat.jpg ADDED

Git LFS Details

  • SHA256: 9175c9f9e3a7402b3d5170b473cb858ee3b014816128097d5dd42e94b8bbd7e9
  • Pointer size: 131 Bytes
  • Size of remote file: 227 kB
dog.jpg ADDED

Git LFS Details

  • SHA256: cd3dbfc3e9fd16b5f55dfd733666af41a34935e639b7a6d74c884ef36b8748aa
  • Pointer size: 132 Bytes
  • Size of remote file: 1.49 MB
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1c09d8f778f89c9eb588eefd9a5ba094eb163cd3ea708a4ea567a83e924f149f
3
+ size 47059947
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fastai