🚀 AnimateLCM文本到视频模型
AnimateLCM是一个文本到视频的模型,可根据给定的文本描述生成对应的视频内容,为视频创作提供了便捷的方式。
🚀 快速开始
视频示例
代码使用示例
基础用法
import torch, torch_xla, diffusers
motion_adapter = diffusers.MotionAdapter.from_pretrained('chaowenguo/AnimateLCM', torch_dtype=torch.bfloat16, variant='fp16', use_safetensors=True)
vae = diffusers.AutoencoderKL.from_single_file('https://huggingface.co/chaowenguo/pal/blob/main/vae-ft-mse-840000-ema-pruned.safetensors', torch_dtype=torch.bfloat16, use_safetensors=True)
pipe = diffusers.AnimateDiffPipeline.from_single_file('https://huggingface.co/chaowenguo/pal/blob/main/chilloutMix-Ni.safetensors', config='chaowenguo/stable-diffusion-v1-5', safety_checker=None, use_safetensors=True, torch_dtype=torch.bfloat16, motion_adapter=motion_adapter, vae=vae).to(torch_xla.core.xla_model.xla_device())
pipe.scheduler = diffusers.LCMScheduler.from_config(pipe.scheduler.config, beta_schedule='linear')
pipe.load_lora_weights('chaowenguo/AnimateLCM', weight_name='AnimateLCM_sd15_t2v_lora.safetensors')
pipe.enable_vae_slicing()
output = pipe(prompt="A full body gorgeous smiling slim young cleavage robust boob japanese girl, wearing white deep V bandeau pantie, lying on back on white bed, befautiful face, hands with five fingers, best quality, extremely detailed, HD, ultra-realistic, 8K, HQ, masterpiece, trending on artstation, art, smooth", negative_prompt="nipple, dudou, shirt, shawl, hat, sock, sleeve, monochrome, dark background, longbody, lowres, bad anatomy, bad hands, fused fingers, missing fingers, too many fingers, extra digit, fewer difits, cropped, worst quality, low quality, deformed body, bloated, ugly, unrealistic, extra hands and arms", height=912, num_frames=16, guidance_scale=3, num_inference_steps=8, generator=torch.manual_seed(0), context_frames=8)
diffuser.utils.export_to_video(output.frames[0], "animatelcm.mp4")
上述代码展示了如何使用AnimateLCM模型结合Diffusers库进行视频生成。主要步骤包括加载模型组件、配置调度器、加载LoRA权重,最后根据提示词生成视频并导出。