## 主要更新 - ✨ 更新所有依赖到最新稳定版本 - 📝 添加详细的项目文档和模型推荐 - 🔧 配置 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
76 lines
2.4 KiB
Python
76 lines
2.4 KiB
Python
from typing import Dict
|
|
|
|
from loguru import logger
|
|
|
|
from .anime_seg import AnimeSeg
|
|
from .gfpgan_plugin import GFPGANPlugin
|
|
from .interactive_seg import InteractiveSeg
|
|
from .realesrgan import RealESRGANUpscaler
|
|
from .remove_bg import RemoveBG
|
|
from .restoreformer import RestoreFormerPlugin
|
|
from ..schema import InteractiveSegModel, Device, RealESRGANModel
|
|
|
|
|
|
def build_plugins(
|
|
enable_interactive_seg: bool,
|
|
interactive_seg_model: InteractiveSegModel,
|
|
interactive_seg_device: Device,
|
|
enable_remove_bg: bool,
|
|
remove_bg_device: Device,
|
|
remove_bg_model: str,
|
|
enable_anime_seg: bool,
|
|
enable_realesrgan: bool,
|
|
realesrgan_device: Device,
|
|
realesrgan_model: RealESRGANModel,
|
|
enable_gfpgan: bool,
|
|
gfpgan_device: Device,
|
|
enable_restoreformer: bool,
|
|
restoreformer_device: Device,
|
|
no_half: bool,
|
|
) -> Dict:
|
|
plugins = {}
|
|
if enable_interactive_seg:
|
|
logger.info(f"Initialize {InteractiveSeg.name} plugin")
|
|
plugins[InteractiveSeg.name] = InteractiveSeg(
|
|
interactive_seg_model, interactive_seg_device
|
|
)
|
|
|
|
if enable_remove_bg:
|
|
logger.info(f"Initialize {RemoveBG.name} plugin")
|
|
plugins[RemoveBG.name] = RemoveBG(remove_bg_model, remove_bg_device)
|
|
|
|
if enable_anime_seg:
|
|
logger.info(f"Initialize {AnimeSeg.name} plugin")
|
|
plugins[AnimeSeg.name] = AnimeSeg()
|
|
|
|
if enable_realesrgan:
|
|
logger.info(
|
|
f"Initialize {RealESRGANUpscaler.name} plugin: {realesrgan_model}, {realesrgan_device}"
|
|
)
|
|
plugins[RealESRGANUpscaler.name] = RealESRGANUpscaler(
|
|
realesrgan_model,
|
|
realesrgan_device,
|
|
no_half=no_half,
|
|
)
|
|
|
|
if enable_gfpgan:
|
|
logger.info(f"Initialize {GFPGANPlugin.name} plugin")
|
|
if enable_realesrgan:
|
|
logger.info("Use realesrgan as GFPGAN background upscaler")
|
|
else:
|
|
logger.info(
|
|
f"GFPGAN no background upscaler, use --enable-realesrgan to enable it"
|
|
)
|
|
plugins[GFPGANPlugin.name] = GFPGANPlugin(
|
|
gfpgan_device,
|
|
upscaler=plugins.get(RealESRGANUpscaler.name, None),
|
|
)
|
|
|
|
if enable_restoreformer:
|
|
logger.info(f"Initialize {RestoreFormerPlugin.name} plugin")
|
|
plugins[RestoreFormerPlugin.name] = RestoreFormerPlugin(
|
|
restoreformer_device,
|
|
upscaler=plugins.get(RealESRGANUpscaler.name, None),
|
|
)
|
|
return plugins
|