rafaym commited on
Commit
a0ae92e
·
1 Parent(s): 6e59158

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
14
+ examples=('Black people','White people')
15
+ demo = gr.Interface(fn=func_classi, inputs=[gr.Webcam()], outputs=[gr.Textbook(label="Results")])
16
+ demo.launch(inline=False)