rafaym commited on
Commit
4db2a6d
·
1 Parent(s): 53d474a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -43
app.py CHANGED
@@ -1,57 +1,14 @@
1
- # from fastai.vision.all import *
2
- # import gradio as gr
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(img)
10
- # #print(f"This is a: {race}.")
11
- # processed_output=(f"This is a: {race}./nProbability it's a black person: {probs[0]:.4f}.\nProbability it's a white person: {probs[1]:.4f}")
12
- # return processed_output
13
-
14
- # # categories=('Black people','White people')
15
- # # def func_classi(img):
16
- # # pred,idx,probs=learn.predict(img)
17
- # # return dict(zip(categories,map(float,probs)))
18
-
19
- # image=gr.inputs.Image(shape=(192,192))
20
- # label=gr.outputs.Label()
21
- # examples=('Black people','White people')
22
- # #demo = gr.Interface(fn=func_classi, inputs="image", outputs="label")
23
- # demo = gr.Interface(fn=input_img, inputs="image", outputs="label")
24
- # demo.launch(inline=False)
25
-
26
- # #image=gr.inputs.Image(shape=(192,192))
27
- # #label=gr.outputs.Label()
28
- # #examples=('Black people','White people')
29
- # #demo = gr.Interface(fn=func_classi, inputs=[gr.func_classi()], outputs=[gr.Textbook(label="Results")])
30
- # #demo.launch(inline=False)
31
-
32
  from fastai.vision.all import *
33
  learn=load_learner('model.pkl')
34
  def input_img(img):
35
  race,_,probs = learn.predict(PILImage.create('img'))
36
- #race,_,probs = learn.predict(PILImage.create(img))
37
- #processed_output=(f"This is a: {race}./nProbability it's a black person: {probs[0]:.4f}.\nProbability it's a white person: {probs[1]:.4f}")
38
  processed_output=(f"This is a: {race}./nProbability it's a black person: {probs[0]:.4f}.\nProbability it's a white person: {probs[1]:.4f}")
39
  return processed_output
40
 
41
- #im=PILImage.create(img)
42
- # im=PILImage.create('img')
43
- # im.thumbnail((192,192))
44
-
45
-
46
-
47
- #learn.predict(im)
48
-
49
  categories=('Black people','White people')
50
  def func_classi(img):
51
  pred,idx,probs=learn.predict(img)
52
  return dict(zip(categories,map(float,probs)))
53
-
54
- #func_classi(im)
55
  import gradio as gr
56
  image=gr.inputs.Image(shape=(192,192))
57
  label=gr.outputs.Label()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from fastai.vision.all import *
2
  learn=load_learner('model.pkl')
3
  def input_img(img):
4
  race,_,probs = learn.predict(PILImage.create('img'))
 
 
5
  processed_output=(f"This is a: {race}./nProbability it's a black person: {probs[0]:.4f}.\nProbability it's a white person: {probs[1]:.4f}")
6
  return processed_output
7
 
 
 
 
 
 
 
 
 
8
  categories=('Black people','White people')
9
  def func_classi(img):
10
  pred,idx,probs=learn.predict(img)
11
  return dict(zip(categories,map(float,probs)))
 
 
12
  import gradio as gr
13
  image=gr.inputs.Image(shape=(192,192))
14
  label=gr.outputs.Label()