mirror of
https://github.com/KwaiVGI/LivePortrait.git
synced 2024-12-22 04:12:38 +00:00
bbb2e33599
* feat: update * feat: update * feat: update * feat: update * feat: update * feat: update * feat: update * chore: refactor * chore: refactor * chore: refactor * fix: video cropping * chore: refactor * chore: remove timm * merge: animal support (#258) * feat: update * feat: update * feat: update * feat: update * feat: update * feat: update * feat: update * feat: update * feat: update * feat: update * feat: update --------- Co-authored-by: zhangdingyun <zhangdingyun@kuaishou.com> feat: update feat: update chore: stage * chore: stage * chore: refactor * chore: refactor * doc: update readme * doc: update readme * doc: update readme * chore: refactor * doc: update * doc: update * doc: update * doc: update * chore: rename * doc: update * doc: update * chore: refactor * doc: update * chore: refactor * chore: refactor * doc: update * chore: update clip feature * chore: add landmark option * doc: update * doc: update * doc: update * doc: update * doc: update * doc: update * doc: update * doc: update * doc: update * doc: update * doc: update * doc: update --------- Co-authored-by: zhangdingyun <zhangdingyun@kuaishou.com> Co-authored-by: zzzweakman <1819489045@qq.com>
66 lines
1.7 KiB
Python
66 lines
1.7 KiB
Python
# coding: utf-8
|
|
"""
|
|
for human
|
|
"""
|
|
|
|
import os
|
|
import os.path as osp
|
|
import tyro
|
|
import subprocess
|
|
from src.config.argument_config import ArgumentConfig
|
|
from src.config.inference_config import InferenceConfig
|
|
from src.config.crop_config import CropConfig
|
|
from src.live_portrait_pipeline import LivePortraitPipeline
|
|
|
|
|
|
def partial_fields(target_class, kwargs):
|
|
return target_class(**{k: v for k, v in kwargs.items() if hasattr(target_class, k)})
|
|
|
|
|
|
def fast_check_ffmpeg():
|
|
try:
|
|
subprocess.run(["ffmpeg", "-version"], capture_output=True, check=True)
|
|
return True
|
|
except:
|
|
return False
|
|
|
|
|
|
def fast_check_args(args: ArgumentConfig):
|
|
if not osp.exists(args.source):
|
|
raise FileNotFoundError(f"source info not found: {args.source}")
|
|
if not osp.exists(args.driving):
|
|
raise FileNotFoundError(f"driving info not found: {args.driving}")
|
|
|
|
|
|
def main():
|
|
# set tyro theme
|
|
tyro.extras.set_accent_color("bright_cyan")
|
|
args = tyro.cli(ArgumentConfig)
|
|
|
|
ffmpeg_dir = os.path.join(os.getcwd(), "ffmpeg")
|
|
if osp.exists(ffmpeg_dir):
|
|
os.environ["PATH"] += (os.pathsep + ffmpeg_dir)
|
|
|
|
if not fast_check_ffmpeg():
|
|
raise ImportError(
|
|
"FFmpeg is not installed. Please install FFmpeg (including ffmpeg and ffprobe) before running this script. https://ffmpeg.org/download.html"
|
|
)
|
|
|
|
fast_check_args(args)
|
|
|
|
# specify configs for inference
|
|
inference_cfg = partial_fields(InferenceConfig, args.__dict__)
|
|
crop_cfg = partial_fields(CropConfig, args.__dict__)
|
|
|
|
live_portrait_pipeline = LivePortraitPipeline(
|
|
inference_cfg=inference_cfg,
|
|
crop_cfg=crop_cfg
|
|
)
|
|
|
|
# run
|
|
live_portrait_pipeline.execute(args)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|