funkstop commited on
Commit
d74bf4b
·
2 Parent(s): 36ddcb5 d26be9f

Merge branch 'main' of hf.co:spaces/radatia/minimal into main

Browse files
Files changed (6) hide show
  1. app.py +32 -0
  2. cat.jpeg +0 -0
  3. dog.jpeg +0 -0
  4. dogcat.jpeg +0 -0
  5. model.pkl +3 -0
  6. requirements.txt +2 -0
app.py CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
2
  from fastai.vision.all import *
3
  import skimage
4
 
 
5
  learn = load_learner('model.pkl')
6
 
7
  labels = learn.dls.vocab
@@ -10,6 +11,19 @@ def predict(img):
10
  pred,pred_idx,probs = learn.predict(img)
11
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  title = "Pet Breed Classifier"
14
  description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
15
  article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
@@ -17,4 +31,22 @@ examples = ['siamese.jpg']
17
  interpretation='default'
18
  enable_queue=True
19
 
 
20
  gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  from fastai.vision.all import *
3
  import skimage
4
 
5
+ <<<<<<< HEAD
6
  learn = load_learner('model.pkl')
7
 
8
  labels = learn.dls.vocab
 
11
  pred,pred_idx,probs = learn.predict(img)
12
  return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
 
14
+ =======
15
+ def is_cat(x):
16
+ return x[0].isupper()
17
+
18
+ learn = load_learner('model.pkl')
19
+
20
+ labels = learn.dls.vocab
21
+ def predict(img):
22
+ img = PILImage.create(img)
23
+ pred,pred_idx,probs = learn.predict(img)
24
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
25
+
26
+ >>>>>>> d26be9f828be2719f155927ee31381a78ee309a2
27
  title = "Pet Breed Classifier"
28
  description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
29
  article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
 
31
  interpretation='default'
32
  enable_queue=True
33
 
34
+ <<<<<<< HEAD
35
  gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
36
+ =======
37
+ image = gr.Image(height=192, width=192)
38
+ label = gr.Label(num_top_classes=3)
39
+ examples = ['dog.jpeg', 'cat.jpeg', 'dogcat.jpeg']
40
+
41
+ intf = gr.Interface(
42
+ fn=predict,
43
+ inputs=image,
44
+ outputs=label,
45
+ examples=examples,
46
+ title='Cat or Dog Classifier',
47
+ description='This is a cat or dog classifier. Upload an image of a cat or dog and it will predict which it is.'
48
+ )
49
+ intf.launch()
50
+
51
+ # gr.Interface(fn=predict,inputs=gr.components.Image(height=512, width=512),outputs=gr.components.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
52
+ >>>>>>> d26be9f828be2719f155927ee31381a78ee309a2
cat.jpeg ADDED
dog.jpeg ADDED
dogcat.jpeg ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7375d58771959f253b5fcce261d2116525f917cd9543dfb81ef31f79877818e7
3
+ size 47064894
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image