chyinan/uvr-headless-runner
关于
Production-ready UVR5 CLI & Docker image. Run SOTA separation models (Roformer, SCNet, MDX, Demucs, VR Architecture) on headless GPU servers without dependency hell.
系统与基础设施可以做什么
- 🎯 GUI-Identical - Exactly replicates UVR GUI behavior
- ⚡ GPU Accelerated - NVIDIA CUDA & AMD DirectML support
- 🔧 Zero Config - Auto-detect model parameters
- 📦 Batch Ready - Perfect for automation & pipelines
实测星标增长
- 24小时
- 0
- 7天
- -1
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README_CN.md
原文
🎧 从任意音频中分离人声、乐器、鼓、贝斯等
基于 UVR 的命令行音频分离工具
🇨🇳 中文 | 🇬🇧 English | 🐳 Docker
✨ 功能特性
🎸 MDX-Net 运行器
|
🥁 Demucs 运行器
|
🎤 VR 运行器
|
🚀 亮点
| 特性 | 说明 |
|---|---|
| 🎯 GUI 行为一致 | 完全复制 UVR GUI 的行为逻辑 |
| ⚡ GPU 加速 | 支持 NVIDIA CUDA 和 AMD DirectML |
| 🔧 零配置 | 自动检测模型参数 |
| 📦 批量处理 | 适合自动化和流水线 |
| 🎚️ 位深控制 | 16/24/32-bit PCM,32/64-bit 浮点 |
| 📥 自动下载 | 官方 UVR 模型注册表 + 自动下载 |
| 🛡️ 健壮错误处理 | GPU 回退、重试、模糊匹配 |
| 🔗 统一 CLI | uvr mdx / uvr demucs / uvr vr — 一条命令搞定 |
| 📦 PyPI 发布 | pip install uvr-headless-runner — 即装即用 |
📖 设计理念
本项目是 Ultimate Vocal Remover 的无头自动化层。
它不会重新实现任何分离逻辑。
它完全复制 UVR GUI 的行为 —— 包括模型加载、参数回退和自动检测。✅ 如果模型在 UVR GUI 中能用,这里就能用 —— 无需额外配置。
🤔 为什么选择这个工具?
大多数命令行分离工具将你限制在预定义的模型列表中。作为高级用户,你需要更多。
🎨 完全自定义模型直接使用你的 |
🖥️ 无头 & 远程就绪专为 Web 服务和自动化脚本 |
👥 用户至上由音频爱好者设计, |
📋 系统要求
| 组件 | 要求 |
|---|---|
| Python | 3.9.x(3.10+ 未完全测试) |
| GPU | NVIDIA CUDA 或 AMD DirectML (可选) |
| 系统 | Windows / Linux / macOS |
🔧 安装
🚀 方式一:pip install 从 PyPI 安装(推荐)
# 从 PyPI 安装
pip install uvr-headless-runner
# GPU 支持 (NVIDIA)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
# ONNX GPU(可选)
pip install onnxruntime-gpu
安装后即可使用 uvr 统一命令 — 无需克隆仓库!
uvr mdx -m "UVR-MDX-NET Inst HQ 3" -i song.wav -o output/
uvr demucs -m htdemucs -i song.wav -o output/
uvr vr -m "UVR-De-Echo-Normal" -i song.wav -o output/
📦 方式二:Poetry(从源码安装)
# 克隆仓库
git clone https://github.com/chyinan/uvr-headless-runner.git
cd uvr-headless-runner
# 安装依赖
poetry install
# GPU 支持 (NVIDIA)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
# ONNX GPU(可选)
pip install onnxruntime-gpu
📦 方式三:pip + venv(从源码安装)
# 克隆仓库
git clone https://github.com/chyinan/uvr-headless-runner.git
cd uvr-headless-runner
# 创建虚拟环境
python -m venv venv
source venv/bin/activate # Linux/macOS
# venv\Scripts\activate # Windows
# 安装依赖
pip install -r requirements.txt
# GPU 支持 (NVIDIA)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
🔴 AMD 显卡(DirectML)
# 安装 DirectML 支持
pip install torch-directml
# 使用 --directml 参数
python mdx_headless_runner.py -m model.ckpt -i song.wav -o output/ --directml
⚠️ DirectML 为实验性功能,推荐使用 NVIDIA CUDA 以获得最佳性能。
✅ 验证安装(仅限原生 Python 安装)
python -c "import torch; print(f'PyTorch: {torch.__version__}'); print(f'CUDA: {torch.cuda.is_available()}')"
💡 如果使用 Docker,请跳过此步骤 - 容器已包含所有依赖。
🐳 方式四:Docker Hub(无需构建!)
最快捷的方式 - 直接拉取运行!
# 从 Docker Hub 拉取预构建镜像
docker pull chyinan/uvr-headless-runner:latest
# 直接运行(GPU 模式)
docker run --rm --gpus all \
-v ~/.uvr_models:/models \
-v $(pwd):/data \
chyinan/uvr-headless-runner:latest \
uvr-mdx -m "UVR-MDX-NET Inst HQ 3" -i /data/song.wav -o /data/output/
# 直接运行(CPU 模式)
docker run --rm \
-v ~/.uvr_models:/models \
-v $(pwd):/data \
chyinan/uvr-headless-runner:latest \
uvr-mdx -m "UVR-MDX-NET Inst HQ 3" -i /data/song.wav -o /data/output/ --cpu
或安装 CLI 包装器获得原生体验:
# 一键安装(自动检测 GPU)
./docker/install.sh # Linux/macOS
.\docker\install.ps1 # Windows
# 然后像原生命令一样使用
uvr-mdx -m "UVR-MDX-NET Inst HQ 3" -i song.wav -o output/
uvr-demucs -m htdemucs -i song.wav -o output/
uvr-vr -m "UVR-De-Echo-Normal" -i song.wav -o output/
🎼 快速开始
统一 CLI(pip install / Docker 均可用)
通过 pip install uvr-headless-runner 或 Docker 安装后,即可使用简短命令:
# MDX-Net / Roformer 分离
uvr mdx -m "UVR-MDX-NET Inst HQ 3" -i song.wav -o output/ --gpu
# Demucs 分离
uvr demucs -m htdemucs -i song.wav -o output/ --gpu
# VR Architecture 分离
uvr vr -m "UVR-De-Echo-Normal" -i song.wav -o output/ --gpu
# 列出所有可用模型
uvr list all
# 下载模型
uvr download "UVR-MDX-NET Inst HQ 3" --arch mdx
# 查看系统信息
uvr info
💡 也可以使用独立命令:
uvr-mdx、uvr-demucs、uvr-vr
MDX-Net / Roformer / SCNet
# 基本分离
python mdx_headless_runner.py -m "model.ckpt" -i "song.flac" -o "output/" --gpu
# 只输出人声(24-bit)
python mdx_headless_runner.py -m "model.ckpt" -i "song.flac" -o "output/" --gpu --vocals-only --wav-type PCM_24
Demucs
# 输出全部 4 轨
python demucs_headless_runner.py --model htdemucs --input "song.flac" --output "output/" --gpu
# 只输出人声
python demucs_headless_runner.py --model htdemucs --input "song.flac" --output "output/" --gpu --stem Vocals --primary-only
VR Architecture
# 基本分离(模型在数据库中)
python vr_headless_runner.py -m "model.pth" -i "song.flac" -o "output/" --gpu
# 自定义模型(不在数据库中)
python vr_headless_runner.py -m "model.pth" -i "song.flac" -o "output/" --gpu \
--param 4band_v3 --primary-stem Vocals
📥 模型下载中心
所有运行器现在都支持从官方 UVR 源自动下载模型 —— 就像 GUI 一样!
列出可用模型
# 列出所有 MDX-Net 模型
python mdx_headless_runner.py --list
# 只列出已安装的模型
python mdx_headless_runner.py --list-installed
# 列出未下载的模型
python mdx_headless_runner.py --list-uninstalled
# Demucs 和 VR 也一样
python demucs_headless_runner.py --list
python vr_headless_runner.py --list
下载模型
# 下载指定模型(不运行推理)
python mdx_headless_runner.py --download "UVR-MDX-NET Inst HQ 3"
python demucs_headless_runner.py --download "htdemucs_ft"
python vr_headless_runner.py --download "UVR-De-Echo-Normal by FoxJoy"
推理时自动下载
# 直接使用模型名 - 如果未安装会自动下载!
python mdx_headless_runner.py -m "UVR-MDX-NET Inst HQ 3" -i "song.flac" -o "output/" --gpu
# Demucs 模型也支持自动下载
python demucs_headless_runner.py --model htdemucs_ft --input "song.flac" --output "output/" --gpu
模型信息 & 模糊匹配
# 获取模型详细信息
python mdx_headless_runner.py --model-info "UVR-MDX-NET Inst HQ 3"
# 拼写错误?给你建议!
python mdx_headless_runner.py --model-info "UVR-MDX Inst HQ"
# 输出: Did you mean: UVR-MDX-NET Inst HQ 1, UVR-MDX-NET Inst HQ 2, ...
功能特性
| 功能 | 说明 |
|---|---|
| 🌐 官方注册表 | 同步 UVR 官方模型列表 |
| 🔄 断点续传 | 中断的下载可以恢复 |
| ⏱️ 指数退避重试 | 网络错误自动重试 |
| 💾 磁盘空间检查 | 下载前预检可用空间 |
| 🔍 模糊匹配 | 拼写错误时建议相似模型名 |
| ✅ 完整性检查 | 验证下载文件 |
🛡️ 错误处理 & GPU 回退
所有运行器都包含健壮的错误处理,支持自动 GPU 转 CPU 回退:
# 如果 GPU 显存不足,自动回退到 CPU
python mdx_headless_runner.py -m "model.ckpt" -i "song.flac" -o "output/" --gpu
# GPU 错误时的输出:
# ============================================================
# ERROR: GPU memory exhausted
# ============================================================
# Suggestion: Try: (1) Use --cpu flag, (2) Reduce --batch-size...
#
# Attempting to fall back to CPU mode...
错误消息
错误现在包含清晰的解释和建议:
| 之前 | 之后 |
|---|---|
FileNotFoundError |
Audio file not found: song.wav |
CUDA out of memory |
GPU memory exhausted. Try: --cpu or reduce --batch-size |
Model not found |
Model 'xyz' not found. Did you mean: UVR-MDX-NET...? |
📊 CLI 进度显示
所有运行器都配备 专业的 CLI 进度系统,提供实时反馈:
╭──────────────────────────────────────────────────────────────────────────╮
│ UVR 音频分离 │
├──────────────────────────────────────────────────────────────────────────┤
│ 模型 │ UVR-MDX-NET Inst HQ 3 │
│ 输入 │ song.flac │
│ 输出 │ ./output/ │
│ 设备 │ CUDA:0 │
│ 架构 │ MDX-Net │
╰──────────────────────────────────────────────────────────────────────────╯
⠹ 正在下载模型: UVR-MDX-NET Inst HQ 3
████████████████████████████████████████ 100% • 245.3 MB • 12.5 MB/s • 0:00:00
✓ 模型下载完成
⠹ 正在推理
████████████████░░░░░░░░░░░░░░░░░░░░░░░░ 42% • 0:01:23 • 0:01:52
✓ 推理完成
╭──────────────────────────────────────────────────────────────────────────╮
│ ✓ 处理完成,耗时 3:15 │
╰──────────────────────────────────────────────────────────────────────────╯
输出文件:
• output/song_(Vocals).wav
• output/song_(Instrumental).wav
功能特性
| 功能 | 说明 |
|---|---|
| 📥 下载进度 | 实时显示下载速度、剩余时间和传输统计 |
| 🎯 推理进度 | 基于分块的音频处理进度跟踪 |
| ⏱️ 时间估算 | 显示已用时间和剩余时间 (ETA) |
| 🎨 精美输出 | 使用 rich 库的精美终端 UI |
| 🐳 Docker 兼容 | 在容器内无缝运行 |
| 📉 优雅降级 | 如果 rich 不可用则回退到基础输出 |
进度库支持
系统自动选择最佳可用库:
rich(首选) - 带颜色的全功能进度条tqdm(备选) - 标准进度条- 基础 (无依赖) - 简单文本进度
安装 rich 以获得最佳体验:
pip install rich
静默模式
为脚本禁用进度输出:
python mdx_headless_runner.py -m model.ckpt -i song.wav -o output/ --quiet
🎛️ MDX-Net 运行器
命令行参数
| 参数 | 简写 | 默认值 | 说明 |
|---|---|---|---|
--model |
-m |
必需 | 模型文件路径 (.ckpt/.onnx) |
--input |
-i |
必需 | 输入音频文件 |
--output |
-o |
必需 | 输出目录 |
--gpu |
自动 | 使用 NVIDIA CUDA | |
--directml |
使用 AMD DirectML | ||
--overlap |
0.25 |
MDX 重叠率 (0.25-0.99) | |
--overlap-mdxc |
2 |
MDX-C/Roformer 重叠 (2-50) | |
--wav-type |
PCM_24 |
输出格式:PCM_16/24/32, FLOAT, DOUBLE | |
--vocals-only |
只输出人声 | ||
--instrumental-only |
只输出伴奏 |
📋 全部参数
| 参数 | 说明 |
|---|---|
--name -n |
输出文件名 |
--json |
模型 JSON 配置 |
--cpu |
强制 CPU |
--device -d |
GPU 设备 ID |
--segment-size |
段大小(默认:256) |
--batch-size |
批次大小(默认:1) |
--primary-only |
只保存 primary stem |
--secondary-only |
只保存 secondary stem |
--stem |
MDX-C stem 选择 |
--quiet -q |
静默模式 |
使用示例
# Roformer 模型 + 自定义重叠
python mdx_headless_runner.py \
-m "MDX23C-8KFFT-InstVoc_HQ.ckpt" \
-i "song.flac" -o "output/" \
--gpu --overlap-mdxc 8
# 32-bit 浮点输出
python mdx_headless_runner.py \
-m "model.ckpt" -i "song.flac" -o "output/" \
--gpu --wav-type FLOAT
🥁 Demucs 运行器
支持的模型
| 模型 | 版本 | 轨道 | 质量 |
|---|---|---|---|
htdemucs |
v4 | 4 | ⭐⭐⭐ |
htdemucs_ft |
v4 | 4 | ⭐⭐⭐⭐ 精调版 |
htdemucs_6s |
v4 | 6 | ⭐⭐⭐⭐ +吉他/钢琴 |
hdemucs_mmi |
v4 | 4 | ⭐⭐⭐ |
mdx_extra_q |
v3 | 4 | ⭐⭐⭐ |
命令行参数
| 参数 | 简写 | 默认值 | 说明 |
|---|---|---|---|
--model |
-m |
必需 | 模型名称或路径 |
--input |
-i |
必需 | 输入音频文件 |
--output |
-o |
必需 | 输出目录 |
--gpu |
自动 | 使用 NVIDIA CUDA | |
--segment |
Default | 分段大小 (1-100+) | |
--shifts |
2 |
时间偏移次数 | |
--stem |
Vocals/Drums/Bass/Other/Guitar/Piano | ||
--wav-type |
PCM_24 |
输出位深 | |
--primary-only |
只输出 primary stem |
Stem 选择
| GUI 操作 | CLI 命令 |
|---|---|
| 全部轨道 | (不指定 --stem) |
| 只要人声 | --stem Vocals --primary-only |
| 只要伴奏 | --stem Vocals --secondary-only |
使用示例
# 6 轨分离
python demucs_headless_runner.py \
--model htdemucs_6s \
--input "song.flac" --output "output/" \
--gpu
# 高质量 + 自定义 segment
python demucs_headless_runner.py \
--model htdemucs_ft \
--input "song.flac" --output "output/" \
--gpu --segment 85
🎤 VR Architecture 运行器
命令行参数
| 参数 | 简写 | 默认值 | 说明 |
|---|---|---|---|
--model |
-m |
必需 | 模型文件路径 (.pth) |
--input |
-i |
必需 | 输入音频文件 |
--output |
-o |
必需 | 输出目录 |
--gpu |
自动 | 使用 NVIDIA CUDA | |
--directml |
使用 AMD DirectML | ||
--window-size |
512 |
窗口大小 (320/512/1024) | |
--aggression |
5 |
激进度设置 (0-50+) | |
--wav-type |
PCM_16 |
输出格式:PCM_16/24/32, FLOAT, DOUBLE | |
--primary-only |
只输出 primary stem | ||
--secondary-only |
只输出 secondary stem |
📋 全部参数
| 参数 | 说明 |
|---|---|
--name -n |
输出文件名 |
--param |
模型参数名(如 4band_v3) |
--primary-stem |
Primary stem 名称(Vocals/Instrumental) |
--nout |
VR 5.1 nout 参数 |
--nout-lstm |
VR 5.1 nout_lstm 参数 |
--cpu |
强制 CPU |
--device -d |
GPU 设备 ID |
--batch-size |
批次大小(默认:1) |
--tta |
启用 Test-Time Augmentation |
--post-process |
启用后处理 |
--post-process-threshold |
后处理阈值(默认:0.2) |
--high-end-process |
启用高端镜像处理 |
--list-params |
列出可用的模型参数 |
模型参数
当模型哈希不在数据库中时,需要手动提供参数:
# 列出可用参数
python vr_headless_runner.py --list-params
# 使用自定义参数
python vr_headless_runner.py -m "model.pth" -i "song.flac" -o "output/" \
--param 4band_v3 --primary-stem Vocals
# VR 5.1 模型指定 nout/nout_lstm
python vr_headless_runner.py -m "model.pth" -i "song.flac" -o "output/" \
--param 4band_v3 --primary-stem Vocals --nout 48 --nout-lstm 128
使用示例
# 高质量 + TTA
python vr_headless_runner.py \
-m "UVR-MDX-NET-Voc_FT.pth" \
-i "song.flac" -o "output/" \
--gpu --tta --window-size 1024
# 高激进度分离
python vr_headless_runner.py \
-m "model.pth" -i "song.flac" -o "output/" \
--gpu --aggression 15 --post-process
# 24-bit 输出
python vr_headless_runner.py \
-m "model.pth" -i "song.flac" -o "output/" \
--gpu --wav-type PCM_24
📁 输出结构
output/
├── song_(Vocals).wav # 人声
├── song_(Instrumental).wav # 伴奏 (MDX)
├── song_(Drums).wav # 鼓 (Demucs)
├── song_(Bass).wav # 贝斯 (Demucs)
├── song_(Other).wav # 其他 (Demucs)
├── song_(Guitar).wav # 吉他 (6轨)
└── song_(Piano).wav # 钢琴 (6轨)
🐍 Python API
from mdx_headless_runner import run_mdx_headless
from demucs_headless_runner import run_demucs_headless
from vr_headless_runner import run_vr_headless
# MDX 分离
run_mdx_headless(
model_path='model.ckpt',
audio_file='song.wav',
export_path='output',
use_gpu=True,
verbose=True # 打印进度
)
# 输出: output/song_(Vocals).wav, output/song_(Instrumental).wav
# Demucs 分离(只要人声)
run_demucs_headless(
model_path='htdemucs',
audio_file='song.wav',
export_path='output',
use_gpu=True,
demucs_stems='Vocals', # 或 'All Stems' 输出全部
primary_only=True,
verbose=True
)
# 输出: output/song_(Vocals).wav
# VR Architecture 分离
run_vr_headless(
model_path='model.pth',
audio_file='song.wav',
export_path='output',
use_gpu=True,
window_size=512,
aggression_setting=5,
is_tta=False,
# 未知模型需手动指定参数:
# user_vr_model_param='4band_v3',
# user_primary_stem='Vocals'
)
# 输出: output/song_(Vocals).wav, output/song_(Instrumental).wav
💡 说明: 函数会处理音频并保存到
export_path。结果请查看输出目录。
🔍 故障排除
❌ GPU 未检测到
# 检查 CUDA
python -c "import torch; print(torch.cuda.is_available())"
# 重新安装带 CUDA 的 PyTorch
pip uninstall torch torchvision torchaudio
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
❌ 找不到模型
方式一:使用自动下载(推荐)
# 列出可用模型
python mdx_headless_runner.py --list
# 下载模型
python mdx_headless_runner.py --download "UVR-MDX-NET Inst HQ 3"
# 或者直接使用 - 自动下载!
python mdx_headless_runner.py -m "UVR-MDX-NET Inst HQ 3" -i song.wav -o output/
方式二:手动下载
默认位置:
- MDX:
./models/MDX_Net_Models/ - Demucs:
./models/Demucs_Models/v3_v4_repo/ - VR:
./models/VR_Models/
❌ 网络/下载错误
# 强制刷新模型注册表
python model_downloader.py --sync
# 检查网络连接
python -c "import urllib.request; urllib.request.urlopen('https://github.com')"
下载器包含:
- 自动重试(3 次,指数退避)
- 断点续传
- 注册表缓存回退
❌ VR 模型哈希未找到
如果你的 VR 模型不在数据库中,需要手动指定参数:
# 列出可用参数
python vr_headless_runner.py --list-params
# 指定 param 和 primary stem
python vr_headless_runner.py -m "model.pth" -i "song.wav" -o "output/" \
--param 4band_v3 --primary-stem Vocals
常用参数: 4band_v3, 4band_v2, 1band_sr44100_hl512, 3band_44100
❌ 输出质量不佳
- 尝试增加
--overlap或--overlap-mdxc - Demucs 可以增加
--segment(如 85) - 使用
--json指定正确的模型配置
🙏 致谢
|
Anjok07 & aufr33 |
Facebook Research |
Woosung Choi |
tsurumeso |
特别感谢 ZFTurbo 提供的 MDX23C 和 SCNet 实现。
📄 许可证
MIT License
Copyright (c) 2022 Anjok07 (Ultimate Vocal Remover)
Copyright (c) 2026 UVR Headless Runner Contributors
贡献与支持
欢迎提交 Pull Request 和 Issue!无论是 bug 反馈、功能建议还是代码贡献,我们都非常感谢。
如果你觉得这个项目对你有帮助,请给我们一个 Star ⭐,这是对我们最大的支持!
为音频分离社区用 ❤️ 制作
探索相关项目
加载中…