jhj0517 commited on
Commit
219ecf9
·
1 Parent(s): d35e462

Fix meaningless `retargeting()`

Browse files
modules/live_portrait/live_portrait_inferencer.py CHANGED
@@ -4,6 +4,7 @@ import cv2
4
  import time
5
  import copy
6
  import dill
 
7
  from ultralytics import YOLO
8
  import safetensors.torch
9
  import gradio as gr
@@ -218,9 +219,9 @@ class LivePortraitInferencer:
218
  rotate_yaw += self.d_info['yaw'] * sample_ratio
219
  rotate_roll += self.d_info['roll'] * sample_ratio
220
  elif sample_parts == SamplePart.ONLY_MOUTH.value:
221
- self.retargeting(es.e, self.d_info['exp'], sample_ratio, (14, 17, 19, 20))
222
  elif sample_parts == SamplePart.ONLY_EYES.value:
223
- self.retargeting(es.e, self.d_info['exp'], sample_ratio, (1, 2, 11, 13, 15, 16))
224
 
225
  es.r = self.calc_fe(es.e, blink, eyebrow, wink, pupil_x, pupil_y, aaa, eee, woo, smile,
226
  rotate_pitch, rotate_yaw, rotate_roll)
@@ -312,8 +313,8 @@ class LivePortraitInferencer:
312
  if d_0_es is None:
313
  d_0_es = ExpressionSet(erst = (d_i_info['exp'], d_i_r, d_i_info['scale'], d_i_info['t']))
314
 
315
- self.retargeting(s_es.e, d_0_es.e, retargeting_eyes, (11, 13, 15, 16))
316
- self.retargeting(s_es.e, d_0_es.e, retargeting_mouth, (14, 17, 19, 20))
317
 
318
  new_es.e += d_i_info['exp'] - d_0_es.e
319
  new_es.r += d_i_r - d_0_es.r
@@ -508,9 +509,10 @@ class LivePortraitInferencer:
508
 
509
  @staticmethod
510
  def retargeting(delta_out, driving_exp, factor, idxes):
 
511
  for idx in idxes:
512
- # delta_out[0, idx] -= src_exp[0, idx] * factor
513
  delta_out[0, idx] += driving_exp[0, idx] * factor
 
514
 
515
  @staticmethod
516
  def calc_face_region(square, dsize):
 
4
  import time
5
  import copy
6
  import dill
7
+ import torch
8
  from ultralytics import YOLO
9
  import safetensors.torch
10
  import gradio as gr
 
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)
 
313
  if d_0_es is None:
314
  d_0_es = ExpressionSet(erst = (d_i_info['exp'], d_i_r, d_i_info['scale'], d_i_info['t']))
315
 
316
+ s_es.e = self.retargeting(s_es.e, d_0_es.e, retargeting_eyes, (11, 13, 15, 16))
317
+ s_es.e = self.retargeting(s_es.e, d_0_es.e, retargeting_mouth, (14, 17, 19, 20))
318
 
319
  new_es.e += d_i_info['exp'] - d_0_es.e
320
  new_es.r += d_i_r - d_0_es.r
 
509
 
510
  @staticmethod
511
  def retargeting(delta_out, driving_exp, factor, idxes):
512
+ delta_out = delta_out.clone()
513
  for idx in idxes:
 
514
  delta_out[0, idx] += driving_exp[0, idx] * factor
515
+ return delta_out
516
 
517
  @staticmethod
518
  def calc_face_region(square, dsize):