elyx commited on
Commit
a412168
·
1 Parent(s): 70c4ce0
app.py CHANGED
@@ -2,14 +2,18 @@ import gradio as gr
2
  from fastai.vision.all import *
3
  from fastcore import *
4
 
5
- learn = load_learner('kitten.pkl')
6
 
 
7
  classes = learn.dls.vocab
8
 
9
  def classify_images(img):
10
- img = PILimage.create(img)
11
  pred,idx,prob = learn.predict(img)
12
- return {labels[i]: float(probs[i]) for i in range(len(labels))}
 
 
 
 
13
 
14
- iface = gr.Interface(fn=classify_images, inputs=gr.interface.Image(shape=(512, 512)), outputs=gr.interface.Label())
15
- iface.launch()
 
2
  from fastai.vision.all import *
3
  from fastcore import *
4
 
 
5
 
6
+ learn = load_learner('kitten.pkl')
7
  classes = learn.dls.vocab
8
 
9
  def classify_images(img):
10
+ img = PILImage.create(img)
11
  pred,idx,prob = learn.predict(img)
12
+ return {classes[i]: float(prob[i]) for i in range(len(classes))}
13
+
14
+ title = "Cute or Ugly Kitten Classifier"
15
+ description = "Upload a kitten and it will tell you if it's ugly or cute! ~Elio."
16
+ examples = ['cute kitten.jpg', 'ugly kitten.jpg']
17
 
18
+ iface = gr.Interface(fn=classify_images, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(), title=title, description=description, examples=examples)
19
+ iface.launch(share=True)
cute kitten.jpg ADDED
cute kitten.jpg:Zone.Identifier ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ [ZoneTransfer]
2
+ ZoneId=3
3
+ ReferrerUrl=https://www.google.com/
4
+ HostUrl=https://i.pinimg.com/564x/32/f2/43/32f24381b05fcf53d8088c98963fe326.jpg
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ fastai
2
+ scikit-image
3
+ fastcore
ugly kitten.jpg ADDED
ugly kitten.jpg:Zone.Identifier ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ [ZoneTransfer]
2
+ ZoneId=3
3
+ ReferrerUrl=https://www.google.com/
4
+ HostUrl=https://www.rd.com/wp-content/uploads/2020/12/GettyImages-638917674-e1608242612552.jpg