moodboard基础模型修改
This commit is contained in:
@@ -66,6 +66,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@@ -248,6 +249,13 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
jsonString = JSON.toJSONString(generateToPythonDTO, SerializerFeature.WriteMapNullValue);
|
jsonString = JSON.toJSONString(generateToPythonDTO, SerializerFeature.WriteMapNullValue);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (Objects.equals(version, "fast")) {
|
||||||
|
GenerateToPythonDTO generateToPythonDTO = new GenerateToPythonDTO(generateThroughImageTextDTO.getUniqueId(), text, Objects.isNull(collectionElement) ? "" : collectionElement.getUrl(),
|
||||||
|
mode, category, generateThroughImageTextDTO.getGender(), version);
|
||||||
|
jsonString = JSON.toJSONString(generateToPythonDTO, SerializerFeature.WriteMapNullValue);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
|
||||||
path = CommonConstant.GENERATE_PATH_FLUX2_KLEIN;
|
path = CommonConstant.GENERATE_PATH_FLUX2_KLEIN;
|
||||||
// 构建object_name: {userId}/{category}/{uuid}.png
|
// 构建object_name: {userId}/{category}/{uuid}.png
|
||||||
String objectName = generateThroughImageTextDTO.getUserId() + "/" + category + "/" + UUID.randomUUID() + ".png";
|
String objectName = generateThroughImageTextDTO.getUserId() + "/" + category + "/" + UUID.randomUUID() + ".png";
|
||||||
@@ -259,7 +267,9 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
jsonString = JSON.toJSONString(imageProcessRequest);
|
jsonString = JSON.toJSONString(imageProcessRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean requestResult = pythonService.generateSketchOrPrint(jsonString, port, path,generateThroughImageTextDTO.getUniqueId());
|
}
|
||||||
|
|
||||||
|
Boolean requestResult = pythonService.generateSketchOrPrint(jsonString, port, path, generateThroughImageTextDTO.getUniqueId());
|
||||||
|
|
||||||
|
|
||||||
// 5、将本次请求存入redis
|
// 5、将本次请求存入redis
|
||||||
@@ -274,6 +284,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
redisUtil.addToString(key, new Gson().toJson(generateResultVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
redisUtil.addToString(key, new Gson().toJson(generateResultVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveGenerateImmediately(Generate generate) {
|
public void saveGenerateImmediately(Generate generate) {
|
||||||
save(generate);
|
save(generate);
|
||||||
// 使用 TransactionSynchronizationManager 在事务真正提交后再设锁
|
// 使用 TransactionSynchronizationManager 在事务真正提交后再设锁
|
||||||
@@ -837,7 +848,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
response.code(), (requestEndTime - requestStartTime), taskId);
|
response.code(), (requestEndTime - requestStartTime), taskId);
|
||||||
String result = response.body().string();
|
String result = response.body().string();
|
||||||
if (!response.isSuccessful()) {
|
if (!response.isSuccessful()) {
|
||||||
log.warn("Google API响应失败,状态码: {} for taskId: {},结果:{}", response.code(), taskId,result);
|
log.warn("Google API响应失败,状态码: {} for taskId: {},结果:{}", response.code(), taskId, result);
|
||||||
if (attempt < maxRetries) {
|
if (attempt < maxRetries) {
|
||||||
Thread.sleep(retryDelay * attempt); // 递增延迟
|
Thread.sleep(retryDelay * attempt); // 递增延迟
|
||||||
continue;
|
continue;
|
||||||
@@ -1260,7 +1271,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
* @param modelName advanced high normal
|
* @param modelName advanced high normal
|
||||||
*/
|
*/
|
||||||
private HashMap<String, String> chooseModelAndPrompt(GenerateThroughImageTextDTO generateDTO, String modelName) {
|
private HashMap<String, String> chooseModelAndPrompt(GenerateThroughImageTextDTO generateDTO, String modelName) {
|
||||||
if (StringUtil.isNullOrEmpty(modelName)){
|
if (StringUtil.isNullOrEmpty(modelName)) {
|
||||||
throw new BusinessException("system error");
|
throw new BusinessException("system error");
|
||||||
}
|
}
|
||||||
HashMap<String, String> modelAndPromptMap = new HashMap<>();
|
HashMap<String, String> modelAndPromptMap = new HashMap<>();
|
||||||
@@ -1278,7 +1289,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
String style = generateDTO.getText().substring(0, firstCommaIndex).trim();
|
String style = generateDTO.getText().substring(0, firstCommaIndex).trim();
|
||||||
|
|
||||||
String prompt = generateDTO.getText().substring(firstCommaIndex + 1).trim();
|
String prompt = generateDTO.getText().substring(firstCommaIndex + 1).trim();
|
||||||
prompt = getPrintboardPrompt(style, prompt,modelName,isUseImage);
|
prompt = getPrintboardPrompt(style, prompt, modelName, isUseImage);
|
||||||
modelAndPromptMap.put(ModelConstants.PROMPT, prompt);
|
modelAndPromptMap.put(ModelConstants.PROMPT, prompt);
|
||||||
|
|
||||||
|
|
||||||
@@ -1676,14 +1687,14 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
"Flat textile pattern printed directly on fabric surface, no three-dimensional objects, no items placed on cloth. \n" +
|
"Flat textile pattern printed directly on fabric surface, no three-dimensional objects, no items placed on cloth. \n" +
|
||||||
"Real style: fabric print, realistic woven/printed pattern, detailed surface pattern only";
|
"Real style: fabric print, realistic woven/printed pattern, detailed surface pattern only";
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
throw new BusinessException("style error:"+ style);
|
throw new BusinessException("style error:" + style);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userInput == null || userInput.trim().isEmpty()) {
|
if (userInput == null || userInput.trim().isEmpty()) {
|
||||||
if (isUseImage){
|
if (isUseImage) {
|
||||||
prompt = "Theme: Image content" + "\nRequirement: " + systemPrompt;
|
prompt = "Theme: Image content" + "\nRequirement: " + systemPrompt;
|
||||||
}else {
|
} else {
|
||||||
throw new BusinessException("prompt null");
|
throw new BusinessException("prompt null");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user