File size: 2,154 Bytes
fcd5d71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import gradio as gr
from main import main


with gr.Blocks() as demo:

    with gr.Row():
        with gr.Column():
            last_name = gr.Textbox(label='last name',
                                   interactive=True,
                                   value='ABOLADE')
            matric_no = gr.Textbox(label='Matric number',
                                   interactive=True,
                                   value='CPE/18/6627')
            
        with gr.Column():
            input_image = gr.Image(type='numpy',
                               image_mode='RGB',
                               sources='webcam',
                               interactive=True,
                               height=640,
                               width=640,
                               label='Webcam Image')
            
            cropped_input_image = gr.Image(type='pil',
                    image_mode='RGB',
                    interactive=False,
                    height=640,
                    width=640,
                    label='Detected face in webcam image')

        with gr.Column(scale=1):
            returned_image = gr.Image(type='pil',
                               image_mode='RGB',
                                interactive=False,
                               height=640,
                               width=640,
                               label='Image in database')
            cropped_returned_image = gr.Image(type='pil',
                    image_mode='RGB',
                    interactive=False,
                    height=640,
                    width=640,
                    label='Face in image in database')

    submit_button = gr.Button(value='Submit')
    result = gr.Textbox(label='Result',
                        interactive=False)
    submit_button.click(fn = main,
                        inputs=[last_name, matric_no, input_image],
                        outputs=[result, cropped_input_image,
                                 cropped_returned_image, returned_image,
                        ]
                        )
    

if __name__ == '__main__':
    demo.launch(share=False)