通过API托管ComfyUI工作流

This article focuses on leveraging ComfyUI beyond its basic workflow capabilities. You have created a fantastic Workflow and want to share it with the world or build an application around it. By hosting your projects and utilizing this WebSocket API concept, you can dynamically process user input to create an incredible style transfer or stunning photo effect.

本文重点介绍如何在基本工作流程能力之外利用ComfyUI。您已经创建了一个很棒的工作流程,并希望与世界分享或围绕它构建一个应用程序。通过托管您的项目并利用这个WebSocket API概念,您可以动态处理用户输入,创建令人惊叹的风格转换或令人惊叹的照片效果。

Introduction

介绍

This blog post describes the basic structure of a WebSocket API that communicates with ComfyUI. Generating images through ComfyUI typically takes several seconds, and depending on the complexity of the workflow, this time can increase. We utilize a WebSocket connection to track progress and allow us to give real-time feedback to the user. Using these endpoints without a WebSocket connection is possible, but this will cost you the benefits of real-time updates.

本博客文章描述了与ComfyUI通信的WebSocket API的基本结构。通过ComfyUI生成图像通常需要几秒钟的时间,而且根据工作流程的复杂性,这个时间可能会增加。我们利用WebSocket连接来跟踪进度,并允许我们向用户提供实时反馈。在没有WebSocket连接的情况下使用这些端点是可能的,但这将使您失去实时更新的好处。

Code for a basic WebSocket API structure can be found here: Basic WebSocket API.

基本WebSocket API结构的代码可以在这里找到:Basic WebSocket API

Utilized ComfyUI endpoints

使用 ComfyUI 端点

ComfyUI already has predefined endpoints ComfyUI endpoints, which we can target. Furthermore, ComfyUI also offers a WebSocket interface. For the API described later in this blog post, we do not need to modify this file, as it already provides everything we need.

ComfyUI已经预定义了一些端点ComfyUI端点,我们可以进行目标定位。此外,ComfyUI还提供了WebSocket接口。对于本文后面描述的API,我们不需要修改此文件,因为它已经提供了我们所需的一切。

  • @routes.get('/ws') ⇒ Returns the WebSocket object, sends status and executing messages
  • @routes.get('/ws') ⇒ 返回WebSocket对象,发送状态和执行消息
  • @routes.post("/prompt") ⇒ Queues prompt to workflow, returns prompt_id or error
  • @routes.post("/prompt") ⇒ 将提示排入工作流队列,返回提示 ID 或错误
  • @routes.get("/history/{prompt_id}") ⇒ Returns the queue or output for the given prompt_id
  • @routes.get("/his...
开通本站会员,查看完整译文。

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.1. UTC+08:00, 2024-11-24 21:54
浙ICP备14020137号-1 $访客地图$