mirror of
https://github.com/iperov/DeepFaceLive
synced 2025-08-20 21:43:22 -07:00
refactoring
This commit is contained in:
parent
6b6b6b2d16
commit
64116844f2
9 changed files with 360 additions and 74 deletions
|
@ -135,7 +135,7 @@ class FaceAlignerWorker(BackendWorker):
|
|||
exclude_moving_parts=state.exclude_moving_parts,
|
||||
head_yaw=head_yaw,
|
||||
x_offset=state.x_offset,
|
||||
y_offset=state.y_offset)
|
||||
y_offset=state.y_offset-0.08)
|
||||
|
||||
fsi.face_align_image_name = f'{frame_image_name}_{face_id}_aligned'
|
||||
fsi.image_to_align_uni_mat = uni_mat
|
||||
|
|
|
@ -164,7 +164,7 @@ class FaceMarkerWorker(BackendWorker):
|
|||
if fsi.face_urect is not None:
|
||||
# Cut the face to feed to the face marker
|
||||
face_image, face_uni_mat = fsi.face_urect.cut(frame_image, marker_state.marker_coverage, 256 if is_opencv_lbf else \
|
||||
192 if is_google_facemesh else 0 )
|
||||
192 if is_google_facemesh else 0 )
|
||||
_,H,W,_ = ImageProcessor(face_image).get_dims()
|
||||
|
||||
if is_opencv_lbf:
|
||||
|
|
|
@ -233,7 +233,7 @@ class FaceMergerWorker(BackendWorker):
|
|||
|
||||
# Combine face mask
|
||||
face_mask = ImageProcessor(face_mask).erode_blur(state.face_mask_erode, state.face_mask_blur, fade_to_border=True).get_image('HWC')
|
||||
frame_face_mask = ImageProcessor(face_mask).warpAffine(aligned_to_source_uni_mat, frame_width, frame_height).clip2( (1.0/255.0), 0.0, 1.0, 1.0).get_image('HWC')
|
||||
frame_face_mask = ImageProcessor(face_mask).warp_affine(aligned_to_source_uni_mat, frame_width, frame_height).clip2( (1.0/255.0), 0.0, 1.0, 1.0).get_image('HWC')
|
||||
|
||||
face_swap_img = ImageProcessor(face_swap_img).to_ufloat32().get_image('HWC')
|
||||
|
||||
|
@ -241,7 +241,7 @@ class FaceMergerWorker(BackendWorker):
|
|||
face_align_img = ImageProcessor(face_align_img).to_ufloat32().get_image('HWC')
|
||||
face_swap_img = lib_ct.rct(face_swap_img, face_align_img, target_mask=face_mask, source_mask=face_mask)
|
||||
|
||||
frame_face_swap_img = ImageProcessor(face_swap_img).warpAffine(aligned_to_source_uni_mat, frame_width, frame_height, interpolation=interpolation).get_image('HWC')
|
||||
frame_face_swap_img = ImageProcessor(face_swap_img).warp_affine(aligned_to_source_uni_mat, frame_width, frame_height, interpolation=interpolation).get_image('HWC')
|
||||
|
||||
# Combine final frame
|
||||
opacity = np.float32(state.face_opacity)
|
||||
|
|
|
@ -251,10 +251,10 @@ class FaceSwapperWorker(BackendWorker):
|
|||
|
||||
fai_ip = ImageProcessor(face_align_image)
|
||||
if model_state.presharpen_amount != 0:
|
||||
fai_ip.sharpen(factor=model_state.presharpen_amount)
|
||||
fai_ip.gaussian_sharpen(sigma=1.0, power=model_state.presharpen_amount)
|
||||
|
||||
if pre_gamma_red != 1.0 or pre_gamma_green != 1.0 or pre_gamma_blue != 1.0:
|
||||
fai_ip.adjust_gamma(pre_gamma_red, pre_gamma_green, pre_gamma_blue)
|
||||
fai_ip.gamma(pre_gamma_red, pre_gamma_green, pre_gamma_blue)
|
||||
face_align_image = fai_ip.get_image('HWC')
|
||||
|
||||
celeb_face, celeb_face_mask_img, face_align_mask_img = dfm_model.convert(face_align_image, morph_factor=model_state.morph_factor)
|
||||
|
|
|
@ -77,8 +77,8 @@ class FrameAdjusterWorker(BackendWorker):
|
|||
|
||||
if frame_image is not None:
|
||||
frame_image_ip = ImageProcessor(frame_image)
|
||||
frame_image_ip.median_blur(5, state.median_blur_per / 100.0 )
|
||||
frame_image_ip.degrade_resize( state.degrade_bicubic_per / 100.0, interpolation=ImageProcessor.Interpolation.CUBIC)
|
||||
frame_image_ip.median_blur(5, opacity=state.median_blur_per / 100.0 )
|
||||
frame_image_ip.reresize( state.degrade_bicubic_per / 100.0, interpolation=ImageProcessor.Interpolation.CUBIC)
|
||||
|
||||
frame_image = frame_image_ip.get_image('HWC')
|
||||
bcd.set_image(frame_image_name, frame_image)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue