ComfyUI迁移
ComfyUI是一个基于节点的Stable Diffusion用户界面,用户能够通过连接节点来构建复杂的图像生成工作流。ComfyUI中可以通过构建自定义加速节点替换工作流中的原有节点实现加速。
操作步骤
- 下载ComfyUI官方代码仓,并安装相关依赖。
- 加载MindIE SD提供的加速节点插件至ComfyUI/custom_nodes文件夹,并安装相关依赖。或基于MindIE SD优化后的模型自定义加速节点,如下所示。
- 加载MindIE代码仓中优化后模型的Transformer模型。
unet_path = os.path.join(MODEL_FOLDER_PATH, unet_name) unet = UnetAdapter(unet_path, use_attentioncache, start_step, attentioncache_interval, end_step)
- 加载ComfyUI中对应模型的Transformer模型。
conf = comfy.supported_models.StableAudio( {"audio_model": "dit1.0"}) conf.unet_config["disable_unet_model_creation"] = True conf.unet_config = { "audio_model": "dit1.0", } embedder_weights_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "seconds_embedder_weights") seconds_start_embedder_weights = torch.load(os.path.join(embedder_weights_path, "seconds_start_embedder_weights.pt")) seconds_total_embedder_weights = torch.load(os.path.join(embedder_weights_path, "seconds_total_embedder_weights.pt")) model = comfy.model_base.StableAudio1(conf, seconds_start_embedder_weights, seconds_total_embedder_weights)
- 使用优化后的Transformer模型替换ComfyUI的Transformer模型。
model.diffusion_model = unet model.memory_required = lambda *args, **kwargs: 0
- 加载MindIE代码仓中优化后模型的Transformer模型。
- 启动ComfyUI,加载MindIE SD提供的加速工作流,或基于官方工作流自行替换加速节点,完成推理。
父主题: 迁移优化指导