Chinat commited on
Commit
4689cab
1 Parent(s): e81a241

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai import *
3
+ from fastai.vision.all import *
4
+
5
+ import pathlib
6
+ plt = platform.system()
7
+ if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
8
+
9
+ learn_inf = load_learner("export.pkl")
10
+ new_label = {'asian male': '老公', 'glasses asian female': '老婆'}
11
+
12
+ def predict_person(img):
13
+
14
+ pred, pred_idx, probs = learn_inf.predict(img)
15
+ return f'Prediction: {new_label[pred]}; Probability: {probs[pred_idx]:.04f}'
16
+
17
+ gr.inputs.Image(tool=False, optional=False)
18
+ webpage = gr.Interface(fn=predict_person, inputs=gr.inputs.Image(tool=False, optional=False), outputs="text", title="Special Detector", live=True, theme="dark-peach", description="It is a special detector...")
19
+ # webpage = gr.Interface(fn=predict_person, inputs=gr.inputs.Image(tool=False, optional=False), outputs="text", title="Special Detector", live=True, theme="dark-peach", description="It is a special detector...", examples=[["example1.jpg"], ["example2.jpg"], ["example3.jpg"]])
20
+ webpage.launch()