Files
ViGent2/Docs/DevLogs/Day16.md
Kevin Wong e226224119 更新
2026-02-08 19:54:11 +08:00

140 lines
3.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 🔧 Qwen-TTS Flash Attention 优化 (10:00)
### 优化背景
Qwen3-TTS 1.7B 模型在默认情况下加载速度慢,推理显存占用高。通过引入 Flash Attention 2可以显著提升模型加载速度和推理效率。
### 实施方案
`qwen-tts` Conda 环境中安装 `flash-attn`
```bash
conda activate qwen-tts
pip install -U flash-attn --no-build-isolation
```
### 验证结果
- **加载速度**: 从 ~60s 提升至 **8.9s**
- **显存占用**: 显著降低,消除 OOM 风险
- **代码变动**: 无代码变动,仅环境优化 (自动检测)
## 🛡️ 服务看门狗 Watchdog (10:30)
### 问题描述
常驻服务 (`vigent2-qwen-tts``vigent2-latentsync`) 可能会因显存碎片或长时间运行出现僵死 (Port open but unresponsive)。
### 解决方案
开发了一个 Python Watchdog 脚本,每 30 秒轮询服务的 `/health` 接口,如果连续 3 次失败则自动重启服务。
1. **Watchdog 脚本**: `backend/scripts/watchdog.py`
2. **启动脚本**: `run_watchdog.sh` (基于 PM2)
### 核心逻辑
```python
# 连续 3 次心跳失败触发重启
if service["failures"] >= service['threshold']:
subprocess.run(["pm2", "restart", service["name"]])
```
### 部署状态
- `vigent2-watchdog` 已启动并加入 PM2 列表
- 监控对象: `vigent2-qwen-tts` (8009), `vigent2-latentsync` (8007)
---
## ⚡ LatentSync 性能确认
经代码审计LatentSync 1.6 已内置优化:
-**Flash Attention**: 原生使用 `torch.nn.functional.scaled_dot_product_attention`
-**DeepCache**: 已启用 (`cache_interval=3`),提供 ~2.5x 加速
-**GPU 并发**: 双卡流水线 (GPU0 TTS | GPU1 LipSync) 已确认工作正常
---
## 🎨 交互体验与视图优化 (14:20)
### 主页优化
- 视频生成完成后,预览优先选中最新输出
- 选择项持久化:素材 / 背景音乐 / 历史作品
- 列表内滚动定位选中项,避免页面跳动
- 刷新回到顶部(首页)
- 标题/字幕样式预览面板
- 背景音乐试听即选中并自动开启,音量滑块实时影响试听
### 发布页优化
- 刷新回到顶部(发布页)
---
## 🎵 背景音乐链路修复 (15:00)
### 修复点
- FFmpeg 混音改为 `shell=False`,避免 `filter_complex` 被 shell 误解析
- `amix` 禁用归一化,避免配音音量被压低
### 关键修改
`backend/app/services/video_service.py`
---
## 🗣️ 字幕断句修复 (15:20)
### 内容
- 字幕切分逻辑保留英文单词整体,避免中英混合被硬切
### 涉及文件
- `backend/app/services/whisper_service.py`
---
## 🧱 资源库与样式能力接入 (15:40)
### 内容
- 字体库 / BGM 资源接入本地 assets
- 新增样式配置文件(字幕/标题)
- 新增资源 API 与静态挂载 `/assets`
- Remotion 支持样式参数与字体加载
### 涉及文件
- `backend/assets/fonts/`
- `backend/assets/bgm/`
- `backend/assets/styles/subtitle.json`
- `backend/assets/styles/title.json`
- `backend/app/services/assets_service.py`
- `backend/app/api/assets.py`
- `backend/app/main.py`
- `backend/app/api/videos.py`
- `backend/app/services/remotion_service.py`
- `remotion/src/components/Subtitles.tsx`
- `remotion/src/components/Title.tsx`
- `remotion/src/Video.tsx`
- `remotion/render.ts`
- `frontend/src/app/page.tsx`
- `frontend/next.config.ts`
---
## 🛠️ 运维调整 (16:10)
### 内容
- Watchdog 移除 LatentSync 监控,避免长推理误杀
- LatentSync PM2 增加内存重启阈值(运行时配置)
---
## 🎯 前端按钮图标统一 (16:40)
### 内容
- 首页与发布页按钮图标统一替换为 Lucide SVG
- 交互按钮保持一致尺寸与对齐
### 涉及文件
- `frontend/src/features/home/ui/`
- `frontend/src/app/publish/page.tsx`
---
## 📝 文档更新
- [x] `Docs/QWEN3_TTS_DEPLOY.md`: 添加 Flash Attention 安装指南
- [x] `Docs/DEPLOY_MANUAL.md`: 添加 Watchdog 部署说明
- [x] `Docs/TASK_COMPLETE.md`: 更新进度至 100% (Day 16)