当前位置: 首页 > news >正文

Hunyuan-GameCraft:基于混合历史条件的高动态交互游戏视频生成

在这里插入图片描述

摘要

基于扩散模型和可控视频生成技术的最新进展,已经能够实现高质量且时序连贯的视频合成,为沉浸式交互游戏体验奠定了基础。然而,当前方法在动态性、物理真实性、长期一致性效率方面仍存在局限,制约了多样化游戏视频的生成能力。针对这些不足,我们提出了Hunyuan-GameCraft框架,专为游戏环境中的高动态交互视频生成而设计。

为实现细粒度动作控制,我们将标准键盘鼠标输入统一映射至共享相机表征空间,实现各类镜头与移动操作的平滑插值。通过提出的混合历史条件训练策略,模型能以自回归方式扩展视频序列,同时保持游戏场景信息。此外,为提升推理效率和可玩性,我们采用模型蒸馏技术降低计算开销,在长时序中保持一致性,使其适用于复杂交互环境的实时部署。

模型在超100款3A游戏的百万级游戏实录数据集上预训练,确保覆盖广度和多样性,再经过精细标注的合成数据集微调以提升精度控制。经筛选的游戏场景数据显著提升了视觉保真度、真实感和动作可控性。大量实验表明,Hunyuan-GameCraft在交互游戏视频生成的拟真度与可玩性上显著超越现有模型。

整体架构

image

给定参考图像及对应提示词、键盘或鼠标信号,我们将这些选项映射到连续的相机空间。随后设计一个轻量级动作编码器,对输入的相机轨迹进行编码。动作与图像特征在分块化后相加。针对长视频扩展,我们设计了可变掩码指示器,其中1和0分别代表历史帧与待预测帧。

📜 要求

  • 需要支持 CUDA 的 NVIDIA GPU
    • 该模型在配备 8 块 GPU 的机器上测试通过
    • 最低配置:最低需要 24GB 显存,但运行速度极慢
    • 推荐配置:建议使用 80GB 显存的 GPU 以获得更优生成质量
  • 测试操作系统:Linux

🛠️ 依赖与安装

首先克隆代码仓库:

git clone https://github.com/Tencent-Hunyuan/Hunyuan-GameCraft-1.0.git
cd Hunyuan-GameCraft-1.0

Linux 安装指南

我们推荐使用 CUDA 12.4 版本进行手动安装。

Conda 的安装说明可参考此链接。

# 1. Create conda environment
conda create -n HYGameCraft python==3.10# 2. Activate the environment
conda activate HYGameCraft# 3. Install PyTorch and other dependencies using conda
conda install pytorch==2.5.1 torchvision==0.20.0 torchaudio==2.5.1 pytorch-cuda=12.4 -c pytorch -c nvidia# 4. Install pip dependencies
python -m pip install -r requirements.txt
# 5. Install flash attention v2 for acceleration (requires CUDA 11.8 or above)
python -m pip install ninja
python -m pip install git+https://github.com/Dao-AILab/flash-attention.git@v2.6.3

此外,您还可以使用HunyuanVideo的Docker镜像。使用以下命令拉取并运行该Docker镜像。

# For CUDA 12.4 (updated to avoid float point exception)
docker pull hunyuanvideo/hunyuanvideo:cuda_12
docker run -itd --gpus all --init --net=host --uts=host --ipc=host --name hunyuanvideo --security-opt=seccomp=unconfined --ulimit=stack=67108864 --ulimit=memlock=-1 --privileged hunyuanvideo/hunyuanvideo:cuda_12
pip install diffusers==0.34.0 transformers==4.54.1

🚀 多GPU并行推理

例如,要使用8个GPU生成视频,可使用以下命令。其中--action-list w s d a模拟键盘操控信号,帮助生成对应内容的视频。--action-speed-list 0.2 0.2 0.2 0.2表示位移距离,可替换为0至3之间的任意值,注意action-speed-list的长度必须与action-list保持一致:

#!/bin/bash
JOBS_DIR=$(dirname $(dirname "$0"))
export PYTHONPATH=${JOBS_DIR}:$PYTHONPATH
export MODEL_BASE="weights/stdmodels"
checkpoint_path="weights/gamecraft_models/mp_rank_00_model_states.pt"current_time=$(date "+%Y.%m.%d-%H.%M.%S")
modelname='Tencent_hunyuanGameCraft_720P'torchrun --nnodes=1 --nproc_per_node=8 --master_port 29605 hymm_sp/sample_batch.py \--image-path "asset/village.png" \--prompt "A charming medieval village with cobblestone streets, thatched-roof houses, and vibrant flower gardens under a bright blue sky." \--add-pos-prompt "Realistic, High-quality." \--add-neg-prompt "overexposed, low quality, deformation, a poor composition, bad hands, bad teeth, bad eyes, bad limbs, distortion, blurring, text, subtitles, static, picture, black border." \--ckpt ${checkpoint_path} \--video-size 704 1216 \--cfg-scale 2.0 \--image-start \--action-list w s d a \--action-speed-list 0.2 0.2 0.2 0.2 \--seed 250160 \--infer-steps 50 \--flow-shift-eval-video 5.0 \--save-path './results/'

