Skip to content

zinan92/AI-videos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI-Videos

从种子脸到成品视频,一条命令跑完 AI 虚拟人物换装 + 动作迁移全流程

Python 3.9+ RunningHub API License: MIT

in PNG 角色图 + PNG 服装图 + MP4 动作视频 → out MP4 成品视频 + JSON 运行日志


输入 / 输出 / 失败契约

in  角色图片 (PNG) + 服装参考图 (PNG, 可选) + 动作参考视频 (MP4)
out 换装后角色视频 (MP4) + 运行日志 (JSON)

fail RunningHub API key 无效或余额不足 → 启动时 RuntimeError 退出
fail Klein 换装失败 → 跳过换装,用原图继续生成视频
fail 可灵审查拦截 (L3+ 内容) → 任务返回空结果,exit code 1
fail RunningHub 任务超时 (>900s) → 抛出 TimeoutError
fail 上传文件失败 → 抛出 RuntimeError

Adapters: RunningHub API v2 (Klein 9B 换装 + Kling v2.6 动作迁移)


示例输出

$ python scripts/pipeline.py generate \
    --character seed_fullbody.png \
    --outfit outfit_bikini.png \
    --motion dance.mp4 \
    --outfit-desc "红色比基尼"

Checking account status...
  Balance: 342 RH coins

[Stage 0] Uploading assets...
  Uploading seed_fullbody.png...
  Uploaded: https://cdn.runninghub.cn/xxxxx...
  Uploading dance.mp4...
  Uploaded: https://cdn.runninghub.cn/xxxxx...

[Stage 2] Klein outfit change...
  Task 20260319xxxx: RUNNING (15s)
  Task 20260319xxxx: RUNNING (30s)
  Task 20260319xxxx: SUCCESS
  Outfit changed: output/run_1710000000/dressed.png

[Stage 3] Kling motion control video generation...
  Task 20260319yyyy: RUNNING (30s)
  Task 20260319yyyy: RUNNING (60s)
  Task 20260319yyyy: SUCCESS
  Video saved: output/run_1710000000/output.mp4

==================================================
Pipeline complete!
  Total cost: 25 RH coins
  Total time: 183s
  Output: output/run_1710000000/output.mp4
  Log: output/run_1710000000/run_log.json
==================================================

运行日志 (run_log.json) 包含每个 step 的 task_id、耗时、cost、输出路径。


架构

┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│  种子脸 (PNG) │────▶│  Klein 换装   │────▶│  换装后角色   │
└──────────────┘     │  (开源无审查)  │     └──────┬───────┘
                     └──────────────┘            │
                                                 ▼
┌──────────────┐                        ┌──────────────┐
│  动作参考视频  │───────────────────────▶│  可灵 v2.6    │
│  (MP4)       │                        │  动作迁移      │
└──────────────┘                        └──────┬───────┘
                                               │
                                               ▼
                                        ┌──────────────┐
                                        │  成品视频 MP4  │
                                        └──────────────┘

内部流程:上传素材 → Klein 双图换装 (可跳过) → 可灵动作迁移 → 下载结果 + 保存运行日志。


快速开始

# 1. 克隆
git clone https://github.com/zinan92/AI-videos.git && cd AI-videos

# 2. 安装依赖 (仅 requests)
pip install requests

# 3. 配置 API Key
cp config/runninghub_api.json.example config/runninghub_api.json
# 编辑填入 RunningHub API Key (币多多套餐)

# 4. 检查余额
python scripts/pipeline.py account

# 5. 放入素材
# 角色图 → assets/characters/
# 动作视频 → assets/motions/

# 6. 跑 pipeline
python scripts/pipeline.py generate \
  --character seed_fullbody.png \
  --outfit outfit_bikini.png \
  --motion dance.mp4 \
  --outfit-desc "红色比基尼"

功能一览

功能 说明 状态
Klein 换装 (L1~L4) 开源模型,支持多种服装级别,无审查 ✅ 已验证
可灵动作迁移 成本最低 (1~12 RH/次),人脸偏差可接受 ⚠️ 服装丢失
Pipeline CLI 一条命令跑完上传 → 换装 → 视频 → 下载 ✅ 可用
任务状态查询 按 task_id 查询 RunningHub 任务进度 ✅ 可用
账户余额查询 查看 RH 币余额 ✅ 可用
运行日志 每次 pipeline 自动保存 JSON 日志 ✅ 可用

测试结论速查

Klein 换装 -- 全部通过

SKU 内容 服装还原 人脸一致 RH币 耗时
D-01 L1 黑裙 20 100s
D-02 L2 吊带裙 13 63s
D-03 L3 比基尼 24 120s
D-04 L4 内衣 13 64s

视频模型对比 -- 核心瓶颈

