🚀 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權重,最後根據提示詞生成視頻並導出。