khartist29's picture
changes minor issues
a1b648f
import gradio as gr
from deepface import DeepFace
def verify(img1, img2):
result = DeepFace.verify(img1_path = img1, img2_path = img2)
return result['verified']
def detect(img):
dct = DeepFace.detectFace(img)
return dct
def analyze(img):
objs = DeepFace.analyze(img_path = img, actions = ['age', 'gender', 'race', 'emotion'])
return objs
demo = gr.Blocks()
with demo:
with gr.Tab("Face Detection"):
with gr.Row():
image_input = gr.Image()
image_output = gr.Image()
image_button = gr.Button("Detect")
image_button.click(detect, inputs=image_input, outputs=image_output)
with gr.Tab("Verification"):
with gr.Row():
imgToVerify = gr.Image()
imgToVerify2 = gr.Image()
verifyOutput = gr.Textbox()
verifyImgButton = gr.Button("Verify with Images input")
verifyImgButton.click(verify, inputs=[imgToVerify,imgToVerify2], outputs = verifyOutput)
with gr.Tab("Face Analysis"):
with gr.Row():
imgToAnalyze = gr.Image()
analyzeData = gr.JSON()
analyzeImgButton = gr.Button("Analyze this image")
analyzeImgButton.click(analyze, inputs = imgToAnalyze, outputs = analyzeData)
demo.launch()