rafaym commited on
Commit
7d6f63f
·
1 Parent(s): 4c20b36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -3,19 +3,25 @@ import gradio as gr
3
 
4
 
5
  #is_black(x) : return x[0].isupper()
6
- categories=('Black people','White people')
7
- def func_classi(image):
8
  learn=load_learner('model.pkl')
9
- race,_,probs = learn.predict(PILImage.create(image))
10
  print(f"This is a: {race}.")
11
  print(f"Probability it's a black person: {probs[0]:.4f}.\nProbability it's a white person: {probs[1]:.4f}")
12
-
 
13
  pred,idx,probs=learn.predict(img)
14
  return dict(zip(categories,map(float,probs)))
15
 
 
 
 
 
 
16
 
17
  #image=gr.inputs.Image(shape=(192,192))
18
  #label=gr.outputs.Label()
19
- examples=('Black people','White people')
20
- demo = gr.Interface(fn=func_classi, inputs=[gr.func_classi()], outputs=[gr.Textbook(label="Results")])
21
- demo.launch(inline=False)
 
3
 
4
 
5
  #is_black(x) : return x[0].isupper()
6
+
7
+ def input_img(img)
8
  learn=load_learner('model.pkl')
9
+ race,_,probs = learn.predict(PILImage.create(img))
10
  print(f"This is a: {race}.")
11
  print(f"Probability it's a black person: {probs[0]:.4f}.\nProbability it's a white person: {probs[1]:.4f}")
12
+ categories=('Black people','White people')
13
+ def func_classi(img):
14
  pred,idx,probs=learn.predict(img)
15
  return dict(zip(categories,map(float,probs)))
16
 
17
+ image=gr.inputs.Image(shape=(192,192))
18
+ label=gr.outputs.Label()
19
+ examples=('Black people','White people')
20
+ demo = gr.Interface(fn=func_classi, inputs="image", outputs="label")
21
+ demo.launch(inline=False)
22
 
23
  #image=gr.inputs.Image(shape=(192,192))
24
  #label=gr.outputs.Label()
25
+ #examples=('Black people','White people')
26
+ #demo = gr.Interface(fn=func_classi, inputs=[gr.func_classi()], outputs=[gr.Textbook(label="Results")])
27
+ #demo.launch(inline=False)