jhj0517 commited on
Commit
353443c
·
1 Parent(s): f48d0d5

Fix `retargeting()`

Browse files
modules/live_portrait/live_portrait_inferencer.py CHANGED
@@ -219,9 +219,9 @@ class LivePortraitInferencer:
219
  rotate_yaw += self.d_info['yaw'] * sample_ratio
220
  rotate_roll += self.d_info['roll'] * sample_ratio
221
  elif sample_parts == SamplePart.ONLY_MOUTH.value:
222
- es.e = self.retargeting(es.e, self.d_info['exp'], sample_ratio, (14, 17, 19, 20))
223
  elif sample_parts == SamplePart.ONLY_EYES.value:
224
- es.e = self.retargeting(es.e, self.d_info['exp'], sample_ratio, (1, 2, 11, 13, 15, 16))
225
 
226
  es.r = self.calc_fe(es.e, blink, eyebrow, wink, pupil_x, pupil_y, aaa, eee, woo, smile,
227
  rotate_pitch, rotate_yaw, rotate_roll)
@@ -314,8 +314,8 @@ class LivePortraitInferencer:
314
  if d_0_es is None:
315
  d_0_es = ExpressionSet(erst = (d_i_info['exp'], d_i_r, d_i_info['scale'], d_i_info['t']))
316
 
317
- s_es.e = self.retargeting(s_es.e, d_0_es.e, retargeting_eyes, (11, 13, 15, 16))
318
- s_es.e = self.retargeting(s_es.e, d_0_es.e, retargeting_mouth, (14, 17, 19, 20))
319
 
320
  new_es.e += d_i_info['exp'] - d_0_es.e
321
  new_es.r += d_i_r - d_0_es.r
@@ -510,10 +510,8 @@ class LivePortraitInferencer:
510
 
511
  @staticmethod
512
  def retargeting(delta_out, driving_exp, factor, idxes):
513
- delta_out = delta_out.clone()
514
  for idx in idxes:
515
  delta_out[0, idx] += driving_exp[0, idx] * factor
516
- return delta_out
517
 
518
  @staticmethod
519
  def calc_face_region(square, dsize):
 
219
  rotate_yaw += self.d_info['yaw'] * sample_ratio
220
  rotate_roll += self.d_info['roll'] * sample_ratio
221
  elif sample_parts == SamplePart.ONLY_MOUTH.value:
222
+ self.retargeting(es.e, self.d_info['exp'], sample_ratio, (14, 17, 19, 20))
223
  elif sample_parts == SamplePart.ONLY_EYES.value:
224
+ self.retargeting(es.e, self.d_info['exp'], sample_ratio, (1, 2, 11, 13, 15, 16))
225
 
226
  es.r = self.calc_fe(es.e, blink, eyebrow, wink, pupil_x, pupil_y, aaa, eee, woo, smile,
227
  rotate_pitch, rotate_yaw, rotate_roll)
 
314
  if d_0_es is None:
315
  d_0_es = ExpressionSet(erst = (d_i_info['exp'], d_i_r, d_i_info['scale'], d_i_info['t']))
316
 
317
+ self.retargeting(s_es.e, d_0_es.e, retargeting_eyes, (11, 13, 15, 16))
318
+ self.retargeting(s_es.e, d_0_es.e, retargeting_mouth, (14, 17, 19, 20))
319
 
320
  new_es.e += d_i_info['exp'] - d_0_es.e
321
  new_es.r += d_i_r - d_0_es.r
 
510
 
511
  @staticmethod
512
  def retargeting(delta_out, driving_exp, factor, idxes):
 
513
  for idx in idxes:
514
  delta_out[0, idx] += driving_exp[0, idx] * factor
 
515
 
516
  @staticmethod
517
  def calc_face_region(square, dsize):