维度 Kling v2.6 Wan2.1 LTX2.3
合规严格度 最严 (L3 拦截) 最松
服装保留
人脸一致性 ⚠️ 最好 ❌ 最差 ❌ 差
成本/次 1~12 RH 146~193 RH 83 RH
推荐度 ⭐⭐

核心发现: 换装没问题,视频是瓶颈。所有视频模型都无法保留输入图的服装。

完整测试数据见 config/test-report.jsonvideo-generation-workflow.md


CLI 用法

# 完整流程: 换装 + 视频生成
python scripts/pipeline.py generate \
  --character seed_fullbody.png \
  --outfit outfit_bikini.png \
  --motion dance.mp4 \
  --outfit-desc "红色比基尼"

# 跳过换装,直接图生视频
python scripts/pipeline.py generate \
  --character dressed_sexy.png \
  --motion dance.mp4 \
  --skip-outfit \
  --outfit-desc "黑色性感连衣裙"

# 查询任务状态
python scripts/pipeline.py status --task-id <task_id>

# 查看账户余额
python scripts/pipeline.py account

技术栈

层级 技术 用途
语言 Python 3.9+ Pipeline CLI
依赖 requests HTTP 请求 (唯一依赖)
平台 RunningHub API v2 统一模型调用网关
换装模型 Klein 9B 双图编辑换装 (开源, 无审查)
视频模型 Kling v2.6 动作迁移 (主力, 成本最低)

项目结构

AI-videos/
├── scripts/
│   ├── pipeline.py              # 端到端 pipeline CLI
│   └── runninghub_client.py     # RunningHub API 客户端 + workflow/app 注册表
├── config/
│   ├── runninghub_api.json.example  # API 配置模板
│   ├── test-report.json         # 完整测试报告 (机器可读)
│   └── test-matrix.json         # 测试矩阵数据
├── assets/
│   ├── characters/              # 角色图片 (git-ignored)
│   └── motions/                 # 动作视频 (git-ignored)
├── output/                      # 生成结果 (git-ignored)
├── video-generation-workflow.md # 12 步完整 SOP 文档
└── README.md

配置

变量 说明 必填
api_key RunningHub API Key (币多多套餐)
base_url RunningHub API 地址 否 (默认 runninghub.ai)

配置文件路径: config/runninghub_api.json


For AI Agents

Capability Contract

name: AI-videos
version: 0.1.0
capability: "AI 虚拟人物换装 + 动作迁移视频生成 pipeline"
cli_entry: python scripts/pipeline.py

input:
  character: PNG 图片 (角色全身照, 放入 assets/characters/)
  outfit: PNG 图片 (服装参考图, 放入 assets/characters/, 可选)
  motion: MP4 视频 (动作参考, 放入 assets/motions/)
  outfit_desc: string (服装文字描述, 用于 prompt)

output:
  video: MP4 (output/<run_id>/output.mp4)
  log: JSON (output/<run_id>/run_log.json, 含 cost/time/steps)

commands:
  generate:
    flags: [--character, --outfit, --motion, --outfit-desc, --skip-outfit]
    exit_code: 0=success, 1=failed
  status:
    flags: [--task-id]
    stdout: JSON {task_id, status, results}
  account:
    stdout: JSON {balance, ...}

dependencies:
  runtime: [python>=3.9, requests]
  external: [RunningHub API account (币多多套餐)]

failure_modes:
  - condition: "API key invalid or balance insufficient"
    behavior: "RuntimeError at startup"
  - condition: "content moderation block (L3+)"
    behavior: "empty result, exit code 1"
  - condition: "task timeout (>900s)"
    behavior: "TimeoutError raised"
  - condition: "Klein outfit step fails"
    behavior: "warns and continues with original image"

Agent 调用示例

import subprocess, json

# 端到端视频生成
result = subprocess.run(
    [
        "python", "scripts/pipeline.py", "generate",
        "--character", "seed_fullbody.png",
        "--outfit", "outfit_bikini.png",
        "--motion", "dance.mp4",
        "--outfit-desc", "红色比基尼",
    ],
    capture_output=True, text=True, cwd="/path/to/AI-videos"
)
# exit code 0 = success, 1 = failed
# output/<run_id>/run_log.json 包含完整运行记录

# 查询余额
acct = subprocess.run(
    ["python", "scripts/pipeline.py", "account"],
    capture_output=True, text=True, cwd="/path/to/AI-videos"
)
balance = json.loads(acct.stdout)

相关项目

项目 说明
videocut 录一次视频,自动出全平台内容
seedance-expert Seedance 2.0 视频导演 skill

License

MIT

About

AI 虚拟人物换装 + 动作迁移 pipeline。in PNG + MP4 → out 成品视频 MP4 + JSON 日志

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages