jhj0517 commited on
Commit
41321c3
ยท
unverified ยท
2 Parent(s): 80de2f9 0d02276

Merge pull request #1 from jhj0517/feature/make-enum

Browse files
app.py CHANGED
@@ -39,7 +39,7 @@ class App:
39
  gr.Slider(label=_("Source Ratio"), minimum=0, maximum=1, step=0.01, value=1),
40
  gr.Slider(label=_("Sample Ratio"), minimum=-0.2, maximum=1.2, step=0.01, value=1),
41
  gr.Dropdown(label=_("Sample Parts"),
42
- choices=["OnlyExpression", "OnlyRotation", "OnlyMouth", "OnlyEyes", "All"], value="All"),
43
  gr.Slider(label=_("Crop Factor"), minimum=1.5, maximum=2.5, step=0.1, value=1.7)
44
  ]
45
 
 
39
  gr.Slider(label=_("Source Ratio"), minimum=0, maximum=1, step=0.01, value=1),
40
  gr.Slider(label=_("Sample Ratio"), minimum=-0.2, maximum=1.2, step=0.01, value=1),
41
  gr.Dropdown(label=_("Sample Parts"),
42
+ choices=[part.value for part in SamplePart], value=SamplePart.ALL.value),
43
  gr.Slider(label=_("Crop Factor"), minimum=1.5, maximum=2.5, step=0.1, value=1.7)
44
  ]
45
 
i18n/translation.yaml CHANGED
@@ -18,6 +18,11 @@ en: # English
18
  Sample Ratio: Sample Ratio
19
  Sample Parts: Sample Parts
20
  Crop Factor: Crop Factor
 
 
 
 
 
21
 
22
  ko: # Korean
23
  Language: ์–ธ์–ด
@@ -35,10 +40,15 @@ ko: # Korean
35
  EEE: ์ด์ด์ด
36
  WOO: ์šฐ์šฐ์šฐ
37
  Smile: ๋ฏธ์†Œ
38
- Source Ratio: ์›๋ณธ ๋น„์œจ
39
  Sample Ratio: ์ƒ˜ํ”Œ ๋น„์œจ
40
  Sample Parts: ์ƒ˜ํ”Œ ํŒŒํŠธ
41
  Crop Factor: Crop Factor
 
 
 
 
 
42
 
43
  ja: # Japanese
44
  Language: ่จ€่ชž
@@ -60,6 +70,11 @@ ja: # Japanese
60
  Sample Ratio: Sample Ratio
61
  Sample Parts: Sample Parts
62
  Crop Factor: Crop Factor
 
 
 
 
 
63
 
64
  es: # Spanish
65
  Language: Idioma
@@ -81,6 +96,11 @@ es: # Spanish
81
  Sample Ratio: Sample Ratio
82
  Sample Parts: Sample Parts
83
  Crop Factor: Crop Factor
 
 
 
 
 
84
 
85
  fr: # French
86
  Language: Langue
@@ -102,6 +122,11 @@ fr: # French
102
  Sample Ratio: Sample Ratio
103
  Sample Parts: Sample Parts
104
  Crop Factor: Crop Factor
 
 
 
 
 
105
 
106
  de: # German
107
  Language: Sprache
@@ -123,6 +148,11 @@ de: # German
123
  Sample Ratio: Sample Ratio
124
  Sample Parts: Sample Parts
125
  Crop Factor: Crop Factor
 
 
 
 
 
126
 
127
  zh: # Chinese
128
  Language: ่ฏญ่จ€
@@ -144,6 +174,11 @@ zh: # Chinese
144
  Sample Ratio: Sample Ratio
145
  Sample Parts: Sample Parts
146
  Crop Factor: Crop Factor
 
 
 
 
 
147
 
148
  uk: # Ukrainian
149
  Language: ะœะพะฒะฐ
@@ -165,6 +200,11 @@ uk: # Ukrainian
165
  Sample Ratio: Sample Ratio
166
  Sample Parts: Sample Parts
167
  Crop Factor: Crop Factor
 
 
 
 
 
168
 
169
  ru: # Russian
170
  Language: ะฏะทั‹ะบ
@@ -186,6 +226,11 @@ ru: # Russian
186
  Sample Ratio: Sample Ratio
187
  Sample Parts: Sample Parts
188
  Crop Factor: Crop Factor
 
 
 
 
 
