added Face Animator module

This commit is contained in:
iperov 2022-05-13 12:26:20 +04:00
parent 98a16c4700
commit ae8a1e0ff4
51 changed files with 773 additions and 158 deletions

View file

@ -6,10 +6,10 @@ from xlib import face as lib_face
from xlib import path as lib_path
from xlib.file import SplittedFile
from xlib import cv as lib_cv
import cv2
repo_root = Path(__file__).parent.parent
large_files_list = [ (repo_root / 'modelhub' / 'onnx' / 'S3FD' / 'S3FD.onnx', 48*1024*1024),
(repo_root / 'modelhub' / 'onnx' / 'TPSMM' / 'generator.onnx', 50*1024*1024),
(repo_root / 'modelhub' / 'torch' / 'S3FD' / 'S3FD.pth', 48*1024*1024),
(repo_root / 'modelhub' / 'cv' / 'FaceMarkerLBF' / 'lbfmodel.yaml', 34*1024*1024),
]
@ -23,7 +23,11 @@ def merge_large_files(delete_parts=False):
def split_large_files(delete_original=False):
for filepath, part_size in large_files_list:
print(f'Splitting {filepath}...')
SplittedFile.split(filepath, part_size=part_size, delete_original=delete_original)
if filepath.exists():
SplittedFile.split(filepath, part_size=part_size, delete_original=delete_original)
else:
print(f'{filepath} not found. Skipping.')
print('Done')
def extract_FaceSynthetics(inputdir_path : Path, faceset_path : Path):
@ -53,7 +57,7 @@ def extract_FaceSynthetics(inputdir_path : Path, faceset_path : Path):
"""
if faceset_path.suffix != '.dfs':
raise ValueError('faceset_path must have .dfs extension.')
filepaths = lib_path.get_files_paths(inputdir_path)
fs = lib_face.Faceset(faceset_path, write_access=True, recreate=True)
for filepath in lib_con.progress_bar_iterator(filepaths, desc='Processing'):
@ -89,10 +93,10 @@ def extract_FaceSynthetics(inputdir_path : Path, faceset_path : Path):
ufm.set_UImage_uuid(uimg.get_uuid())
ufm.set_FRect(flmrks.get_FRect())
ufm.add_FLandmarks2D(flmrks)
fs.add_UFaceMark(ufm)
fs.add_UFaceMark(ufm)
fs.add_UImage(uimg, format='png')
fs.optimize()
fs.close()