diff --git a/README.md b/README.md index 51ce25f..1d29df8 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,67 @@ This service provides an async API for separating audio files into vocals and ac - **Redis**: Task queue for separation jobs - **Demucs 4.0.1**: AI-powered source separation model (htdemucs) +## 模型下载(离线部署) + +Demucs 使用 htdemucs 模型(PyTorch hub 格式),首次运行时自动下载,也可手动预下载。 + +### 方法1: PyTorch Hub 自动下载(默认) + +服务首次运行时会通过 `torch.hub.load("facebookresearch/demucs", "htdemucs")` 自动下载模型。 + +**下载位置**: `~/.cache/torch/hub/checkpoints/` +**下载大小**: ~80MB + +### 方法2: 手动预下载 + +如果部署环境无法访问外网,可以先在有网络的机器上下载,再拷贝: + +```bash +# 在有网络的机器上运行 Python +python3 << "PYTHON" +import torch +model = torch.hub.load("facebookresearch/demucs", "htdemucs", pretrained=True) +print("Model downloaded to:", torch.hub.get_dir()) +PYTHON + +# 找到模型文件 +ls ~/.cache/torch/hub/checkpoints/ +# 应该看到 htdemucs-*.pt 或类似文件 + +# 拷贝到部署服务器 +scp ~/.cache/torch/hub/checkpoints/htdemucs*.pt ymq@opencomputing.net:~/.cache/torch/hub/checkpoints/ +``` + +### 方法3: 直接下载模型文件 + +```bash +# 创建缓存目录 +mkdir -p ~/.cache/torch/hub/checkpoints/ + +# 下载 htdemucs 模型 +wget -O ~/.cache/torch/hub/checkpoints/htdemucs_v4.pt \ + https://dl.fbaipublicfiles.com/demucs/v4.0/htdemucs.pth +``` + +**下载大小**: ~80MB +**下载时间**: 约5-15秒 + +### 验证下载 + +```bash +# 启动服务后检查日志 +tail -f /data/ymq/demucs-service/nohup.out | grep -i "model" +# 应该看到 "Model loaded" 而不是 "Downloading" +``` + +### 模型来源 + +- **GitHub**: https://github.com/facebookresearch/demucs +- **PyTorch Hub**: facebookresearch/demucs +- **License**: MIT +- **Paper**: Hybrid Spectrogram and Waveform Source Separation + + ## API ### Submit Separation Task