189
 
190
  tr: # Turkish
191
  Language: Dil
@@ -207,3 +252,8 @@ tr: # Turkish
207
  Sample Ratio: Sample Ratio
208
  Sample Parts: Sample Parts
209
  Crop Factor: Crop Factor
 
 
 
 
 
 
18
  Sample Ratio: Sample Ratio
19
  Sample Parts: Sample Parts
20
  Crop Factor: Crop Factor
21
+ OnlyExpression: OnlyExpression
22
+ OnlyRotation: OnlyRotation
23
+ OnlyMouth: OnlyMouth
24
+ OnlyEyes: OnlyEyes
25
+ All: All
26
 
27
  ko: # Korean
28
  Language: ์–ธ์–ด
 
40
  EEE: ์ด์ด์ด
41
  WOO: ์šฐ์šฐ์šฐ
42
  Smile: ๋ฏธ์†Œ
43
+ Source Ratio: ์›๋ณธ ๋ฐ˜์˜ ๋น„์œจ
44
  Sample Ratio: ์ƒ˜ํ”Œ ๋น„์œจ
45
  Sample Parts: ์ƒ˜ํ”Œ ํŒŒํŠธ
46
  Crop Factor: Crop Factor
47
+ OnlyExpression: ํ‘œ์ •๋งŒ
48
+ OnlyRotation: ํšŒ์ „๋งŒ
49
+ OnlyMouth: ์ž…๋งŒ
50
+ OnlyEyes: ๋ˆˆ๋งŒ
51
+ All: ์ „๋ถ€
52
 
53
  ja: # Japanese
54
  Language: ่จ€่ชž
 
70
  Sample Ratio: Sample Ratio
71
  Sample Parts: Sample Parts
72
  Crop Factor: Crop Factor
73
+ OnlyExpression: OnlyExpression
74
+ OnlyRotation: OnlyRotation
75
+ OnlyMouth: OnlyMouth
76
+ OnlyEyes: OnlyEyes
77
+ All: All
78
 
79
  es: # Spanish
80
  Language: Idioma
 
96
  Sample Ratio: Sample Ratio
97
  Sample Parts: Sample Parts
98
  Crop Factor: Crop Factor
99
+ OnlyExpression: OnlyExpression
100
+ OnlyRotation: OnlyRotation
101
+ OnlyMouth: OnlyMouth
102
+ OnlyEyes: OnlyEyes
103
+ All: All
104
 
105
  fr: # French
106
  Language: Langue
 
122
  Sample Ratio: Sample Ratio
123
  Sample Parts: Sample Parts
124
  Crop Factor: Crop Factor
125
+ OnlyExpression: OnlyExpression
126
+ OnlyRotation: OnlyRotation
127
+ OnlyMouth: OnlyMouth
128
+ OnlyEyes: OnlyEyes
129
+ All: All
130
 
131
  de: # German
132
  Language: Sprache
 
148
  Sample Ratio: Sample Ratio
149
  Sample Parts: Sample Parts
150
  Crop Factor: Crop Factor
151
+ OnlyExpression: OnlyExpression
152
+ OnlyRotation: OnlyRotation
153
+ OnlyMouth: OnlyMouth
154
+ OnlyEyes: OnlyEyes
155
+ All: All
156
 
157
  zh: # Chinese
158
  Language: ่ฏญ่จ€
 
174
  Sample Ratio: Sample Ratio
175
  Sample Parts: Sample Parts
176
  Crop Factor: Crop Factor
177
+ OnlyExpression: OnlyExpression
178
+ OnlyRotation: OnlyRotation
179
+ OnlyMouth: OnlyMouth
180
+ OnlyEyes: OnlyEyes
181
+ All: All
182
 
183
  uk: # Ukrainian
184
  Language: ะœะพะฒะฐ
 
200
  Sample Ratio: Sample Ratio
201
  Sample Parts: Sample Parts
202
  Crop Factor: Crop Factor
203
+ OnlyExpression: OnlyExpression
204
+ OnlyRotation: OnlyRotation
205
+ OnlyMouth: OnlyMouth
206
+ OnlyEyes: OnlyEyes
207
+ All: All
208
 
209
  ru: # Russian
210
  Language: ะฏะทั‹ะบ
 
226
  Sample Ratio: Sample Ratio
227
  Sample Parts: Sample Parts
