joseph34961971 commited on
Commit
dfbc18c
·
1 Parent(s): 06dbd7c

update dogs model

Browse files
Files changed (6) hide show
  1. app.py +11 -3
  2. dogs.pkl +3 -0
  3. golden_retriver.jpg +0 -0
  4. husky.jpg +0 -0
  5. requriements.txt +3 -0
  6. samoyed.jpg +0 -0
app.py CHANGED
@@ -4,8 +4,16 @@ from fastai.vision.all import *
4
  def greet(name):
5
  return f"Hello {name} !!"
6
 
7
- learn_inf = load_learner(path/'export.pkl')
8
- learn_inf.predict('/home/joseph/fastbook/clean/seasons/autumn/0f2b6170-7605-47bd-b4e4-49726ceae836.jpg')
 
9
 
10
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
11
  iface.launch()
 
4
  def greet(name):
5
  return f"Hello {name} !!"
6
 
7
+ def classify_image(img):
8
+ pred, idx, probs = learn.predict(img)
9
+ return dict(zip(categories, map(float, probs)))
10
 
11
+ learn = load_learner('dogs.pkl')
12
+ categories = learn.dls.vocab
13
+
14
+ image = gr.inputs.Image(shape = (192, 192))
15
+ label = gr.outputs.Label()
16
+ examples = ['golden_retriver.jpg', 'husky.jpg', 'samoyed.jpg']
17
+
18
+ iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples = examples)
19
  iface.launch()
dogs.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:75855d20cc308272526932e4995757d7efcbdfa6fea44b818d13b65f61fc2737
3
+ size 355582638
golden_retriver.jpg ADDED
husky.jpg ADDED
requriements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch <1.12
2
+ fastai>2.6.1
3
+ timm
samoyed.jpg ADDED