jhj0517 commited on
Commit
2459a6e
1 Parent(s): e679e08

Add gradio app

Browse files
Files changed (1) hide show
  1. app.py +71 -0
app.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from modules.live_portrait.live_portrait_inferencer import LivePortraitInferencer
4
+
5
+
6
+ class App:
7
+ def __init__(self,
8
+ args=None):
9
+ self.args = args
10
+ self.app = gr.Blocks()
11
+ self.inferencer = LivePortraitInferencer()
12
+
13
+ def launch(self):
14
+ with self.app:
15
+ with gr.Row():
16
+ with gr.Column():
17
+ img_ref = gr.Image(label="Reference Image")
18
+
19
+ with gr.Column():
20
+ sld_rotate_pitch = gr.Slider(label="Rotate Pitch", minimum=-20, maximum=20, step=0.5, value=0)
21
+ sld_rotate_yaw = gr.Slider(label="Rotate Yaw", minimum=-20, maximum=20, step=0.5, value=0)
22
+ sld_rotate_roll = gr.Slider(label="Rotate Roll", minimum=-20, maximum=20, step=0.5, value=0)
23
+
24
+ sld_blink = gr.Slider(label="Blink", minimum=-20, maximum=5, step=0.5, value=0)
25
+ sld_eyebrow = gr.Slider(label="Eyebrow", minimum=-10, maximum=15, step=0.5, value=0)
26
+ sld_wink = gr.Slider(label="Wink", minimum=0, maximum=25, step=0.5, value=0)
27
+ sld_pupil_x = gr.Slider(label="Pupil X", minimum=-15, maximum=15, step=0.5, value=0)
28
+ sld_pupil_y = gr.Slider(label="Pupil Y", minimum=-15, maximum=15, step=0.5, value=0)
29
+
30
+ sld_aaa = gr.Slider(label="AAA", minimum=-30, maximum=120, step=1, value=0)
31
+ sld_eee = gr.Slider(label="EEE", minimum=-20, maximum=15, step=0.2, value=0)
32
+ sld_woo = gr.Slider(label="WOO", minimum=-20, maximum=15, step=0.2, value=0)
33
+ sld_smile = gr.Slider(label="Smile", minimum=-0.3, maximum=1.3, step=0.01, value=0)
34
+
35
+ sld_src_ratio = gr.Slider(label="Source Ratio", minimum=0, maximum=1, step=0.01, value=1)
36
+ sld_sample_ratio = gr.Slider(label="Sample Ratio", minimum=-0.2, maximum=1.2, step=0.01, value=1)
37
+
38
+ dd_sample_parts = gr.Dropdown(label="Sample Parts",
39
+ choices=["OnlyExpression", "OnlyRotation", "OnlyMouth", "OnlyEyes", "All"],
40
+ value="All")
41
+ sld_crop_factor = gr.Slider(label="Crop Factor", minimum=1.5, maximum=2.5, step=0.1,
42
+ value=1.7)
43
+ with gr.Accordion("Opt in features", visible=False):
44
+ img_sample = gr.Image()
45
+ img_motion_link = gr.Image()
46
+ tb_exp = gr.Textbox()
47
+ with gr.Row():
48
+ btn_gen = gr.Button("GEN")
49
+ with gr.Row():
50
+ img_out = gr.Image(label="Output Image")
51
+
52
+ params = [
53
+ sld_rotate_pitch, sld_rotate_yaw, sld_rotate_roll, sld_blink, sld_eyebrow, sld_wink, sld_pupil_x,
54
+ sld_pupil_y, sld_aaa, sld_eee, sld_woo, sld_smile, sld_src_ratio, sld_sample_ratio, dd_sample_parts,
55
+ sld_crop_factor, img_ref
56
+ ]
57
+ opt_in_features_params = [img_sample, img_motion_link, tb_exp]
58
+
59
+ btn_gen.click(self.inferencer.edit_expression,
60
+ inputs=params + opt_in_features_params,
61
+ outputs=img_out)
62
+
63
+ self.app.launch(inbrowser=True)
64
+
65
+
66
+ app = App()
67
+ app.launch()
68
+
69
+
70
+
71
+