|
@@ -86,27 +86,20 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
|
|
|
|
|
|
CrtDramaProjectStoryboard storyboardDetail = crtDramaProjectStoryboardDao.selectById(drama_project_storyboard_id);
|
|
|
if (storyboardDetail == null) throw new CustException("分镜不存在");
|
|
|
- // System.out.println("- 分镜详情: " + JSONUtil.toJsonStr(storyboardDetail));
|
|
|
|
|
|
Long drama_project_id = storyboardDetail.getDrama_project_id();
|
|
|
LambdaQueryWrapper<CrtDramaProjectSettings> wrapperSettings = new LambdaQueryWrapper<>();
|
|
|
wrapperSettings.eq(CrtDramaProjectSettings::getDrama_project_id, drama_project_id);
|
|
|
List<CrtDramaProjectSettings> settingsDetail = crtDramaProjectSettingsDao.selectList(wrapperSettings);
|
|
|
if (settingsDetail == null) throw new CustException("项目配置不存在");
|
|
|
- // System.out.println("- 项目配置: " + JSONUtil.toJsonStr(settingsDetail));
|
|
|
|
|
|
// 项目配置类型 (1:生图配置, 2:生视频配置)
|
|
|
CrtDramaProjectSettings settings_image = settingsDetail.stream().filter(item -> item.getDrama_project_setting_type() == 1).findFirst().orElse(null);
|
|
|
- // System.out.println("- 生图配置: " + JSONUtil.toJsonStr(settings_image));
|
|
|
-
|
|
|
// CrtDramaProjectSettings settings_video = settingsDetail.stream().filter(item -> item.getDrama_project_setting_type() == 2).findFirst().orElse(null);
|
|
|
- // System.out.println("- 生视频配置: " + JSONUtil.toJsonStr(settings_video));
|
|
|
-
|
|
|
|
|
|
- // 文生图提示词
|
|
|
- String prompt_text = crtDramaProjectStoryboard.getText_to_image_prompt();
|
|
|
|
|
|
- // == 从 storboard detail 获取参数 =============================================================================
|
|
|
+ // == 从生图参数初始化 ===========================================================================================
|
|
|
+ String prompt_text = crtDramaProjectStoryboard.getText_to_image_prompt(); // 文生图提示词
|
|
|
Integer param_batch_size = storyboardDetail.getParam_batch_size(); // 生成图片数量
|
|
|
Float param_prompt_flux_guidance = storyboardDetail.getParam_prompt_flux_guidance(); // 提示词引导系数
|
|
|
String param_sampler = SamplerEnums.getValueByKey(storyboardDetail.getParam_sampler()); // 采样器
|
|
@@ -118,69 +111,73 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
|
|
|
Convert.toStr(DateUtil.current()) :
|
|
|
storyboardDetail.getParam_seed();
|
|
|
|
|
|
- // [分集详情] 实体类
|
|
|
+ // 画面比例 (从项目配置)(16:9 - 1280*720, 9:16 - 720*1280, 1:1 - 1024*1024)
|
|
|
+ AspectRatioEnums aspect_ratio_option = AspectRatioEnums.of(settings_image.getAspect_ratio());
|
|
|
+ Integer width = aspect_ratio_option.getWidth(); // 1280
|
|
|
+ Integer height = aspect_ratio_option.getHeight(); // 720
|
|
|
+
|
|
|
+ // 获取基础模型 (从项目配置)
|
|
|
+ Long model_id = settings_image.getModel_id();
|
|
|
+ CrtModel modelDetail = crtModelDao.selectById(model_id);
|
|
|
+ String model_name = modelDetail.getModel_name();
|
|
|
+ // =========================================================================================================
|
|
|
+
|
|
|
+
|
|
|
+ // [DB] 更新分集详情记录 (更新种子值、提示词)
|
|
|
CrtDramaProjectStoryboard entity = new CrtDramaProjectStoryboard();
|
|
|
entity.setParam_seed(param_seed);
|
|
|
entity.setText_to_image_prompt(prompt_text);
|
|
|
-
|
|
|
- // [DB] 更新分集详情记录 (种子值、提示词)
|
|
|
LambdaQueryWrapper<CrtDramaProjectStoryboard> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(CrtDramaProjectStoryboard::getId, drama_project_storyboard_id);
|
|
|
crtDramaProjectStoryboardDao.update(entity, wrapper);
|
|
|
|
|
|
- // [DB] 获取画面比例 (从项目配置)
|
|
|
- String aspect_ratio = settings_image.getAspect_ratio();
|
|
|
- AspectRatioEnums aspect_ratio_option = AspectRatioEnums.of(aspect_ratio);
|
|
|
- Integer width = aspect_ratio_option.getWidth();
|
|
|
- Integer height = aspect_ratio_option.getHeight();
|
|
|
-// Integer width = 1280;
|
|
|
-// Integer height = 720;
|
|
|
-
|
|
|
- // [DB] 获取基础模型 (从项目配置)
|
|
|
- Long model_id = settings_image.getModel_id();
|
|
|
- CrtModel modelDetail = crtModelDao.selectById(model_id);
|
|
|
- String model_name = modelDetail.getModel_name();
|
|
|
-
|
|
|
// 风格 Lora 待定
|
|
|
// 风格 Lora (阙值)待定
|
|
|
|
|
|
- // ===========================================================================================================
|
|
|
-
|
|
|
- String client_id = Convert.toStr(UUID.randomUUID());
|
|
|
|
|
|
- // -- [ComfyUI] 创建 WebSocket 监听连接 --------------------------
|
|
|
- Map<String, Object> params = new LinkedHashMap<>();
|
|
|
- params.put("drama_project_storyboard_id", drama_project_storyboard_id);
|
|
|
- // - is_save: 是否转存到 cos/tos
|
|
|
- comfyUISocketService.connectToSse(client_id, 8000, IS_SAVE, params).subscribe();
|
|
|
+ // ===========================================================================================================
|
|
|
|
|
|
- // -- [ComfyUI] 生图参数 ----------------------------------------
|
|
|
+ // -- [ComfyUI] 生图参数 ---------------------------------------------------
|
|
|
ComfyuiText2Image comfyuiText2Image = new ComfyuiText2Image();
|
|
|
comfyuiText2Image.setBatch_size(param_batch_size);
|
|
|
comfyuiText2Image.setPrompt_flux_guidance(param_prompt_flux_guidance);
|
|
|
comfyuiText2Image.setSampler(param_sampler);
|
|
|
-
|
|
|
comfyuiText2Image.setStep(param_step);
|
|
|
comfyuiText2Image.setWidth(width);
|
|
|
comfyuiText2Image.setHeight(height);
|
|
|
-// comfyuiText2Image.setStep(5);
|
|
|
-// comfyuiText2Image.setWidth(400);
|
|
|
-// comfyuiText2Image.setHeight(200);
|
|
|
-
|
|
|
- // aspect_ratio 画面比例 (枚举)(16:9 - 1280*720, 9:16 - 720*1280, 1:1 - 1024*1024)
|
|
|
-
|
|
|
comfyuiText2Image.setModel_name(model_name);
|
|
|
comfyuiText2Image.setPrompt_text(prompt_text);
|
|
|
comfyuiText2Image.setSeed(param_seed);
|
|
|
|
|
|
- // -- [ComfyUI] 生图 --------------------------------------------
|
|
|
- ComfyuiResponse response = comfyuiText2ImageService.generateText2Image(client_id, comfyuiText2Image);
|
|
|
- System.out.println("结果: " + response);
|
|
|
- // 结果: ComfyuiResponse(client_id=1a8a2d01-5500-437f-bb11-7a986130da48, prompt_id=c74501ed-6755-48f8-a440-aef3474b523c, number=47, node_errors={}, error=null)
|
|
|
+ String client_id = Convert.toStr(UUID.randomUUID());
|
|
|
+
|
|
|
+ // -- [ComfyUI] 发起生图任务 -----------------------------------------------
|
|
|
+ Long task_id = comfyuiText2ImageService.generateText2Image(client_id, comfyuiText2Image);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// // -- [ComfyUI] 创建 WebSocket 监听进度 --------------------------
|
|
|
+// Map<String, Object> params = new LinkedHashMap<>();
|
|
|
+// params.put("drama_project_storyboard_id", drama_project_storyboard_id);
|
|
|
+// // - is_save: 是否转存到 cos/tos
|
|
|
+// comfyUISocketService.connectToSse(client_id, 8000, IS_SAVE, params).subscribe();
|
|
|
+
|
|
|
+ // -- [ComfyUI] 执行/排队生图任务 --------------------------------------------
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// ComfyuiResponse response = null; // comfyuiText2ImageService.generateText2Image(client_id, comfyuiText2Image);
|
|
|
+// System.out.println("结果: " + response);
|
|
|
+// // 结果: ComfyuiResponse(client_id=1a8a2d01-5500-437f-bb11-7a986130da48, prompt_id=c74501ed-6755-48f8-a440-aef3474b523c, number=47, node_errors={}, error=null)
|
|
|
|
|
|
Map<String, Object> resp = new LinkedHashMap<>();
|
|
|
resp.put("drama_project_storyboard_id", drama_project_storyboard_id);
|
|
|
- resp.put("response", response);
|
|
|
+ resp.put("client_id", client_id);
|
|
|
+ resp.put("task_id", task_id);
|
|
|
+// resp.put("response", response);
|
|
|
return resp;
|
|
|
}
|
|
|
|