|
@@ -2,25 +2,32 @@ package com.backendsys.modules.crt.service.impl;
|
|
|
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
-import cn.hutool.json.JSONObject;
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
import com.backendsys.exception.CustException;
|
|
|
-import com.backendsys.modules.common.config.security.utils.SecurityUtil;
|
|
|
import com.backendsys.modules.crt.dao.CrtDramaProjectSettingsDao;
|
|
|
import com.backendsys.modules.crt.dao.CrtDramaProjectStoryboardDao;
|
|
|
+import com.backendsys.modules.crt.dao.CrtGenerateImageDao;
|
|
|
import com.backendsys.modules.crt.dao.CrtModelDao;
|
|
|
import com.backendsys.modules.crt.entity.CrtDramaProjectSettings;
|
|
|
import com.backendsys.modules.crt.entity.CrtDramaProjectStoryboard;
|
|
|
import com.backendsys.modules.crt.entity.CrtGenerateImage;
|
|
|
import com.backendsys.modules.crt.entity.CrtModel;
|
|
|
+import com.backendsys.modules.crt.enums.AspectRatioEnums;
|
|
|
import com.backendsys.modules.crt.enums.SamplerEnums;
|
|
|
import com.backendsys.modules.crt.service.CrtGenerateService;
|
|
|
-import com.backendsys.modules.sdk.comfyui.entity.CFPromptResponse;
|
|
|
-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 com.backendsys.modules.sdk.comfyui.entity.ComfyuiResponse;
|
|
|
+import com.backendsys.modules.sdk.comfyui.entity.ComfyuiQueue;
|
|
|
+import com.backendsys.modules.sdk.comfyui.entity.ComfyuiText2Image;
|
|
|
+import com.backendsys.modules.sdk.comfyui.service.ComfyuiService;
|
|
|
+import com.backendsys.modules.sdk.comfyui.service.ComfyuiSocketService;
|
|
|
+import com.backendsys.modules.sdk.comfyui.service.ComfyuiText2ImageService;
|
|
|
+import com.backendsys.modules.upload.enums.StyleEnums;
|
|
|
+import com.backendsys.modules.upload.utils.UploadUtil;
|
|
|
+import com.backendsys.utils.response.PageEntity;
|
|
|
+import com.backendsys.utils.response.PageInfoResult;
|
|
|
+import com.backendsys.utils.v2.PageUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
@@ -28,14 +35,21 @@ import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class CrtGenerateServiceImpl implements CrtGenerateService {
|
|
|
|
|
|
+ @Value("${comfyui.is-save}")
|
|
|
+ private Boolean IS_SAVE;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ComfyuiService comfyUIService;
|
|
|
@Autowired
|
|
|
- private ComfyUIService comfyUIService;
|
|
|
+ private ComfyuiSocketService comfyUISocketService;
|
|
|
+
|
|
|
@Autowired
|
|
|
- private ComfyUISocketService comfyUISocketService;
|
|
|
+ private ComfyuiText2ImageService comfyuiText2ImageService;
|
|
|
|
|
|
@Autowired
|
|
|
private CrtModelDao crtModelDao;
|
|
@@ -43,6 +57,8 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
|
|
|
private CrtDramaProjectSettingsDao crtDramaProjectSettingsDao;
|
|
|
@Autowired
|
|
|
private CrtDramaProjectStoryboardDao crtDramaProjectStoryboardDao;
|
|
|
+ @Autowired
|
|
|
+ private CrtGenerateImageDao crtGenerateImageDao;
|
|
|
|
|
|
/**
|
|
|
* [ComfyUI] 查询任务队列
|
|
@@ -50,8 +66,8 @@ public class CrtGenerateServiceImpl implements CrtGenerateService {
|
|
|
@Override
|
|
|
public Map<String, Object> getQueue() {
|
|
|
// [ComfyUI] 执行任务
|
|
|
- Mono<CFQueue> cfQueueMono = comfyUIService.getQueue();
|
|
|
- CFQueue response = cfQueueMono.block();
|
|
|
+ Mono<ComfyuiQueue> cfQueueMono = comfyUIService.getQueue();
|
|
|
+ ComfyuiQueue response = cfQueueMono.block();
|
|
|
System.out.println("结果: " + response);
|
|
|
|
|
|
Map<String, Object> resp = new LinkedHashMap<>();
|
|
@@ -70,469 +86,130 @@ 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);
|
|
|
- CrtDramaProjectSettings settings_video = settingsDetail.stream().filter(item -> item.getDrama_project_setting_type() == 2).findFirst().orElse(null);
|
|
|
- System.out.println("- 生图配置: " + JSONUtil.toJsonStr(settings_image));
|
|
|
- System.out.println("- 生视频配置: " + JSONUtil.toJsonStr(settings_video));
|
|
|
+ // CrtDramaProjectSettings settings_video = settingsDetail.stream().filter(item -> item.getDrama_project_setting_type() == 2).findFirst().orElse(null);
|
|
|
|
|
|
|
|
|
- // 文生图提示词
|
|
|
- String text_to_image_prompt = 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()); // 采样器
|
|
|
- Integer param_step = storyboardDetail.getParam_step();
|
|
|
+ Integer param_step = storyboardDetail.getParam_step(); // 步数
|
|
|
|
|
|
// 随机种子 (默认值:1,范围:(1:随机, 2:自定义))
|
|
|
- Integer param_seed = storyboardDetail.getParam_seed();
|
|
|
- String param_seed_custom = storyboardDetail.getParam_seed_custom();
|
|
|
- if (param_seed == 1) {
|
|
|
- param_seed_custom = Convert.toStr(DateUtil.current()); // 生成一个随机值 (毫秒时间戳)
|
|
|
-
|
|
|
- // 【随机值,要保存到数据库】
|
|
|
- CrtDramaProjectStoryboard entity = new CrtDramaProjectStoryboard();
|
|
|
- entity.setParam_seed_custom(param_seed_custom);
|
|
|
- LambdaQueryWrapper<CrtDramaProjectStoryboard> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(CrtDramaProjectStoryboard::getId, drama_project_storyboard_id);
|
|
|
- crtDramaProjectStoryboardDao.update(entity, wrapper);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
+ Integer param_seed_type = storyboardDetail.getParam_seed_type();
|
|
|
+ String param_seed = (param_seed_type == 1) ?
|
|
|
+ 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
|
|
|
|
|
|
- // [db] 获取基础模型 (从项目配置)
|
|
|
+ // 获取基础模型 (从项目配置)
|
|
|
Long model_id = settings_image.getModel_id();
|
|
|
CrtModel modelDetail = crtModelDao.selectById(model_id);
|
|
|
String model_name = modelDetail.getModel_name();
|
|
|
+ // =========================================================================================================
|
|
|
|
|
|
|
|
|
- // 风格 Lora?
|
|
|
- // 风格 Lora (阙值)?
|
|
|
+ // [DB] 更新分集详情记录 (更新种子值、提示词)
|
|
|
+ CrtDramaProjectStoryboard entity = new CrtDramaProjectStoryboard();
|
|
|
+ entity.setParam_seed(param_seed);
|
|
|
+ entity.setText_to_image_prompt(prompt_text);
|
|
|
+ LambdaQueryWrapper<CrtDramaProjectStoryboard> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(CrtDramaProjectStoryboard::getId, drama_project_storyboard_id);
|
|
|
+ crtDramaProjectStoryboardDao.update(entity, wrapper);
|
|
|
+
|
|
|
+ // 风格 Lora 待定
|
|
|
+ // 风格 Lora (阙值)待定
|
|
|
|
|
|
|
|
|
// ===========================================================================================================
|
|
|
|
|
|
+ // -- [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.setModel_name(model_name);
|
|
|
+ comfyuiText2Image.setPrompt_text(prompt_text);
|
|
|
+ comfyuiText2Image.setSeed(param_seed);
|
|
|
|
|
|
+ String client_id = Convert.toStr(UUID.randomUUID());
|
|
|
|
|
|
+ // -- [ComfyUI] 发起生图任务 -----------------------------------------------
|
|
|
+ Long task_id = comfyuiText2ImageService.generateText2Image(client_id, comfyuiText2Image);
|
|
|
|
|
|
- // -- 前端生成的UUID ---------------------------------------------
|
|
|
- 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);
|
|
|
- comfyUISocketService.connectToSse(client_id, 8000, params).subscribe();
|
|
|
-
|
|
|
- // -------------------------------------------------------------
|
|
|
- // [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"+
|
|
|
- " ]"+
|
|
|
- " },"+
|
|
|
- " \"clip\": ["+
|
|
|
- " \"151\","+
|
|
|
- " 1"+
|
|
|
- " ]"+
|
|
|
- " },"+
|
|
|
- " \"class_type\": \"CLIPTextEncode\","+
|
|
|
- " \"_meta\": {"+
|
|
|
- " \"title\": \"CLIP文本编码\""+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"13\": {"+
|
|
|
- " \"inputs\": {"+
|
|
|
- " \"guidance\": " + param_prompt_flux_guidance + ","+
|
|
|
- " \"conditioning\": ["+
|
|
|
- " \"3\","+
|
|
|
- " 0"+
|
|
|
- " ]"+
|
|
|
- " },"+
|
|
|
- " \"class_type\": \"FluxGuidance\","+
|
|
|
- " \"_meta\": {"+
|
|
|
- " \"title\": \"Flux引导\""+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"15\": {"+
|
|
|
- " \"inputs\": {"+
|
|
|
- " \"model\": ["+
|
|
|
- " \"152\","+
|
|
|
- " 0"+
|
|
|
- " ],"+
|
|
|
- " \"conditioning\": ["+
|
|
|
- " \"13\","+
|
|
|
- " 0"+
|
|
|
- " ]"+
|
|
|
- " },"+
|
|
|
- " \"class_type\": \"BasicGuider\","+
|
|
|
- " \"_meta\": {"+
|
|
|
- " \"title\": \"基本引导器\""+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"31\": {"+
|
|
|
- " \"inputs\": {"+
|
|
|
- " \"samples\": ["+
|
|
|
- " \"32\","+
|
|
|
- " 0"+
|
|
|
- " ],"+
|
|
|
- " \"vae\": ["+
|
|
|
- " \"151\","+
|
|
|
- " 2"+
|
|
|
- " ]"+
|
|
|
- " },"+
|
|
|
- " \"class_type\": \"VAEDecode\","+
|
|
|
- " \"_meta\": {"+
|
|
|
- " \"title\": \"VAE解码\""+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"32\": {"+
|
|
|
- " \"inputs\": {"+
|
|
|
- " \"noise\": ["+
|
|
|
- " \"37\","+
|
|
|
- " 0"+
|
|
|
- " ],"+
|
|
|
- " \"guider\": ["+
|
|
|
- " \"15\","+
|
|
|
- " 0"+
|
|
|
- " ],"+
|
|
|
- " \"sampler\": ["+
|
|
|
- " \"84\","+
|
|
|
- " 0"+
|
|
|
- " ],"+
|
|
|
- " \"sigmas\": ["+
|
|
|
- " \"150\","+
|
|
|
- " 0"+
|
|
|
- " ],"+
|
|
|
- " \"latent_image\": ["+
|
|
|
- " \"90\","+
|
|
|
- " 0"+
|
|
|
- " ]"+
|
|
|
- " },"+
|
|
|
- " \"class_type\": \"SamplerCustomAdvanced\","+
|
|
|
- " \"_meta\": {"+
|
|
|
- " \"title\": \"自定义采样器(高级)\""+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"37\": {"+
|
|
|
- " \"inputs\": {"+
|
|
|
- " \"noise_seed\": " + param_seed_custom +
|
|
|
- " },"+
|
|
|
- " \"class_type\": \"RandomNoise\","+
|
|
|
- " \"_meta\": {"+
|
|
|
- " \"title\": \"随机噪波\""+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"38\": {"+
|
|
|
- " \"inputs\": {"+
|
|
|
- " \"text\": \"\","+
|
|
|
- " \"speak_and_recognation\": {"+
|
|
|
- " \"__value__\": ["+
|
|
|
- " false,"+
|
|
|
- " true"+
|
|
|
- " ]"+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"class_type\": \"TextInput_\","+
|
|
|
- " \"_meta\": {"+
|
|
|
- " \"title\": \"触发词\""+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"51\": {"+
|
|
|
- " \"inputs\": {"+
|
|
|
- " \"text\": \"fenjing_" + drama_project_storyboard_id + "\","+
|
|
|
- " \"speak_and_recognation\": {"+
|
|
|
- " \"__value__\": ["+
|
|
|
- " false,"+
|
|
|
- " true"+
|
|
|
- " ]"+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"class_type\": \"TextInput_\","+
|
|
|
- " \"_meta\": {"+
|
|
|
- " \"title\": \"分镜号\""+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"84\": {"+
|
|
|
- " \"inputs\": {"+
|
|
|
- " \"sampler_name\": \"" + param_sampler + "\""+
|
|
|
- " },"+
|
|
|
- " \"class_type\": \"KSamplerSelect\","+
|
|
|
- " \"_meta\": {"+
|
|
|
- " \"title\": \"K采样器选择\""+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"90\": {"+
|
|
|
- " \"inputs\": {"+
|
|
|
- " \"width\": ["+
|
|
|
- " \"121\","+
|
|
|
- " 0"+
|
|
|
- " ],"+
|
|
|
- " \"height\": ["+
|
|
|
- " \"122\","+
|
|
|
- " 0"+
|
|
|
- " ],"+
|
|
|
- " \"batch_size\": " + param_batch_size +
|
|
|
- " },"+
|
|
|
- " \"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\": \", a pig\","+
|
|
|
- " \"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\": \"auto\","+
|
|
|
- " \"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\""+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"150\": {"+
|
|
|
- " \"inputs\": {"+
|
|
|
- " \"scheduler\": \"normal\","+
|
|
|
- " \"steps\": " + param_step + ","+
|
|
|
- " \"denoise\": 1,"+
|
|
|
- " \"model\": ["+
|
|
|
- " \"152\","+
|
|
|
- " 0"+
|
|
|
- " ]"+
|
|
|
- " },"+
|
|
|
- " \"class_type\": \"BasicScheduler\","+
|
|
|
- " \"_meta\": {"+
|
|
|
- " \"title\": \"基本调度器\""+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"151\": {"+
|
|
|
- " \"inputs\": {"+
|
|
|
- " \"ckpt_name\": \"" + model_name + "\""+
|
|
|
- " },"+
|
|
|
- " \"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\": \"" + text_to_image_prompt + "\","+
|
|
|
- " \"speak_and_recognation\": {"+
|
|
|
- " \"__value__\": ["+
|
|
|
- " false,"+
|
|
|
- " true"+
|
|
|
- " ]"+
|
|
|
- " }"+
|
|
|
- " },"+
|
|
|
- " \"class_type\": \"TextInput_\","+
|
|
|
- " \"_meta\": {"+
|
|
|
- " \"title\": \"Text Input ♾️Mixlab\""+
|
|
|
- " }"+
|
|
|
- " }"+
|
|
|
- "}"
|
|
|
- ;
|
|
|
-
|
|
|
-
|
|
|
- // -------------------------------------------------------------
|
|
|
-
|
|
|
- JSONObject prompt_object = JSONUtil.parseObj(prompt);
|
|
|
- System.out.println("prompt_object: " + prompt_object);
|
|
|
|
|
|
- // [ComfyUI] 执行任务
|
|
|
- Mono<CFPromptResponse> cfPromptResponseMono = comfyUIService.prompt(client_id, prompt_object);
|
|
|
- CFPromptResponse response = cfPromptResponseMono.block();
|
|
|
- response.setClient_id(client_id);
|
|
|
- System.out.println("结果: " + response);
|
|
|
- // 结果: CFPromptResponse(client_id=1a8a2d01-5500-437f-bb11-7a986130da48, prompt_id=c74501ed-6755-48f8-a440-aef3474b523c, number=47, node_errors={}, error=null)
|
|
|
+
|
|
|
+// // -- [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;
|
|
|
}
|
|
|
|
|
|
+ // 短剧创作-获取分集生图记录
|
|
|
+ @Override
|
|
|
+ public PageEntity selectGenerateImage(CrtDramaProjectStoryboard crtDramaProjectStoryboard) {
|
|
|
+ PageUtils.startPage(); // 分页
|
|
|
+
|
|
|
+ Long drama_project_storyboard_id = crtDramaProjectStoryboard.getDrama_project_storyboard_id();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<CrtGenerateImage> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(CrtGenerateImage::getDrama_project_storyboard_id, drama_project_storyboard_id);
|
|
|
+ wrapper.orderByDesc(CrtGenerateImage::getCreate_time);
|
|
|
+ List<CrtGenerateImage> list = crtGenerateImageDao.selectList(wrapper);
|
|
|
+
|
|
|
+ // 1) 完成分页实体渲染
|
|
|
+ PageEntity pageEntity = new PageInfoResult(list).toEntity();
|
|
|
+
|
|
|
+ // 加入缩略图
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ // 2) 分页列表格式化
|
|
|
+ list = list.stream().map(item -> {
|
|
|
+ item.setUrl_thumb(UploadUtil.getImageThumbUrl(item.getUrl(), item.getTarget(), 100, null, StyleEnums.THUMB_BACKGROUND.getValue()));
|
|
|
+ return item;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 3) 分页实体重新赋值
|
|
|
+ List<Object> objectList = list.stream().map(item -> (Object) item).collect(Collectors.toList());
|
|
|
+ pageEntity.setList(objectList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return pageEntity;
|
|
|
+ }
|
|
|
+
|
|
|
}
|