Merge pull request #1 from jhj0517/feature/make-enum
Browse files- app.py +1 -1
- i18n/translation.yaml +51 -1
- modules/live_portrait/live_portrait_inferencer.py +4 -4
- modules/utils/constants.py +8 -0
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=[
|
| 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 ==
|
| 205 |
es.e += self.d_info['exp'] * sample_ratio
|
| 206 |
-
if sample_parts ==
|
| 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 ==
|
| 211 |
self.retargeting(es.e, self.d_info['exp'], sample_ratio, (14, 17, 19, 20))
|
| 212 |
-
elif sample_parts ==
|
| 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 |
"""
|