CogVideoX 又双叒叕开源啦!这次开源了更大尺寸,相比之前开源的CogVideoX-2B,CogVideoX-5B是视频生成质量更高,视觉效果更好的更大尺寸模型。
模型链接:
https://modelscope.cn/models/ZhipuAI/CogVideoX-5b
话不多说,先来看一波效果。
作品案例:
prompt:In a dimly lit bar, purplish light bathes the face of a mature man, his eyes blinking thoughtfully as he ponders in close-up, the background artfully blurred to focus on his introspective expression, the ambiance of the bar a mere suggestion of shadows and soft lighting.
prompt:A Chinese mother, draped in a soft, pastel-colored robe, gently rocks back and forth in a cozy rocking chair positioned in the tranquil setting of a nursery. The dimly lit bedroom is adorned with whimsical mobiles dangling from the ceiling, casting shadows that dance on the walls. Her baby, swaddled in a delicate, patterned blanket, rests against her chest, the child's earlier cries now replaced by contented coos as the mother's soothing voice lulls the little one to sleep. The scent of lavender fills the air, adding to the serene atmosphere, while a warm, orange glow from a nearby nightlight illuminates the scene with a gentle hue, capturing a moment of tender love and comfort.
prompt:On a brilliant sunny day, the lakeshore is lined with an array of willow trees, their slender branches swaying gently in the soft breeze. The tranquil surface of the lake reflects the clear blue sky, while several elegant swans glide gracefully
prompt:A golden retriever, sporting sleek black sunglasses, with its lengthy fur flowing in the breeze, sprints playfully across a rooftop terrace, recently refreshed by a light rain. The scene unfolds from a distance, the dog's energetic bounds growing larger as it approaches the camera, its tail wagging with unrestrained joy, while droplets of water glisten on the concrete behind it. The overcast sky provides a dramatic backdrop, emphasizing the vibrant golden coat of the canine as it dashes towards the viewer.
prompt: An elderly gentleman, with a serene expression, sits at the water's edge, a steaming cup of tea by his side. He is engrossed in his artwork, brush in hand, as he renders an oil painting on a canvas that's propped up against a small, weathered table. The sea breeze whispers through his silver hair, gently billowing his loose-fitting white shirt, while the salty air adds an intangible element to his masterpiece in progress. The scene is one of tranquility and inspiration, with the artist's canvas capturing the vibrant hues of the setting sun reflecting off the tranquil sea.
prompt:A suited astronaut, with the red dust of Mars clinging to their boots, reaches out to shake hands with an alien being, their skin a shimmering blue, under the pink-tinged sky of the fourth planet. In the background, a sleek silver rocket, a beacon of human ingenuity, stands tall, its engines powered down, as the two representatives of different worlds exchange a historic greeting amidst the desolate beauty of the Martian landscape.
prompt: A small boy, head bowed and determination etched on his face, sprints through the torrential downpour as lightning crackles and thunder rumbles in the distance. The relentless rain pounds the ground, creating a chaotic dance of water droplets that mirror the dramatic sky's anger. In the far background, the silhouette of a cozy home beckons, a faint beacon of safety and warmth amidst the fierce weather. The scene is one of perseverance and the unyielding spirit of a child braving the elements.
prompt: A garden comes to life as a kaleidoscope of butterflies flutters amidst the blossoms, their delicate wings casting shadows on the petals below. In the background, a grand fountain cascades water with a gentle splendor, its rhythmic sound providing a soothing backdrop. Beneath the cool shade of a mature tree, a solitary wooden chair invites solitude and reflection, its smooth surface worn by the touch of countless visitors seeking a moment of tranquility in nature's embrace.
模型介绍
论文链接:https://arxiv.org/pdf/2408.06072
CogVideoX是一个大规模DiT(diffusion transformer)模型,用于文本生成视频任务。CogVideoX主要采用了以下技术:
- 3D causal VAE:通过压缩视频数据到latent space,并在时间维度上进行解码来实现高效的视频重建。
- 专家Transformer:将文本embedding和视频embedding相结合,使用3D-RoPE作为位置编码,采用专家自适应层归一化处理两个模态的数据,以及使用3D 全注意力机制来进行时空联合建模。
通过采用渐进式训练技术,CogVideoX能够根据文本提示生成具有显著运动特征、连贯且长时间的高质量视频。相关论文为《CogVideoX: Text-to-Video Diffusion Models withAn Expert Transformer》。
下表展示目前CogVideoX视频生成模型列表,以及相关基础信息。
模型体验
智谱搭建了CogVideoX-5B模型的体验空间,同时搭建了一套视频生成体验pipeline
1、prompt增强
体验页面使用 GLM-4(https://github.com/THUDM/GLM-4) 扩写提示词,扩写提示词模块会先识别语言,将中文翻译成英文,然后将简短的提示词扩写成更加详细的描述,来提升视频生成的精细度和稳定性。
sys_prompt = """You are part of a team of bots that creates videos. You work with an assistant bot that will draw anything you say in square brackets. For example , outputting " a beautiful morning in the woods with the sun peaking through the trees " will trigger your partner bot to output an video of a forest morning , as described. You will be prompted by people looking to create detailed , amazing videos. The way to accomplish this is to take their short prompts and make them extremely detailed and descriptive. There are a few rules to follow: When user inputs Chinese, you will first translated into English video description. You will only ever output a single video description per user request. When modifications are requested , you should not simply make the description longer . You should refactor the entire description to integrate the suggestions. Other times the user will not want modifications , but instead want a new image . In this case , you should ignore your previous conversation with the user. Video descriptions must have the same num of words as examples below. Extra words will be ignored. """
2、视频生成
在魔搭社区免费算力可完成CogVideoX-5B模型bf16精度的推理。
CogVideoX-5B已经支持使用 diffusers 推理,可以按照以下步骤进行推理。
环境依赖
# diffusers>=0.30.1 # transformers>=0.44.0 # accelerate>=0.33.0 (suggest install from source) # imageio-ffmpeg>=0.5.1 pip install --upgrade transformers accelerate diffusers imageio-ffmpeg
运行代码
import torch from diffusers import CogVideoXPipeline from diffusers.utils import export_to_video from modelscope import snapshot_download model_dir = snapshot_download("ZhipuAI/CogVideoX-5b") prompt = "A panda, dressed in a small, red jacket and a tiny hat, sits on a wooden stool in a serene bamboo forest. The panda's fluffy paws strum a miniature acoustic guitar, producing soft, melodic tunes. Nearby, a few other pandas gather, watching curiously and some clapping in rhythm. Sunlight filters through the tall bamboo, casting a gentle glow on the scene. The panda's face is expressive, showing concentration and joy as it plays. The background includes a small, flowing stream and vibrant green foliage, enhancing the peaceful and magical atmosphere of this unique musical performance." pipe = CogVideoXPipeline.from_pretrained( model_dir, torch_dtype=torch.bfloat16 ) pipe.enable_model_cpu_offload() pipe.vae.enable_tiling() video = pipe( prompt=prompt, num_videos_per_prompt=1, num_inference_steps=50, num_frames=49, guidance_scale=6, generator=torch.Generator(device="cuda").manual_seed(42), ).frames[0] export_to_video(video, "output.mp4", fps=8)
显存占用约为19G:
3、超分和插帧
使用 RIFE(https://github.com/hzwer/ECCV2022-RIFE) 模型来插帧,使用 Real-ESRGAN(https://github.com/xinntao/Real-ESRGAN) 模型来做超分(Super-Resolution)。注意:运动幅度较大时,插帧有时会影响视频效果。
超分+插帧后的视频
点击链接👇,即可跳转体验demo~
https://www.modelscope.cn/studios/ZhipuAI/CogVideoX-5b-demo?from=alizishequ__text