Init: 初版代码

This commit is contained in:
Kevin Wong
2026-01-14 14:39:02 +08:00
parent 41c2e3f9d3
commit 302a43a22f
44 changed files with 9999 additions and 316 deletions

263
Docs/DEPLOY_MANUAL.md Normal file
View File

@@ -0,0 +1,263 @@
# ViGent 手动部署指南
## 服务器信息
| 配置 | 规格 |
|------|------|
| 服务器 | Dell PowerEdge R730 |
| CPU | 2× Intel Xeon E5-2680 v4 (56 线程) |
| 内存 | 192GB DDR4 |
| GPU 0 | NVIDIA RTX 3090 24GB |
| GPU 1 | NVIDIA RTX 3090 24GB (用于 MuseTalk) |
| 部署路径 | `/home/rongye/ProgramFiles/ViGent` |
---
## 步骤 1: 环境检查
```bash
# 检查 GPU
nvidia-smi
# 检查 Python 版本 (需要 3.10+)
python3 --version
# 检查 Node.js 版本 (需要 18+)
node --version
# 检查 FFmpeg
ffmpeg -version
```
如果缺少 FFmpeg:
```bash
sudo apt update
sudo apt install ffmpeg
```
---
## 步骤 2: 创建目录结构
```bash
mkdir -p /home/rongye/ProgramFiles/ViGent
cd /home/rongye/ProgramFiles/ViGent
```
将项目文件复制到该目录。
---
## 步骤 3: 安装后端依赖
```bash
cd /home/rongye/ProgramFiles/ViGent/backend
# 创建虚拟环境
python3 -m venv venv
source venv/bin/activate
# 安装 PyTorch (CUDA 12.1)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
# 安装其他依赖
pip install -r requirements.txt
# 安装 Playwright 浏览器 (社交发布用)
playwright install chromium
```
---
## 步骤 4: 安装 MMPose (唇形检测)
```bash
source /home/rongye/ProgramFiles/ViGent/backend/venv/bin/activate
pip install -U openmim
mim install mmengine
mim install "mmcv>=2.0.1"
mim install "mmdet>=3.1.0"
mim install "mmpose>=1.1.0"
```
---
## 步骤 5: 安装 MuseTalk
```bash
cd /home/rongye/ProgramFiles/ViGent/models
# 克隆仓库
git clone https://github.com/TMElyralab/MuseTalk.git
cd MuseTalk
# 激活虚拟环境
source /home/rongye/ProgramFiles/ViGent/backend/venv/bin/activate
# 安装依赖
pip install -r requirements.txt
```
---
## 步骤 6: 下载 MuseTalk 模型权重
从 HuggingFace 下载模型:
- 地址: https://huggingface.co/TMElyralab/MuseTalk
```bash
cd /home/rongye/ProgramFiles/ViGent/models/MuseTalk
# 使用 huggingface-cli 下载 (需要安装 huggingface_hub)
pip install huggingface_hub
huggingface-cli download TMElyralab/MuseTalk --local-dir ./models
```
或手动下载后放到:
```
/home/rongye/ProgramFiles/ViGent/models/MuseTalk/models/
```
---
## 步骤 7: 配置环境变量
```bash
cd /home/rongye/ProgramFiles/ViGent/backend
# 复制配置模板
cp .env.example .env
# 编辑配置
nano .env
```
修改以下配置:
```ini
# GPU 配置
MUSETALK_GPU_ID=1
MUSETALK_LOCAL=true
# 其他配置按需修改
DEBUG=false
```
---
## 步骤 8: 安装前端依赖
```bash
cd /home/rongye/ProgramFiles/ViGent/frontend
# 安装依赖
npm install
```
---
## 步骤 9: 测试运行
### 启动后端
```bash
cd /home/rongye/ProgramFiles/ViGent/backend
source venv/bin/activate
uvicorn app.main:app --host 0.0.0.0 --port 8000
```
### 启动前端 (新开终端)
```bash
cd /home/rongye/ProgramFiles/ViGent/frontend
npm run dev -- --host 0.0.0.0
```
---
## 步骤 10: 验证
1. 访问 http://服务器IP:3000 查看前端
2. 访问 http://服务器IP:8000/docs 查看 API 文档
3. 上传测试视频,生成口播视频
---
## 使用 systemd 管理服务 (可选)
### 后端服务
创建 `/etc/systemd/system/vigent-backend.service`:
```ini
[Unit]
Description=ViGent Backend API
After=network.target
[Service]
Type=simple
User=rongye
WorkingDirectory=/home/rongye/ProgramFiles/ViGent/backend
Environment="PATH=/home/rongye/ProgramFiles/ViGent/backend/venv/bin"
ExecStart=/home/rongye/ProgramFiles/ViGent/backend/venv/bin/uvicorn app.main:app --host 0.0.0.0 --port 8000
Restart=always
[Install]
WantedBy=multi-user.target
```
### 前端服务
创建 `/etc/systemd/system/vigent-frontend.service`:
```ini
[Unit]
Description=ViGent Frontend
After=network.target
[Service]
Type=simple
User=rongye
WorkingDirectory=/home/rongye/ProgramFiles/ViGent/frontend
ExecStart=/usr/bin/npm run start
Restart=always
[Install]
WantedBy=multi-user.target
```
### 启用服务
```bash
sudo systemctl daemon-reload
sudo systemctl enable vigent-backend vigent-frontend
sudo systemctl start vigent-backend vigent-frontend
```
---
## 故障排除
### GPU 不可用
```bash
# 检查 CUDA
nvidia-smi
python3 -c "import torch; print(torch.cuda.is_available())"
```
### 端口被占用
```bash
# 查看端口占用
sudo lsof -i :8000
sudo lsof -i :3000
```
### 查看日志
```bash
# 后端日志
journalctl -u vigent-backend -f
# 前端日志
journalctl -u vigent-frontend -f
```