Kaynağa Gözat

调通生图API

tsurumure 1 ay önce
ebeveyn
işleme
86c4aaeca9

+ 43 - 104
src/main/java/com/backendsys/modules/crt/service/impl/CrtGenerateServiceImpl.java

@@ -4,7 +4,6 @@ import cn.hutool.core.convert.Convert;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.backendsys.exception.CustException;
-import com.backendsys.modules.common.utils.Result;
 import com.backendsys.modules.crt.dao.CrtDramaProjectStoryboardDao;
 import com.backendsys.modules.crt.entity.CrtDramaProjectStoryboard;
 import com.backendsys.modules.crt.service.CrtGenerateService;
@@ -13,7 +12,6 @@ import com.backendsys.modules.sdk.comfyui.entity.CFQueue;
 import com.backendsys.modules.sdk.comfyui.service.ComfyUIService;
 import com.backendsys.modules.sdk.comfyui.service.ComfyUISocketService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import reactor.core.publisher.Mono;
 
@@ -52,8 +50,11 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
     @Override
     public Map<String, Object> generateImage(CrtDramaProjectStoryboard crtDramaProjectStoryboard) {
 
+        String text_to_image_prompt = crtDramaProjectStoryboard.getText_to_image_prompt();
         Long drama_project_storyboard_id = crtDramaProjectStoryboard.getDrama_project_storyboard_id();
 
+        System.out.println("(文生图提示词) text_to_image_prompt = " + text_to_image_prompt);
+
         CrtDramaProjectStoryboard detail = crtDramaProjectStoryboardDao.selectById(drama_project_storyboard_id);
         if (detail == null) throw new CustException("分镜不存在");
 
@@ -61,7 +62,7 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
         String client_id = Convert.toStr(UUID.randomUUID());
 
         // -- [ComfyUI] 创建 WebSocket 监听连接 --------------------------
-        comfyUISocketService.connectToSse(client_id, 8001).subscribe();
+        comfyUISocketService.connectToSse(client_id, 8000).subscribe();
 
         // -------------------------------------------------------------
         // [ComfyUI-基础生图]
@@ -149,7 +150,11 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
                 "          false,"+
                 "          true"+
                 "        ]"+
-                "      }"+
+                "      },"+
+                "      \"clip\": ["+
+                "        \"151\","+
+                "        1"+
+                "      ]"+
                 "    },"+
                 "    \"class_type\": \"CLIPTextEncode\","+
                 "    \"_meta\": {"+
@@ -171,6 +176,10 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
                 "  },"+
                 "  \"15\": {"+
                 "    \"inputs\": {"+
+                "      \"model\": ["+
+                "        \"152\","+
+                "        0"+
+                "      ],"+
                 "      \"conditioning\": ["+
                 "        \"13\","+
                 "        0"+
@@ -181,62 +190,15 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
                 "      \"title\": \"基本引导器\""+
                 "    }"+
                 "  },"+
-                "  \"20\": {"+
-                "    \"inputs\": {"+
-                "      \"text\": \"ng_deepnegative_v1_75t,(badhandv4:1.2),EasyNegative,(worst quality:2),\","+
-                "      \"speak_and_recognation\": {"+
-                "        \"__value__\": ["+
-                "          false,"+
-                "          true"+
-                "        ]"+
-                "      }"+
-                "    },"+
-                "    \"class_type\": \"CLIPTextEncode\","+
-                "    \"_meta\": {"+
-                "      \"title\": \"CLIP文本编码\""+
-                "    }"+
-                "  },"+
-                "  \"21\": {"+
-                "    \"inputs\": {"+
-                "      \"VAE\": ["+
-                "        \"151\","+
-                "        2"+
-                "      ]"+
-                "    },"+
-                "    \"class_type\": \"Anything Everywhere\","+
-                "    \"_meta\": {"+
-                "      \"title\": \"Anything Everywhere\""+
-                "    }"+
-                "  },"+
-                "  \"29\": {"+
-                "    \"inputs\": {"+
-                "      \"LATENT\": ["+
-                "        \"90\","+
-                "        0"+
-                "      ]"+
-                "    },"+
-                "    \"class_type\": \"Anything Everywhere\","+
-                "    \"_meta\": {"+
-                "      \"title\": \"Anything Everywhere\""+
-                "    }"+
-                "  },"+
-                "  \"30\": {"+
-                "    \"inputs\": {"+
-                "      \"NOISE\": ["+
-                "        \"37\","+
-                "        0"+
-                "      ]"+
-                "    },"+
-                "    \"class_type\": \"Anything Everywhere\","+
-                "    \"_meta\": {"+
-                "      \"title\": \"Anything Everywhere\""+
-                "    }"+
-                "  },"+
                 "  \"31\": {"+
                 "    \"inputs\": {"+
                 "      \"samples\": ["+
                 "        \"32\","+
                 "        0"+
+                "      ],"+
+                "      \"vae\": ["+
+                "        \"151\","+
+                "        2"+
                 "      ]"+
                 "    },"+
                 "    \"class_type\": \"VAEDecode\","+
@@ -246,31 +208,35 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
                 "  },"+
                 "  \"32\": {"+
                 "    \"inputs\": {"+
+                "      \"noise\": ["+
+                "        \"37\","+
+                "        0"+
+                "      ],"+
                 "      \"guider\": ["+
                 "        \"15\","+
                 "        0"+
-                "      ]"+
-                "    },"+
-                "    \"class_type\": \"SamplerCustomAdvanced\","+
-                "    \"_meta\": {"+
-                "      \"title\": \"自定义采样器(高级)\""+
-                "    }"+
-                "  },"+
-                "  \"34\": {"+
-                "    \"inputs\": {"+
-                "      \"SIGMAS\": ["+
+                "      ],"+
+                "      \"sampler\": ["+
+                "        \"84\","+
+                "        0"+
+                "      ],"+
+                "      \"sigmas\": ["+
                 "        \"150\","+
                 "        0"+
+                "      ],"+
+                "      \"latent_image\": ["+
+                "        \"90\","+
+                "        0"+
                 "      ]"+
                 "    },"+
-                "    \"class_type\": \"Anything Everywhere\","+
+                "    \"class_type\": \"SamplerCustomAdvanced\","+
                 "    \"_meta\": {"+
-                "      \"title\": \"Anything Everywhere\""+
+                "      \"title\": \"自定义采样器(高级)\""+
                 "    }"+
                 "  },"+
                 "  \"37\": {"+
                 "    \"inputs\": {"+
-                "      \"noise_seed\": 861118998334462"+
+                "      \"noise_seed\": 229229841277714"+
                 "    },"+
                 "    \"class_type\": \"RandomNoise\","+
                 "    \"_meta\": {"+
@@ -294,7 +260,7 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
                 "  },"+
                 "  \"51\": {"+
                 "    \"inputs\": {"+
-                "      \"text\": \"分镜1\","+
+                "      \"text\": \"fenjing_" + drama_project_storyboard_id + "\","+
                 "      \"speak_and_recognation\": {"+
                 "        \"__value__\": ["+
                 "          false,"+
@@ -307,25 +273,6 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
                 "      \"title\": \"分镜号\""+
                 "    }"+
                 "  },"+
-                "  \"76\": {"+
-                "    \"inputs\": {},"+
-                "    \"class_type\": \"Anything Everywhere\","+
-                "    \"_meta\": {"+
-                "      \"title\": \"Anything Everywhere\""+
-                "    }"+
-                "  },"+
-                "  \"80\": {"+
-                "    \"inputs\": {"+
-                "      \"SAMPLER\": ["+
-                "        \"84\","+
-                "        0"+
-                "      ]"+
-                "    },"+
-                "    \"class_type\": \"Anything Everywhere\","+
-                "    \"_meta\": {"+
-                "      \"title\": \"Anything Everywhere\""+
-                "    }"+
-                "  },"+
                 "  \"84\": {"+
                 "    \"inputs\": {"+
                 "      \"sampler_name\": \"euler\""+
@@ -370,7 +317,7 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
                 "  },"+
                 "  \"120\": {"+
                 "    \"inputs\": {"+
-                "      \"text_0\": \", Just cat\","+
+                "      \"text_0\": \", a pig\","+
                 "      \"text\": ["+
                 "        \"148\","+
                 "        0"+
@@ -401,7 +348,7 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
                 "  },"+
                 "  \"146\": {"+
                 "    \"inputs\": {"+
-                "      \"from_translate\": \"japanese\","+
+                "      \"from_translate\": \"auto\","+
                 "      \"to_translate\": \"english\","+
                 "      \"add_proxies\": false,"+
                 "      \"proxies\": \"\","+
@@ -442,23 +389,15 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
                 "      \"title\": \"Join Strings\""+
                 "    }"+
                 "  },"+
-                "  \"149\": {"+
-                "    \"inputs\": {"+
-                "      \"CLIP\": ["+
-                "        \"151\","+
-                "        1"+
-                "      ]"+
-                "    },"+
-                "    \"class_type\": \"Anything Everywhere\","+
-                "    \"_meta\": {"+
-                "      \"title\": \"Anything Everywhere\""+
-                "    }"+
-                "  },"+
                 "  \"150\": {"+
                 "    \"inputs\": {"+
                 "      \"scheduler\": \"normal\","+
                 "      \"steps\": 25,"+
-                "      \"denoise\": 1"+
+                "      \"denoise\": 1,"+
+                "      \"model\": ["+
+                "        \"152\","+
+                "        0"+
+                "      ]"+
                 "    },"+
                 "    \"class_type\": \"BasicScheduler\","+
                 "    \"_meta\": {"+
@@ -490,7 +429,7 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
                 "  },"+
                 "  \"153\": {"+
                 "    \"inputs\": {"+
-                "      \"text\": \"一只猫\","+
+                "      \"text\": \"" + text_to_image_prompt + "\","+
                 "      \"speak_and_recognation\": {"+
                 "        \"__value__\": ["+
                 "          false,"+

+ 1 - 1
src/main/java/com/backendsys/modules/sdk/comfyui/controller/ComfyUIDemoController.java

@@ -33,7 +33,7 @@ public class ComfyUIDemoController {
     @Anonymous
     @PostMapping("/api/comfyui/ws/connect")
     public String connect(String clientId) {
-        comfyUISocketService.connect(clientId, 8001).subscribe();
+        comfyUISocketService.connect(clientId, 8000).subscribe();
         return "Connection initiated for: " + clientId;
     }
 

+ 3 - 3
src/main/java/com/backendsys/modules/sdk/comfyui/service/impl/ComfyUIServiceImpl.java

@@ -32,7 +32,7 @@ public class ComfyUIServiceImpl implements ComfyUIService {
     private WebClient webClient;
     public WebClient getWebClient() {
         if (webClient == null) {
-//            webClient = WebClient.builder().baseUrl(COMFYUI_HOST + ":8001").filter(WebClientFilter.logFilter).build();
+//            webClient = WebClient.builder().baseUrl(COMFYUI_HOST + ":8000").filter(WebClientFilter.logFilter).build();
             webClient = WebClient.builder().filter(WebClientFilter.logFilter).build();
         }
         return webClient;
@@ -53,7 +53,7 @@ public class ComfyUIServiceImpl implements ComfyUIService {
      * [ComfyUI] 查询任务队列
      */
     public Mono<CFQueue> getQueue() {
-        String url = "http://" + COMFYUI_HOST + ":8001/queue";
+        String url = "http://" + COMFYUI_HOST + ":8000/queue";
         WebClient webClient = getWebClient();
         return webClient.get()
                 .uri(url)
@@ -72,7 +72,7 @@ public class ComfyUIServiceImpl implements ComfyUIService {
         bodyValue.setClient_id(client_id);
         bodyValue.setPrompt(prompt);
 
-        String url = "http://" + COMFYUI_HOST + ":8001/prompt";
+        String url = "http://" + COMFYUI_HOST + ":8000/prompt";
 
         WebClient webClient = getWebClient();
         return webClient.post()