File size: 1,069 Bytes
ff65b0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from bald_face import BaldFace

bald = BaldFace()


def predict(image):
    return bald.make(image)


footer = r"""
<center>
<b>
Demo for <a href=''>Lightweight OpenPose</a>
</b>
</center>
"""

with gr.Blocks(title="") as app:
    gr.HTML("<center><h1></h1></center>")
    gr.HTML("<center><h3></h3></center>")
    with gr.Row(equal_height=False):
        with gr.Column():
            input_img = gr.Image(type="numpy", label="Input image")
            run_btn = gr.Button(variant="primary")
        with gr.Column():
            output_img = gr.Image(type="pil", label="Output image")
            gr.ClearButton(components=[input_img, output_img], variant="stop")

    run_btn.click(predict, [input_img], [output_img])

    with gr.Row():
        blobs = [[f"examples/{x:02d}.jpg"] for x in range(1, 5)]
        examples = gr.Dataset(components=[input_img], samples=blobs)
        examples.click(lambda x: x[0], [examples], [input_img])

    with gr.Row():
        gr.HTML(footer)

app.launch(share=False, debug=True, show_error=True)
app.queue()