import gradio as gr import os import shutil import ffmpeg from datetime import datetime…
- User
import gradio as gr import os import shutil import ffmpeg from datetime import datetime from pathlib import Path import numpy as np import cv2 import torch #import spaces
from diffusers import AutoencoderKL, DDIMScheduler from einops import repeat from omegaconf import OmegaConf from PIL import Image from torchvision import transforms from transformers import CLIPVisionModelWithProjection
from src.models.pose_guider import PoseGuider from src.models.unet_2d_condition import UNet2DConditionModel from src.models.unet_3d import UNet3DConditionModel from src.pipelines.pipeline_pose2vid_long import Pose2VideoPipeline from src.utils.util import get_fps, read_frames, save_videos_grid, save_pil_imgs
from src.audio_models.model import Audio2MeshModel from src.utils.audio_util import prepare_audio_feature from src.utils.mp_utils import LMKExtractor from src.utils.draw_util import FaceMeshVisualizer from src.utils.pose_util import project_points, project_points_with_trans, matrix_to_euler_and_translation, euler_and_translation_to_matrix from src.utils.crop_face_single import crop_face from src.audio2vid import get_headpose_temp, smooth_pose_seq from src.utils.frame_interpolation import init_frame_interpolation_model, batch_images_interpolation_tool
config = OmegaConf.load('./configs/prompts/animation_audio.yaml') if config.weight_dtype == "fp16": weight_dtype = torch.float16 else: weight_dtype = torch.float32
audio_infer_config = OmegaConf.load(config.audio_inference_config)
prepare model
a2m_model = Audio2MeshModel(audio_infer_config['a2m_model']) a2m_model.load_state_dict(torch.load(audio_infer_config['pretrained_model']['a2m_ckpt'], map_location="cpu"), strict=False) a2m_model.cuda().eval()
vae = AutoencoderKL.from_pretrained( config.pretrained_vae_path, ).to("cuda", dtype=weight_dtype)
reference_unet = UNet2DConditionModel.from_pretrained( config.pretrained_base_model_path, subfolder="unet", ).to(dtype=weight_dtype, device="cuda")
inference_config_path = config.inference_config infer_config = OmegaConf.load(inference_config_path) denoising_unet = UNet3DConditionModel.from_pretrained_2d( config.pretrained_base_model_path, config.motion_module_path, subfolder="unet", unet_additional_kwargs=infer_config.unet_additional_kwargs, ).to(dtype=weight_dtype, device="cuda")
pose_guider = PoseGuider(noise_latent_channels=320, use_ca=True).to(device="cuda", dtype=weight_dtype) # not use cross attention
image_enc = CLIPVisionModelWithProjection.from_pretrained( config.image_encoder_path ).to(dtype=weight_dtype, device="cuda")
sched_kwargs = OmegaConf.to_container(infer_config.noise_scheduler_kwargs) scheduler = DDIMScheduler(**sched_kwargs)
load pretrained weights
denoising_unet.load_state_dict( torch.load(config.denoising_unet_path, map_location="cpu"), strict=False, ) reference_unet.load_state_dict( torch.load(config.reference_unet_path, map_location="cpu"), ) pose_guider.load_state_dict( torch.load(config.pose_guider_path, map_location="cpu"), )
- Assistant
The issue with the video being only one second long likely comes from how the video frames are processed, interpolated, or encoded, especially when coupled with the audio. To troubleshoot and potentially fix the issue, consider the following steps:
- User
A matching Triton is not available, some optimizations will not be enabled. Error caught was: No module named 'triton'
- Assistant
The error message you're seeing indicates that Python can't find the
tritonmodule, which is essential for some operations in the context you're working with. Triton is a programming language and a runtime for writing highly efficient GPU code. It can significantly speed up certain tasks by optimizing computations, especially in deep learning applications.To resolve this issue, you need to install the Triton Python module. You can do this typically via pip, Python's package installer. Here's how you can install Triton:
-
Open your terminal or command prompt.
-