228
  Crop Factor: Crop Factor
229
+ OnlyExpression: OnlyExpression
230
+ OnlyRotation: OnlyRotation
231
+ OnlyMouth: OnlyMouth
232
+ OnlyEyes: OnlyEyes
233
+ All: All
234
 
235
  tr: # Turkish
236
  Language: Dil
 
252
  Sample Ratio: Sample Ratio
253
  Sample Parts: Sample Parts
254
  Crop Factor: Crop Factor
255
+ OnlyExpression: OnlyExpression
256
+ OnlyRotation: OnlyRotation
257
+ OnlyMouth: OnlyMouth
258
+ OnlyEyes: OnlyEyes
259
+ All: All
modules/live_portrait/live_portrait_inferencer.py CHANGED
@@ -201,15 +201,15 @@ class LivePortraitInferencer:
201
  self.d_info['exp'][0, 5, 1] = 0
202
 
203
  # "OnlyExpression", "OnlyRotation", "OnlyMouth", "OnlyEyes", "All"
204
- if sample_parts == "OnlyExpression" or sample_parts == "All":
205
  es.e += self.d_info['exp'] * sample_ratio
206
- if sample_parts == "OnlyRotation" or sample_parts == "All":
207
  rotate_pitch += self.d_info['pitch'] * sample_ratio
208
  rotate_yaw += self.d_info['yaw'] * sample_ratio
209
  rotate_roll += self.d_info['roll'] * sample_ratio
210
- elif sample_parts == "OnlyMouth":
211
  self.retargeting(es.e, self.d_info['exp'], sample_ratio, (14, 17, 19, 20))
212
- elif sample_parts == "OnlyEyes":
213
  self.retargeting(es.e, self.d_info['exp'], sample_ratio, (1, 2, 11, 13, 15, 16))
214
 
215
  es.r = self.calc_fe(es.e, blink, eyebrow, wink, pupil_x, pupil_y, aaa, eee, woo, smile,
 
201
  self.d_info['exp'][0, 5, 1] = 0
202
 
203
  # "OnlyExpression", "OnlyRotation", "OnlyMouth", "OnlyEyes", "All"
204
+ if sample_parts == SamplePart.ONLY_EXPRESSION.value or sample_parts == SamplePart.ONLY_EXPRESSION.ALL.value:
205
  es.e += self.d_info['exp'] * sample_ratio
206
+ if sample_parts == SamplePart.ONLY_ROTATION.value or sample_parts == SamplePart.ONLY_ROTATION.ALL.value:
207
  rotate_pitch += self.d_info['pitch'] * sample_ratio
208
  rotate_yaw += self.d_info['yaw'] * sample_ratio
209
  rotate_roll += self.d_info['roll'] * sample_ratio
210
+ elif sample_parts == SamplePart.ONLY_MOUTH.value:
211
  self.retargeting(es.e, self.d_info['exp'], sample_ratio, (14, 17, 19, 20))
212
+ elif sample_parts == SamplePart.ONLY_EYES.value:
213
  self.retargeting(es.e, self.d_info['exp'], sample_ratio, (1, 2, 11, 13, 15, 16))
214
 
215
  es.r = self.calc_fe(es.e, blink, eyebrow, wink, pupil_x, pupil_y, aaa, eee, woo, smile,
modules/utils/constants.py CHANGED
@@ -7,6 +7,14 @@ class ModelType(Enum):
7
  ANIMAL = _("Animal")
8
 
9
 
 
 
 
 
 
 
 
 
10
  REPO_MARKDOWN = """
11
  ## [AdvancedLivePortrait-WebUI](https://github.com/jhj0517/AdvancedLivePortrait-WebUI/tree/master)
12
  """
 
7
  ANIMAL = _("Animal")
8
 
9
 
10
+ class SamplePart(Enum):
11
+ ONLY_EXPRESSION = _("OnlyExpression")
12
+ ONLY_ROTATION = _("OnlyRotation")
13
+ ONLY_MOUTH = _("OnlyMouth")
14
+ ONLY_EYES = _("OnlyEyes")
15
+ ALL = _("All")
16
+
17
+
18
  REPO_MARKDOWN = """
19
  ## [AdvancedLivePortrait-WebUI](https://github.com/jhj0517/AdvancedLivePortrait-WebUI/tree/master)
20
  """