segadeds commited on
Commit
91f8449
·
verified ·
1 Parent(s): 4206583

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -3
app.py CHANGED
@@ -1,6 +1,5 @@
1
  from fastai.vision.all import *
2
  import gradio as gr
3
- from PIL import Image as PILImage
4
 
5
  learn = load_learner('model.pkl')
6
 
@@ -15,13 +14,12 @@ categories = ['abraham_grampa_simpson', 'agnes_skinner', 'apu_nahasapeemapetilon
15
  'sideshow_bob', 'sideshow_mel', 'snake_jailbird', 'troy_mcclure', 'waylon_smithers']
16
 
17
  def classify_image(img):
18
- img = PILImage.fromarray(img).resize((192, 192))
19
  pred, idx, probs = learn.predict(img)
20
  return {cat: float(prob) for cat, prob in zip(categories, probs)}
21
 
22
  demo = gr.Interface(
23
  fn=classify_image,
24
- inputs=gr.Image(type='numpy'),
25
  outputs=gr.Label(),
26
  examples=[
27
  'ednar.jpg',
 
1
  from fastai.vision.all import *
2
  import gradio as gr
 
3
 
4
  learn = load_learner('model.pkl')
5
 
 
14
  'sideshow_bob', 'sideshow_mel', 'snake_jailbird', 'troy_mcclure', 'waylon_smithers']
15
 
16
  def classify_image(img):
 
17
  pred, idx, probs = learn.predict(img)
18
  return {cat: float(prob) for cat, prob in zip(categories, probs)}
19
 
20
  demo = gr.Interface(
21
  fn=classify_image,
22
+ inputs=gr.Image(),
23
  outputs=gr.Label(),
24
  examples=[
25
  'ednar.jpg',