Răsfoiți Sursa

Debug generate img

tsurumure 1 lună în urmă
părinte
comite
cf77aaecab

+ 446 - 75
src/main/java/com/backendsys/modules/crt/service/impl/CrtGenerateServiceImpl.java

@@ -60,85 +60,456 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
         // -- 前端生成的UUID ---------------------------------------------
         String client_id = Convert.toStr(UUID.randomUUID());
 
-        // -- [ComfyUI] 创建 WebSocket 监听连接 ---------------------------
+        // -- [ComfyUI] 创建 WebSocket 监听连接 --------------------------
         comfyUISocketService.connectToSse(client_id, 8001).subscribe();
 
-        // -- [ComfyUI] 执行任务 -----------------------------------------
-
-        // [Demo-基础生图]
-        String prompt = "{" +
-                    "\"3\": {" +
-                        "\"inputs\": {" +
-                            "\"seed\": 449753344472378," +
-                            "\"steps\": 20," +
-                            "\"cfg\": 8," +
-                            "\"sampler_name\": \"euler\"," +
-                            "\"scheduler\": \"normal\"," +
-                            "\"denoise\": 1," +
-                            "\"model\": [\"4\", 0]," +
-                            "\"positive\": [\"6\", 0]," +
-                            "\"negative\": [\"7\", 0]," +
-                            "\"latent_image\": [\"5\", 0]" +
-                        "}," +
-                        "\"class_type\": \"KSampler\"," +
-                        "\"_meta\": { \"title\": \"K采样器\" }" +
-                    "}," +
-                    "\"4\": {" +
-                        "\"inputs\": {" +
-                            "\"ckpt_name\": \"v1-5-pruned-emaonly-fp16.safetensors\"" +
-                        "}," +
-                        "\"class_type\": \"CheckpointLoaderSimple\"," +
-                        "\"_meta\": { \"title\": \"Checkpoint加载器(简易)\" }" +
-                    "}," +
-                    "\"5\": {" +
-                        "\"inputs\": {" +
-                            "\"width\": 512, \"height\": 512, \"batch_size\": 1" +
-                        "}," +
-                        "\"class_type\": \"EmptyLatentImage\"," +
-                        "\"_meta\": { \"title\": \"空Latent图像\" }" +
-                    "}," +
-                    "\"6\": {" +
-                        "\"inputs\": {" +
-                            "\"text\": \"beautiful scenery nature glass bottle landscape, , purple galaxy bottle,\"," +
-                            "\"speak_and_recognation\": {" +
-                                "\"__value__\": [false, true]" +
-                            "}," +
-                            "\"clip\": [\"4\", 1]" +
-                        "}," +
-                        "\"class_type\": \"CLIPTextEncode\"," +
-                        "\"_meta\": { \"title\": \"CLIP文本编码\" }" +
-                    "}," +
-                    "\"7\": {" +
-                        "\"inputs\": {" +
-                            "\"text\": \"text, watermark\"," +
-                            "\"speak_and_recognation\": {" +
-                                "\"__value__\": [false, true]" +
-                            "}," +
-                            "\"clip\": [\"4\", 1]" +
-                        "}," +
-                        "\"class_type\": \"CLIPTextEncode\"," +
-                        "\"_meta\": { \"title\": \"CLIP文本编码\" }" +
-                    "}," +
-                    "\"8\": {" +
-                        "\"inputs\": {" +
-                            "\"samples\": [\"3\", 0]," +
-                            "\"vae\": [\"4\", 2]," +
-                        "}," +
-                        "\"class_type\": \"VAEDecode\"," +
-                        "\"_meta\": { \"title\": \"VAE解码\" }" +
-                    "}," +
-                    "\"9\": {" +
-                        "\"inputs\": {" +
-                            "\"filename_prefix\": \"ComfyUI\"," +
-                            "\"images\": [\"8\", 0]" +
-                        "}," +
-                        "\"class_type\": \"SaveImage\"," +
-                        "\"_meta\": { \"title\": \"保存图像\" }" +
-                    "}," +
-                "}";
+        // -------------------------------------------------------------
+        // [ComfyUI-基础生图]
+//        String prompt = "{" +
+//                    "\"3\": {" +
+//                        "\"inputs\": {" +
+//                            "\"seed\": 449753344472378," +
+//                            "\"steps\": 20," +
+//                            "\"cfg\": 8," +
+//                            "\"sampler_name\": \"euler\"," +
+//                            "\"scheduler\": \"normal\"," +
+//                            "\"denoise\": 1," +
+//                            "\"model\": [\"4\", 0]," +
+//                            "\"positive\": [\"6\", 0]," +
+//                            "\"negative\": [\"7\", 0]," +
+//                            "\"latent_image\": [\"5\", 0]" +
+//                        "}," +
+//                        "\"class_type\": \"KSampler\"," +
+//                        "\"_meta\": { \"title\": \"K采样器\" }" +
+//                    "}," +
+//                    "\"4\": {" +
+//                        "\"inputs\": {" +
+//                            "\"ckpt_name\": \"v1-5-pruned-emaonly-fp16.safetensors\"" +
+//                        "}," +
+//                        "\"class_type\": \"CheckpointLoaderSimple\"," +
+//                        "\"_meta\": { \"title\": \"Checkpoint加载器(简易)\" }" +
+//                    "}," +
+//                    "\"5\": {" +
+//                        "\"inputs\": {" +
+//                            "\"width\": 512, \"height\": 512, \"batch_size\": 1" +
+//                        "}," +
+//                        "\"class_type\": \"EmptyLatentImage\"," +
+//                        "\"_meta\": { \"title\": \"空Latent图像\" }" +
+//                    "}," +
+//                    "\"6\": {" +
+//                        "\"inputs\": {" +
+//                            "\"text\": \"beautiful scenery nature glass bottle landscape, , purple galaxy bottle,\"," +
+//                            "\"speak_and_recognation\": {" +
+//                                "\"__value__\": [false, true]" +
+//                            "}," +
+//                            "\"clip\": [\"4\", 1]" +
+//                        "}," +
+//                        "\"class_type\": \"CLIPTextEncode\"," +
+//                        "\"_meta\": { \"title\": \"CLIP文本编码\" }" +
+//                    "}," +
+//                    "\"7\": {" +
+//                        "\"inputs\": {" +
+//                            "\"text\": \"text, watermark\"," +
+//                            "\"speak_and_recognation\": {" +
+//                                "\"__value__\": [false, true]" +
+//                            "}," +
+//                            "\"clip\": [\"4\", 1]" +
+//                        "}," +
+//                        "\"class_type\": \"CLIPTextEncode\"," +
+//                        "\"_meta\": { \"title\": \"CLIP文本编码\" }" +
+//                    "}," +
+//                    "\"8\": {" +
+//                        "\"inputs\": {" +
+//                            "\"samples\": [\"3\", 0]," +
+//                            "\"vae\": [\"4\", 2]," +
+//                        "}," +
+//                        "\"class_type\": \"VAEDecode\"," +
+//                        "\"_meta\": { \"title\": \"VAE解码\" }" +
+//                    "}," +
+//                    "\"9\": {" +
+//                        "\"inputs\": {" +
+//                            "\"filename_prefix\": \"ComfyUI\"," +
+//                            "\"images\": [\"8\", 0]" +
+//                        "}," +
+//                        "\"class_type\": \"SaveImage\"," +
+//                        "\"_meta\": { \"title\": \"保存图像\" }" +
+//                    "}," +
+//                "}";
+
+        // ComfyUI - 7.4生图.json
+        String prompt = "{"+
+                "  \"3\": {"+
+                "    \"inputs\": {"+
+                "      \"text\": ["+
+                "        \"120\","+
+                "        0"+
+                "      ],"+
+                "      \"speak_and_recognation\": {"+
+                "        \"__value__\": ["+
+                "          false,"+
+                "          true"+
+                "        ]"+
+                "      }"+
+                "    },"+
+                "    \"class_type\": \"CLIPTextEncode\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"CLIP文本编码\""+
+                "    }"+
+                "  },"+
+                "  \"13\": {"+
+                "    \"inputs\": {"+
+                "      \"guidance\": 3.5,"+
+                "      \"conditioning\": ["+
+                "        \"3\","+
+                "        0"+
+                "      ]"+
+                "    },"+
+                "    \"class_type\": \"FluxGuidance\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"Flux引导\""+
+                "    }"+
+                "  },"+
+                "  \"15\": {"+
+                "    \"inputs\": {"+
+                "      \"conditioning\": ["+
+                "        \"13\","+
+                "        0"+
+                "      ]"+
+                "    },"+
+                "    \"class_type\": \"BasicGuider\","+
+                "    \"_meta\": {"+
+                "      \"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"+
+                "      ]"+
+                "    },"+
+                "    \"class_type\": \"VAEDecode\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"VAE解码\""+
+                "    }"+
+                "  },"+
+                "  \"32\": {"+
+                "    \"inputs\": {"+
+                "      \"guider\": ["+
+                "        \"15\","+
+                "        0"+
+                "      ]"+
+                "    },"+
+                "    \"class_type\": \"SamplerCustomAdvanced\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"自定义采样器(高级)\""+
+                "    }"+
+                "  },"+
+                "  \"34\": {"+
+                "    \"inputs\": {"+
+                "      \"SIGMAS\": ["+
+                "        \"150\","+
+                "        0"+
+                "      ]"+
+                "    },"+
+                "    \"class_type\": \"Anything Everywhere\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"Anything Everywhere\""+
+                "    }"+
+                "  },"+
+                "  \"37\": {"+
+                "    \"inputs\": {"+
+                "      \"noise_seed\": 861118998334462"+
+                "    },"+
+                "    \"class_type\": \"RandomNoise\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"随机噪波\""+
+                "    }"+
+                "  },"+
+                "  \"38\": {"+
+                "    \"inputs\": {"+
+                "      \"text\": \"\","+
+                "      \"speak_and_recognation\": {"+
+                "        \"__value__\": ["+
+                "          false,"+
+                "          true"+
+                "        ]"+
+                "      }"+
+                "    },"+
+                "    \"class_type\": \"TextInput_\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"触发词\""+
+                "    }"+
+                "  },"+
+                "  \"51\": {"+
+                "    \"inputs\": {"+
+                "      \"text\": \"分镜1\","+
+                "      \"speak_and_recognation\": {"+
+                "        \"__value__\": ["+
+                "          false,"+
+                "          true"+
+                "        ]"+
+                "      }"+
+                "    },"+
+                "    \"class_type\": \"TextInput_\","+
+                "    \"_meta\": {"+
+                "      \"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\""+
+                "    },"+
+                "    \"class_type\": \"KSamplerSelect\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"K采样器选择\""+
+                "    }"+
+                "  },"+
+                "  \"90\": {"+
+                "    \"inputs\": {"+
+                "      \"width\": ["+
+                "        \"121\","+
+                "        0"+
+                "      ],"+
+                "      \"height\": ["+
+                "        \"122\","+
+                "        0"+
+                "      ],"+
+                "      \"batch_size\": 1"+
+                "    },"+
+                "    \"class_type\": \"EmptySD3LatentImage\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"空Latent图像(SD3)\""+
+                "    }"+
+                "  },"+
+                "  \"91\": {"+
+                "    \"inputs\": {"+
+                "      \"filename_prefix\": ["+
+                "        \"51\","+
+                "        0"+
+                "      ],"+
+                "      \"images\": ["+
+                "        \"31\","+
+                "        0"+
+                "      ]"+
+                "    },"+
+                "    \"class_type\": \"SaveImage\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"保存图像\""+
+                "    }"+
+                "  },"+
+                "  \"120\": {"+
+                "    \"inputs\": {"+
+                "      \"text_0\": \", Just cat\","+
+                "      \"text\": ["+
+                "        \"148\","+
+                "        0"+
+                "      ]"+
+                "    },"+
+                "    \"class_type\": \"PandasShowText\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"Pandas Show Text\""+
+                "    }"+
+                "  },"+
+                "  \"121\": {"+
+                "    \"inputs\": {"+
+                "      \"value\": 1280"+
+                "    },"+
+                "    \"class_type\": \"easy int\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"整数\""+
+                "    }"+
+                "  },"+
+                "  \"122\": {"+
+                "    \"inputs\": {"+
+                "      \"value\": 720"+
+                "    },"+
+                "    \"class_type\": \"easy int\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"整数\""+
+                "    }"+
+                "  },"+
+                "  \"146\": {"+
+                "    \"inputs\": {"+
+                "      \"from_translate\": \"japanese\","+
+                "      \"to_translate\": \"english\","+
+                "      \"add_proxies\": false,"+
+                "      \"proxies\": \"\","+
+                "      \"auth_data\": \"\","+
+                "      \"service\": \"BaiduTranslator [appid and appkey]\","+
+                "      \"text\": ["+
+                "        \"153\","+
+                "        0"+
+                "      ],"+
+                "      \"Show proxy\": \"proxy_hide\","+
+                "      \"Show authorization\": \"authorization_hide\","+
+                "      \"speak_and_recognation\": {"+
+                "        \"__value__\": ["+
+                "          false,"+
+                "          true"+
+                "        ]"+
+                "      }"+
+                "    },"+
+                "    \"class_type\": \"DeepTranslatorTextNode\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"Deep Translator Text Node\""+
+                "    }"+
+                "  },"+
+                "  \"148\": {"+
+                "    \"inputs\": {"+
+                "      \"delimiter\": \", \","+
+                "      \"string1\": ["+
+                "        \"38\","+
+                "        0"+
+                "      ],"+
+                "      \"string2\": ["+
+                "        \"146\","+
+                "        0"+
+                "      ]"+
+                "    },"+
+                "    \"class_type\": \"JoinStrings\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"Join Strings\""+
+                "    }"+
+                "  },"+
+                "  \"149\": {"+
+                "    \"inputs\": {"+
+                "      \"CLIP\": ["+
+                "        \"151\","+
+                "        1"+
+                "      ]"+
+                "    },"+
+                "    \"class_type\": \"Anything Everywhere\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"Anything Everywhere\""+
+                "    }"+
+                "  },"+
+                "  \"150\": {"+
+                "    \"inputs\": {"+
+                "      \"scheduler\": \"normal\","+
+                "      \"steps\": 25,"+
+                "      \"denoise\": 1"+
+                "    },"+
+                "    \"class_type\": \"BasicScheduler\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"基本调度器\""+
+                "    }"+
+                "  },"+
+                "  \"151\": {"+
+                "    \"inputs\": {"+
+                "      \"ckpt_name\": \"FLUX1/flux1-dev-fp8.safetensors\""+
+                "    },"+
+                "    \"class_type\": \"CheckpointLoaderSimple\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"Checkpoint加载器(简易)\""+
+                "    }"+
+                "  },"+
+                "  \"152\": {"+
+                "    \"inputs\": {"+
+                "      \"lora_name\": \"【FLUX】都市高武推文 _ 异能 法术 战斗_v1.0.safetensors\","+
+                "      \"strength_model\": 0,"+
+                "      \"model\": ["+
+                "        \"151\","+
+                "        0"+
+                "      ]"+
+                "    },"+
+                "    \"class_type\": \"LoraLoaderModelOnly\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"LoRA加载器(仅模型)\""+
+                "    }"+
+                "  },"+
+                "  \"153\": {"+
+                "    \"inputs\": {"+
+                "      \"text\": \"一只猫\","+
+                "      \"speak_and_recognation\": {"+
+                "        \"__value__\": ["+
+                "          false,"+
+                "          true"+
+                "        ]"+
+                "      }"+
+                "    },"+
+                "    \"class_type\": \"TextInput_\","+
+                "    \"_meta\": {"+
+                "      \"title\": \"Text Input ♾️Mixlab\""+
+                "    }"+
+                "  }"+
+                "}"
+        ;
 
-        JSONObject prompt_object = JSONUtil.parseObj(prompt);
 
+        // -------------------------------------------------------------
+
+        JSONObject prompt_object = JSONUtil.parseObj(prompt);
         System.out.println("prompt_object: " + prompt_object);
 
         // [ComfyUI] 执行任务