From a96532752d14ba18774ae6d043cdf99464897e1c Mon Sep 17 00:00:00 2001 From: fengfusen Date: Fri, 12 Jul 2024 15:03:49 +0800 Subject: [PATCH 1/2] fix run speed.py --- speed.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/speed.py b/speed.py index 3cad248..4dc4d10 100644 --- a/speed.py +++ b/speed.py @@ -47,11 +47,14 @@ def load_and_compile_models(cfg, model_config): """ Load and compile models for inference """ - appearance_feature_extractor = load_model(cfg.checkpoint_F, model_config, cfg.device, 'appearance_feature_extractor') - motion_extractor = load_model(cfg.checkpoint_M, model_config, cfg.device, 'motion_extractor') - warping_module = load_model(cfg.checkpoint_W, model_config, cfg.device, 'warping_module') - spade_generator = load_model(cfg.checkpoint_G, model_config, cfg.device, 'spade_generator') - stitching_retargeting_module = load_model(cfg.checkpoint_S, model_config, cfg.device, 'stitching_retargeting_module') + import torch._dynamo + torch._dynamo.config.suppress_errors = True # Suppress errors and fall back to eager execution + + appearance_feature_extractor = load_model(cfg.checkpoint_F, model_config, cfg.device_id, 'appearance_feature_extractor') + motion_extractor = load_model(cfg.checkpoint_M, model_config, cfg.device_id, 'motion_extractor') + warping_module = load_model(cfg.checkpoint_W, model_config, cfg.device_id, 'warping_module') + spade_generator = load_model(cfg.checkpoint_G, model_config, cfg.device_id, 'spade_generator') + stitching_retargeting_module = load_model(cfg.checkpoint_S, model_config, cfg.device_id, 'stitching_retargeting_module') models_with_params = [ ('Appearance Feature Extractor', appearance_feature_extractor), From 286d1fd35a05df9abc744c2463a0c05533e81bc2 Mon Sep 17 00:00:00 2001 From: ZhizhouZhong <1819489045@qq.com> Date: Sat, 13 Jul 2024 14:45:33 +0800 Subject: [PATCH 2/2] Update speed.py --- speed.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/speed.py b/speed.py index 4dc4d10..c4ed93e 100644 --- a/speed.py +++ b/speed.py @@ -6,10 +6,13 @@ Benchmark the inference speed of each module in LivePortrait. TODO: heavy GPT style, need to refactor """ -import yaml import torch +torch._dynamo.config.suppress_errors = True # Suppress errors and fall back to eager execution + +import yaml import time import numpy as np + from src.utils.helper import load_model, concat_feat from src.config.inference_config import InferenceConfig @@ -47,9 +50,6 @@ def load_and_compile_models(cfg, model_config): """ Load and compile models for inference """ - import torch._dynamo - torch._dynamo.config.suppress_errors = True # Suppress errors and fall back to eager execution - appearance_feature_extractor = load_model(cfg.checkpoint_F, model_config, cfg.device_id, 'appearance_feature_extractor') motion_extractor = load_model(cfg.checkpoint_M, model_config, cfg.device_id, 'motion_extractor') warping_module = load_model(cfg.checkpoint_W, model_config, cfg.device_id, 'warping_module')