上海集团网站制作,wordpress loop count,上海网站建设app,ceo是什么意思是什么职位在 生成式人工智能 中的文本生成模型和图像生成模型大行其道之后#xff0c;现在该是文本-视频模型大显身手的时候了#xff0c;这个列表中的新模型就是 pyramid-flow-sd3#xff0c;它是一个开源模型#xff0c;用于从文本或图像生成长达 10 秒的视频#xf… 在 生成式人工智能 中的文本生成模型和图像生成模型大行其道之后现在该是文本-视频模型大显身手的时候了这个列表中的新模型就是 pyramid-flow-sd3它是一个开源模型用于从文本或图像生成长达 10 秒的视频而且是 24fps 的视频
该模型非常重要的点
可以免费使用并且开源因此本地用户也可以使用代码使用该模型
生成较长的人工智能视频最长 10 秒是其他模型5 秒的两倍。
它既能生成文本视频也能生成图像视频。
它是在开源数据集上训练的。
该模型可在 HuggingFace 上下载并可使用 python
了解金字塔流
随着 pyramid-flow-sd3 的发布该模型所基于的团队也引入了一个新概念即金字塔流Pyramid Flow。 从官方 Github 代码库中摘录如下
Pyramid Flow, a training-efficient Autoregressive Video Generation method based on Flow Matching.
让我们来解释一下这些行话
自回归视频生成技术
自回归视频生成技术是一种按顺序生成视频每一帧画面的技术每一帧新画面都会根据之前生成的画面进行预测。
这种方法可确保视频中的时间关系得以保留从而使最终输出更加逼真。 该模型可学习理解运动和变化是如何随时间发生的这对于创建流畅、可信的视频序列至关重要。
流匹配
流匹配是一种用于将生成数据的分布与真实数据的分布相一致的方法。 它涉及对数据点在本例中为视频帧如何随时间从一种状态过渡到另一种状态进行建模。
通俗地说 流匹配是一种帮助计算机学习如何使生成的视频看起来真实的技术。 它的重点是理解视频的一帧应该如何变化到下一帧。 通过了解这些变化该模型可以制作出看起来自然可信的视频就像现实生活中的运动一样。
Pyramid Flow金字塔流
Pyramid Flow金字塔流指的是视频生成中的一种分层方法可在多个分辨率下运行类似于金字塔结构。
这种方法允许模型从较低分辨率的表征开始逐步细化为较高分辨率的表征。 通过这种方式处理数据Pyramid Flow 提高了计算效率并保持了帧间的连续性这对于生成逼真的视频至关重要。
Pyramid Flow 与流量匹配有什么关系
Pyramid Flow 使用流量匹配来改进视频生成。
当模型创建视频时它会使用 流匹配 来确保金字塔的每一步或层都能顺利过渡到下一步。 这意味着从模糊版本到清晰版本它都能保持一切看起来真实流畅。
Pyramid Flow is like building a video step by step, while Flow Matching makes sure that every step looks good and flows well into the next one.
rain1011/pyramid-flow-sd3
这是 Pyramid Flow 的官方资源库Pyramid Flow 是一种基于流匹配Flow Matching的训练效率高的自回归视频生成方法。 通过仅在开源数据集上进行训练它能以 768p 分辨率和 24 FPS 的速度生成高质量的 10 秒视频并自然支持图像到视频的生成。
安装
我们建议使用 conda 设置环境。 代码库目前使用 Python 3.8.10 和 PyTorch 2.1.2我们正在积极努力支持更广泛的版本。
git clone https://github.com/jy0205/Pyramid-Flow
cd Pyramid-Flow# create env using conda
conda create -n pyramid python3.8.10
conda activate pyramid
pip install -r requirements.txt
然后您可以直接从 Huggingface 下载模型。 我们提供 768p 和 384p 两种视频生成的模型检查点。 384p 检查点支持以 24FPS 的速度生成 5 秒钟的视频而 768p 检查点支持以 24FPS 的速度生成长达 10 秒钟的视频。
from huggingface_hub import snapshot_downloadmodel_path PATH # The local directory to save downloaded checkpoint
snapshot_download(rain1011/pyramid-flow-sd3, local_dirmodel_path, local_dir_use_symlinksFalse, repo_typemodel)
使用
要使用我们的模型请按照此链接中的 video_generation_demo.ipynb 中的推理代码进行操作。 我们将其进一步简化为以下两个步骤。 首先加载下载的模型
import torch
from PIL import Image
from pyramid_dit import PyramidDiTForVideoGeneration
from diffusers.utils import load_image, export_to_videotorch.cuda.set_device(0)
model_dtype, torch_dtype bf16, torch.bfloat16 # Use bf16 (not support fp16 yet)model PyramidDiTForVideoGeneration(PATH, # The downloaded checkpoint dirmodel_dtype,model_variantdiffusion_transformer_768p, # diffusion_transformer_384p
)model.vae.to(cuda)
model.dit.to(cuda)
model.text_encoder.to(cuda)
model.vae.enable_tiling()
然后您可以尝试根据自己的提示将文字转换成视频
prompt A movie trailer featuring the adventures of the 30 year old space man wearing a red wool knitted motorcycle helmet, blue sky, salt desert, cinematic style, shot on 35mm film, vivid colorswith torch.no_grad(), torch.cuda.amp.autocast(enabledTrue, dtypetorch_dtype):frames model.generate(promptprompt,num_inference_steps[20, 20, 20],video_num_inference_steps[10, 10, 10],height768, width1280,temp16, # temp16: 5s, temp31: 10sguidance_scale9.0, # The guidance for the first frame, set it to 7 for 384p variantvideo_guidance_scale5.0, # The guidance for the other video latentoutput_typepil,save_memoryTrue, # If you have enough GPU memory, set it to False to improve vae decoding speed)export_to_video(frames, ./text_to_video_sample.mp4, fps24)
作为一个自回归模型我们的模型还支持以文本为条件的图像到视频的生成
image Image.open(assets/the_great_wall.jpg).convert(RGB).resize((1280, 768))
prompt FPV flying over the Great Wallwith torch.no_grad(), torch.cuda.amp.autocast(enabledTrue, dtypetorch_dtype):frames model.generate_i2v(promptprompt,input_imageimage,num_inference_steps[10, 10, 10],temp16,video_guidance_scale4.0,output_typepil,save_memoryTrue, # If you have enough GPU memory, set it to False to improve vae decoding speed)export_to_video(frames, ./image_to_video_sample.mp4, fps24)
通过添加 cpu_offloadingTrue 参数我们还支持 CPU 卸载以便在 GPU 内存不足 12GB 的情况下进行推理。 该功能由 Ednaordinary 提供详情请参见 #23。
使用技巧
guidance_scale 参数控制视觉质量。 我们建议在文本到视频生成过程中对 768p 检查点使用 [7, 9] 以内的指导对 384p 检查点使用 7 以内的指导。视频引导尺度video_guidance_scale参数用于控制运动。 数值越大动态程度越高自回归生成的劣化程度也就越低而数值越小视频就越稳定。对于 10 秒钟的视频生成我们建议使用 7 级指导等级和 5 级视频指导等级。
最后
自今年上半年图生视频的svd开源以后越来越多的研究者都在尝试复现Sora模型其中企业闭源的模型有不少如MiniMax和Luma Dream Machine等但终于开源社区也迎来了属于自己的文生图模型——CogVideoX。我觉得 Pyramid Flow 的出现也让我们更相信研究的方向是正确的同时需要更多的实验和实践。吾生也有涯而学也无涯以有涯随无涯。