GitHub – text2cinemagraph/text2cinemagraph: Text2Cinemagraph: Text-Guided Synthesis of Eulerian Cinemagraphs [SIGGRAPH ASIA 2023]

1周前发布 4 00

Text2Cinemagraph: Text-Guided Synthesis of Eulerian Cinemagraphs [SIGGRAPH ASIA 2023] - text2cinemagraph/text2cinemagraph

所在地:
中国
语言:
zh
收录时间:
2025-10-06
其他站点:
GitHub – text2cinemagraph/text2cinemagraph: Text2Cinemagraph: Text-Guided Synthesis of Eulerian Cinemagraphs [SIGGRAPH ASIA 2023]GitHub – text2cinemagraph/text2cinemagraph: Text2Cinemagraph: Text-Guided Synthesis of Eulerian Cinemagraphs [SIGGRAPH ASIA 2023]

这是“TextGuided Synthesis of Eulerian Cinemagraphs”(SIGGRAPH ASIA 2023论文)的官方PyTorch实现,用于基于文本描述自动生成欧拉式动态照片(cinemagraphs),可处理包含想象元素和艺术风格的提示词,解决语义理解与运动生成的复杂性问题。

方法原理
通过Stable Diffusion生成一对像素对齐的图像:
艺术风格图像:还原提示词中的风格与外观细节;
自然风格孪生图像:简化布局与运动分析。
利用自然图像/视频数据集,对自然图像进行ODISE语义分割,预测合理运动;将运动转移至艺术图像,生成最终动态照片。

核心功能模块

1. 环境搭建
需执行以下步骤配置依赖:
克隆仓库:`git clone https://github.com/text2cinemagraph/artisticcinemagraph.git`;
创建conda环境:`conda create n t2c python=3.9`,激活后安装PyTorch 1.13.1、CUDA 11.6及相关库;
安装ODISE:`pip install git+https://github.com/NVlabs/ODISE.git`;
安装其他依赖:通过`requirements.txt`安装diffusers等库,解决可能的`ninja`错误(参考ODISE项目issue)。

2. 预训练模型下载
核心模型:通过`gdown`下载光流预测、文本引导光流预测、视频生成的预训练模型,解压后得到`checkpoints`文件夹;
Stable Diffusion模型:下载`sdv14fullema.ckpt`并放入指定目录;
diffusers模型:克隆`stablediffusionv14`仓库至`checkpoints`目录(需`git lfs`)。

3. 推理流程
支持全流程与分阶段生成,方便调整中间结果:
全流程推理:运行`python inference_t2c.py config configs/inference.yaml`,直接生成动态照片;
分阶段推理:通过`stage`参数分步骤生成:
`s1`:艺术风格图像;
`s2`:孪生自然图像;
`s3`:ODISE语义掩码;
`s4`:自注意力掩码(结合ODISE掩码);
`s5`:光流预测;
`s6`:最终动态照片;
文本引导方向控制:通过`use_hint`和`prompt`指定运动方向(如“河流从左到右流动”),生成符合文本描述的运动效果;
调优技巧:调整配置文件参数优化结果:
若艺术图像不满意,修改`prompt`或`seed`;
若ODISE掩码包含无关区域,调整`vocab`指定目标区域;
若自注意力掩码不准确,修改`n_clusters`(聚类数)或`threshold`(重叠阈值);
若运动速度或范围不合适,调整`n_frames`(帧数量)或`speed`(运动速度)。

4. 训练与数据准备
数据准备:
光流与视频数据:下载“Animating Pictures with Eulerian Motion Fields”数据集;
ODISE掩码:运行`gen_mask.py`生成自然图像的语义掩码;
文本引导方向数据:生成光流提示图,用于训练文本引导的光流模型;
艺术提示词:`dataset/prompts.txt`存储艺术风格提示词,`prompts_twin.txt`存储对应的自然风格编辑提示词。
训练步骤:
光流预测模型:训练预测自然图像光流的模型,结合文本条件(如“瀑布”“河流”类别的语义);
文本引导光流模型:训练基于文本方向提示的光流模型,输入图像、掩码和光流提示;
视频生成模型:两阶段训练,先使用真实光流训练,再使用光流预测模型的输出微调,生成动态帧。

5. 评估
生成验证集结果:使用`test_motion.py`预测光流,`test_video.py`生成动态照片;
计算FVD:通过`compute_fvd.py`计算生成视频与真实视频的Fréchet Video Distance(FVD_16或FVD_60),评估结果质量。

资源与其他信息
论文链接:[arXiv:2307.03190](https://arxiv.org/abs/2307.03190);
项目网站:[text2cinemagraph.github.io/website/](https://text2cinemagraph.github.io/website/);
许可证:采用MIT许可证;
仓库情况:截至当前有388个stars、46个forks,代码主要使用Python(99.8%)和Dockerfile(0.2%)。

相关导航

GitHub – Rudrabha/Wav2Lip: This repository contains the codes of “A Lip Sync Expert Is All You Need for Speech to Lip Generation In the Wild”, published at ACM Multimedia 2020. For HD commercial model, please try out Sync Labs

GitHub – Rudrabha/Wav2Lip: This repository contains the codes of “A Lip Sync Expert Is All You Need for Speech to Lip Generation In the Wild”, published at ACM Multimedia 2020. For HD commercial model, please try out Sync Labs

This repository contains the codes of "A Lip Sync Expert Is All You Need for Speech to Lip Generation In the Wild", published at ACM Multimedia 2020. For HD commercial model, please try out Sync Labs - GitHub - Rudrabha/Wav2Lip: This repository contains the codes of "A Lip Sync Expert Is All You Need for Speech to Lip Generation In the Wild", published at ACM Multimedia 2020. For HD commercial model, please try out Sync Labs

暂无评论

您必须登录才能参与评论!
立即登录
none
暂无评论...