此外,我们支持FP8优化和SageAttn。要启用FP8,只需在命令中添加--use-fp8选项。
并通过以下命令安装SageAttention:

git clone https://github.com/thu-ml/SageAttention.git
cd SageAttention 
python setup.py install  # or pip install -e .

我们还提供加速模型,您可以使用以下命令:

#!/bin/bash
JOBS_DIR=$(dirname $(dirname "$0"))
export PYTHONPATH=${JOBS_DIR}:$PYTHONPATH
export MODEL_BASE="weights/stdmodels"
checkpoint_path="weights/gamecraft_models/mp_rank_00_model_states_distill.pt"current_time=$(date "+%Y.%m.%d-%H.%M.%S")
modelname='Tencent_hunyuanGameCraft_720P'torchrun --nnodes=1 --nproc_per_node=8 --master_port 29605 hymm_sp/sample_batch.py \--image-path "asset/village.png" \--prompt "A charming medieval village with cobblestone streets, thatched-roof houses, and vibrant flower gardens under a bright blue sky." \--add-neg-prompt "overexposed, low quality, deformation, a poor composition, bad hands, bad teeth, bad eyes, bad limbs, distortion, blurring, text, subtitles, static, picture, black border." \--ckpt ${checkpoint_path} \--video-size 704 1216 \--cfg-scale 1.0 \--image-start \--action-list w s d a \--action-speed-list 0.2 0.2 0.2 0.2 \--seed 250160 \--infer-steps 8 \--use-fp8 \--flow-shift-eval-video 5.0 \--save-path './results_distill/'

🔑 低显存单GPU推理

例如,要使用低显存(超过24GB)的1个GPU生成视频,可以使用以下命令:

#!/bin/bash
JOBS_DIR=$(dirname $(dirname "$0"))
export PYTHONPATH=${JOBS_DIR}:$PYTHONPATH
export MODEL_BASE="weights/stdmodels"
checkpoint_path="weights/gamecraft_models/mp_rank_00_model_states.pt"current_time=$(date "+%Y.%m.%d-%H.%M.%S")
modelname='Tencent_hunyuanGameCraft_720P'# disable sp and cpu offload
export DISABLE_SP=1
export CPU_OFFLOAD=1torchrun --nnodes=1 --nproc_per_node=1 --master_port 29605 hymm_sp/sample_batch.py \--image-path "asset/village.png" \--prompt "A charming medieval village with cobblestone streets, thatched-roof houses, and vibrant flower gardens under a bright blue sky." \--add-neg-prompt "overexposed, low quality, deformation, a poor composition, bad hands, bad teeth, bad eyes, bad limbs, distortion, blurring, text, subtitles, static, picture, black border." \--ckpt ${checkpoint_path} \--video-size 704 1216 \--cfg-scale 2.0 \--image-start \--action-list w a d s \--action-speed-list 0.2 0.2 0.2 0.2 \--seed 250160 \--sample-n-frames 33 \--infer-steps 50 \--flow-shift-eval-video 5.0 \--cpu-offload \--use-fp8 \--save-path './results/'
http://www.dtcms.com/a/335413.html

相关文章:

  • 健身房预约系统SSM+Mybatis实现(三、校验 +页面完善+头像上传)
  • 基于Node.js+Express的电商管理平台的设计与实现/基于vue的网上购物商城的设计与实现/基于Node.js+Express的在线销售系统
  • Visual Studio Code 基础设置指南
  • iSCSI服务配置全指南(含服务器与客户端)
  • 12.web api 3
  • Docker入门:容器化技术的第一堂课
  • Chrome插件开发实战:todoList 插件
  • IP 分片和组装的具体过程
  • 二分查找(Binary Search)
  • 力扣刷题904——水果成篮
  • Java开发MCP服务器
  • 云计算-K8s 实战:Pod、安全上下文、HPA 、CRD、网络策略、亲和性等功能配置实操指南
  • 大模型提示词(Prompt)终极指南:从原理到实战,让AI输出质量提升300%
  • PS复刻八一电影制片厂经典片头
  • Pandas 2.0 + Arrow 加速、Dask vs Ray、Plotly 可视化:数据分析的未来
  • Centos中内存CPU硬盘的查询
  • MySQL库表操作
  • 基于多Agent的AFSIM复杂场景脚本生成技术(使用Claude Code)
  • 【牛客刷题】 计算01串通过相邻交换变成目标串的最大交换次数
  • 【深度学习-基础知识】单机多卡和多机多卡训练
  • 【Linux系统】动静态库的制作
  • 接口参数校验工具类ValidationParamUtils,让参数校验从“繁琐、重复”变得“省事、简单”!
  • Python文本过滤与清理完全指南:从基础到高级工程实践
  • go基础学习笔记
  • RAG 分块中表格填补简明示例:Markdown、HTML、Excel、Doc
  • C++核心语言元素与构建块全解析:从语法规范到高效设计
  • 编译器生成的合成访问方法(Synthetic Accessor Method)
  • TensorRT-LLM.V1.1.0rc0:在无 GitHub 访问权限的服务器上编译 TensorRT-LLM 的完整实践
  • Linux容器基石:LXC核心概念与实践指南
  • Flink Stream API核心概念继承体系