File size: 1,222 Bytes
bf5f53d
eefb795
bf5f53d
c16f470
a1b648f
bf5f53d
 
c16f470
bf5f53d
 
93e2b13
 
 
 
bf5f53d
 
 
93e2b13
bf5f53d
bd809d0
93e2b13
bf5f53d
 
 
 
93e2b13
 
bd809d0
 
93e2b13
 
 
c066dec
93e2b13
 
 
bd809d0
93e2b13
 
bf5f53d
93e2b13
bf5f53d
2a94b1b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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()