File size: 1,320 Bytes
bf5f53d
eefb795
bf5f53d
93e2b13
bf5f53d
 
 
93e2b13
bf5f53d
 
93e2b13
 
 
 
bf5f53d
 
 
93e2b13
bf5f53d
93e2b13
 
bf5f53d
 
 
 
93e2b13
 
 
 
 
 
 
 
 
 
 
 
 
 
bf5f53d
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
44
45
import gradio as gr
from deepface import DeepFace
def verify(img1, img2):
    result = DeepFace.verify(img1_path = img1, img2_path = img2, model_name = models[0])
    return result

def detect(img):
    dct = DeepFace.detectFace(img, model_name = models[0])
    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(type = "numpy")
        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(type = "numpy")
        imgToVerify2 = gr.Image(type = "numpy")
      verifyOutput = gr.Textbox()
      verifyImgButton = gr.Button("Verify with Images input")

    verifyImgButton.click(verify, inputs=[imgToVerify2,imgToVerify], outputs = verifyOutput)

    with gr.Tab("Face Analysis"):
      with gr.Row():
        imgToAnalyze = gr.Image(type = "numpy")
      analyzeData = gr.JSON()
      analyzeImgButton = gr.Button("Analyze this image")

    analyzeImgButton.click(analyze, inputs = imgToAnalyze, outputs = analyzeData)

    
  
demo.launch()