转产品图提示词更换

This commit is contained in:
litianxiang
2025-11-12 17:25:46 +08:00
parent 52094d58e7
commit e35ed2c768

View File

@@ -443,17 +443,8 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductImageRecord.setUserLikeGroupId(userLikeGroupId);
}
// 处理用户输入的提示词
String prompt = toProductImageDTO.getPrompt();
String advancedPrompt;
//nanobanana模型支持中文为保证语义使用这个模型的不翻译
if (StringUtil.isNullOrEmpty(prompt)) {
advancedPrompt = "Transform this image into a realistic, studio-quality photograph."
+ "Pay attention to the size of the garment, the print, and the fabric texture. the white background. 8K, HDR, DOF, soft lighting" +
", high detail, high quality,Do not return the original image";
} else {
advancedPrompt = prompt + "Pay attention to the size of the garment, the print, and the fabric texture. the white background. 8K, HDR, DOF, soft lighting, high detail, high quality,Do not return the original image";
}
String advancedPrompt = buildAdvancedPrompt(projectId, prompt);
// 初始化基础提示词,确保生成高质量的真实图像
StringBuilder sb = new StringBuilder("The best quality, masterpiece, real image.");
if (!StringUtil.isNullOrEmpty(prompt) && !advanced) {
@@ -1909,13 +1900,14 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
// private ProductImageAttribute toAttrDict(AttributeRecognitionJSON attrDictJSON) {
// ProductImageAttribute attributeRetrieval = new ProductImageAttribute();
//// attributeRetrieval.setImgName(attrDictJSON.getImgName().get(0));
//// attributeRetrieval.setLength(attrDictJSON.getLength().get(0));
//// attributeRetrieval.setSleeveLength(attrDictJSON.getSleeveLength().get(0));
//// attributeRetrieval.setSleeveShape(attrDictJSON.getSleeveShape().get(0));
//// attributeRetrieval.setSleeveShoulder(attrDictJSON.getSleeveShoulder().get(0));
//// attributeRetrieval.setNeckline(attrDictJSON.getNeckline().get(0));
//// attributeRetrieval.setCollar(attrDictJSON.getCollar().get(0));
/// / attributeRetrieval.setImgName(attrDictJSON.getImgName().get(0));
/// / attributeRetrieval.setLength(attrDictJSON.getLength().get(0));
/// / attributeRetrieval.setSleeveLength(attrDictJSON.getSleeveLength().get(0));
/// / attributeRetrieval.setSleeveShape(attrDictJSON.getSleeveShape().get(0));
/// / attributeRetrieval.setSleeveShoulder(attrDictJSON.getSleeveShoulder().get(0));
/// / attributeRetrieval.setNeckline(attrDictJSON.getNeckline().get(0));
/// / attributeRetrieval.setCollar(attrDictJSON.getCollar().get(0));
// if (CollectionUtil.isNotEmpty(attrDictJSON.getDesign()) && attrDictJSON.getDesign().get(0) != null) {
// attributeRetrieval.setDesign(attrDictJSON.getDesign().get(0));
// }
@@ -1933,7 +1925,6 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
// }
// return attributeRetrieval;
// }
@Override
public IPage<ProjectVO> getPage(ProjectQueryDTO query) {
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
@@ -3362,4 +3353,44 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
toProductElementVO.setUrl(minioUtil.getPreSignedUrl(toProductElementVO.getUrl(), 24 * 60));
return toProductElementVO;
}
private String buildAdvancedPrompt(Long projectId, String prompt) {
String process = projectService.getById(projectId).getProcess();
String ageGroup = workspaceService.getWSByProjectId(projectId).getAgeGroup();
String suffixCommon = "Pay attention to the size of the garment, the print, and the fabric texture, real photo, 8K, HDR, DOF, soft lighting, high detail, high quality, Do not return the original image.";
String suffixModelAdult = "Transform this image into a real model standing,"+suffixCommon;
String suffixModelChild = "Transform this image into a real child model standing,"+suffixCommon;
if ("SINGLE_DESIGN".equals(process) && "Adult".equals(ageGroup)) {
if (StringUtil.isNullOrEmpty(prompt)) {
return "Transform this image into a real garment showing in the white studio: garment on invisible mannequin" + suffixCommon;
} else {
return prompt + suffixCommon;
}
} else if ("SINGLE_DESIGN".equals(process) && "Child".equals(ageGroup)) {
if (StringUtil.isNullOrEmpty(prompt)) {
return "Transform this image into a real child model stand and wear this garment, in the white studio, facing camera, standing posture." + suffixCommon;
} else {
return prompt + suffixCommon;
}
} else if ("SERIES_DESIGN".equals(process) && "Adult".equals(ageGroup)) {
if (StringUtil.isNullOrEmpty(prompt)) {
return "in the white studio, facing camera, standing posture." + suffixModelAdult;
} else {
return prompt + suffixModelAdult;
}
} else if ("SERIES_DESIGN".equals(process) && "Child".equals(ageGroup)) {
if (StringUtil.isNullOrEmpty(prompt)) {
return "in the white studio, facing camera, standing posture." + suffixModelChild + "\n";
} else {
return prompt + suffixModelChild;
}
} else if ("TO_PRODUCT_IMAGE".equals(process)) {
if (StringUtil.isNullOrEmpty(prompt)) {
throw new BusinessException("Please enter the prompt.");
} else {
return prompt + suffixCommon;
}
} else {
return "Transform this image into a realistic, studio-quality photograph." + "Pay attention to the size of the garment, the print, and the fabric texture. the white background. 8K, HDR, DOF, soft lighting" + ", high detail, high quality,Do not return the original image";
}
}
}