playdavid commited on
Commit
6322dc7
·
verified ·
1 Parent(s): 6e794f2

Upload 6 files

Browse files
Files changed (6) hide show
  1. .gitattributes +1 -0
  2. app.ipynb +0 -0
  3. app.py +32 -0
  4. cat.jpg +3 -0
  5. dog.jpg +0 -0
  6. dunno.jpg +0 -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
+ cat.jpg filter=lfs diff=lfs merge=lfs -text
app.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 1
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+
10
+ def is_cat(x): return x[0].isupper()
11
+
12
+ # %% app.ipynb 8
13
+ learn = load_learner('model.pkl')
14
+
15
+ # %% app.ipynb 10
16
+ categories = ('Dog', 'Cat')
17
+
18
+ def classify_image(img):
19
+ pred,idx,probs = learn.predict(img)
20
+ return dict(zip(categories, map(float,probs)))
21
+
22
+ # %% app.ipynb 12
23
+ #image = gr.Image(shape=(192, 192))
24
+ image = gr.Image(image_mode='RGB') # 不再使用 shape 參數
25
+ label = gr.Label()
26
+ examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
27
+
28
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples
29
+ ,allow_flagging="never"
30
+ #預設會有Flag的功能,若要取消則要加入上述。
31
+ )
32
+ intf.launch(inline=False)
cat.jpg ADDED

Git LFS Details

  • SHA256: 834d194a5414c079992879b92b780d02ca74737f07e59af475a0f70b1996249e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.14 MB
dog.jpg ADDED
dunno.jpg ADDED