## 主要更新 - ✨ 更新所有依赖到最新稳定版本 - 📝 添加详细的项目文档和模型推荐 - 🔧 配置 VSCode Cloud Studio 预览功能 - 🐛 修复 PyTorch API 弃用警告 ## 依赖更新 - diffusers: 0.27.2 → 0.35.2 - gradio: 4.21.0 → 5.46.0 - peft: 0.7.1 → 0.18.0 - Pillow: 9.5.0 → 11.3.0 - fastapi: 0.108.0 → 0.116.2 ## 新增文件 - CLAUDE.md - 项目架构和开发指南 - UPGRADE_NOTES.md - 详细的升级说明 - .vscode/preview.yml - 预览配置 - .vscode/LAUNCH_GUIDE.md - 启动指南 - .gitignore - 更新的忽略规则 ## 代码修复 - 修复 iopaint/model/ldm.py 中的 torch.cuda.amp.autocast() 弃用警告 ## 文档更新 - README.md - 添加模型推荐和使用指南 - 完整的项目源码(iopaint/) - Web 前端源码(web_app/) 🤖 Generated with Claude Code
49 lines
1.2 KiB
Python
Executable File
49 lines
1.2 KiB
Python
Executable File
from torch import nn
|
|
|
|
|
|
class CTCHead(nn.Module):
|
|
def __init__(self,
|
|
in_channels,
|
|
out_channels=6625,
|
|
fc_decay=0.0004,
|
|
mid_channels=None,
|
|
return_feats=False,
|
|
**kwargs):
|
|
super(CTCHead, self).__init__()
|
|
if mid_channels is None:
|
|
self.fc = nn.Linear(
|
|
in_channels,
|
|
out_channels,
|
|
bias=True,)
|
|
else:
|
|
self.fc1 = nn.Linear(
|
|
in_channels,
|
|
mid_channels,
|
|
bias=True,
|
|
)
|
|
self.fc2 = nn.Linear(
|
|
mid_channels,
|
|
out_channels,
|
|
bias=True,
|
|
)
|
|
|
|
self.out_channels = out_channels
|
|
self.mid_channels = mid_channels
|
|
self.return_feats = return_feats
|
|
|
|
def forward(self, x, labels=None):
|
|
if self.mid_channels is None:
|
|
predicts = self.fc(x)
|
|
else:
|
|
x = self.fc1(x)
|
|
predicts = self.fc2(x)
|
|
|
|
if self.return_feats:
|
|
result = dict()
|
|
result['ctc'] = predicts
|
|
result['ctc_neck'] = x
|
|
else:
|
|
result = predicts
|
|
|
|
return result
|