BUGFIX:FLUX童装prompt修改;获取video结果允许传入list
This commit is contained in:
@@ -107,8 +107,8 @@ public class GenerateController {
|
|||||||
|
|
||||||
@ApiOperation(value = "获取姿势变换生成结果")
|
@ApiOperation(value = "获取姿势变换生成结果")
|
||||||
@PostMapping("/poseTransformResult")
|
@PostMapping("/poseTransformResult")
|
||||||
public Response<PoseTransformationVO> getPoseTransformationResults(@Valid @RequestBody Map<String,String> taskId) {
|
public Response<List<PoseTransformationVO>> getPoseTransformationResults(@Valid @RequestBody List<String> taskIdList) {
|
||||||
PoseTransformationVO generateResult = generateService.getPoseTransformationResult(taskId.get("taskId"));
|
List<PoseTransformationVO> generateResult = generateService.getPoseTransformationResult(taskIdList);
|
||||||
return Response.success(generateResult);
|
return Response.success(generateResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ public class GenerateController {
|
|||||||
typeEnum = CreditsEventsEnum.IMAGE_TO_SKETCH;
|
typeEnum = CreditsEventsEnum.IMAGE_TO_SKETCH;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return Response.success(generateService.flux(typeEnum, prompt, path));
|
return Response.success(generateService.flux(typeEnum, prompt, path, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ApiOperation(value = "获取flux结果")
|
// @ApiOperation(value = "获取flux结果")
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public interface GenerateService extends IService<Generate> {
|
|||||||
|
|
||||||
void processPoseTransformResult(String taskId, String gifUrl, String videoUrl, String imageUrl);
|
void processPoseTransformResult(String taskId, String gifUrl, String videoUrl, String imageUrl);
|
||||||
|
|
||||||
PoseTransformationVO getPoseTransformationResult(String taskId);
|
List<PoseTransformationVO> getPoseTransformationResult(List<String> taskIdList);
|
||||||
|
|
||||||
List<PoseTransformationVO> getPoseTransformationResultList(Long projectId, boolean like);
|
List<PoseTransformationVO> getPoseTransformationResultList(Long projectId, boolean like);
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ public interface GenerateService extends IService<Generate> {
|
|||||||
|
|
||||||
String getImageDescription(String imagePath);
|
String getImageDescription(String imagePath);
|
||||||
|
|
||||||
String flux(CreditsEventsEnum func, String prompt, String imagePath);
|
String flux(CreditsEventsEnum func, String prompt, String imagePath, boolean childStyle);
|
||||||
|
|
||||||
String getFluxResult(String taskId, String objectName);
|
String getFluxResult(String taskId, String objectName);
|
||||||
|
|
||||||
|
|||||||
@@ -1012,7 +1012,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
}else {
|
}else {
|
||||||
imagePath = collagePictureUrl;
|
imagePath = collagePictureUrl;
|
||||||
}
|
}
|
||||||
taskId = flux(event, null, imagePath);
|
taskId = flux(event, null, imagePath, false);
|
||||||
// 存数据库
|
// 存数据库
|
||||||
saveExtractSketchRequest(imageToSketchDTO, collagePictureUrl, projectId,
|
saveExtractSketchRequest(imageToSketchDTO, collagePictureUrl, projectId,
|
||||||
accountId, imageToSketchDTO.getStyle(), "flux", taskId);
|
accountId, imageToSketchDTO.getStyle(), "flux", taskId);
|
||||||
@@ -1158,6 +1158,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
poseTransformation.setUniqueId(taskId);
|
poseTransformation.setUniqueId(taskId);
|
||||||
poseTransformation.setProductImage(productImage);
|
poseTransformation.setProductImage(productImage);
|
||||||
poseTransformation.setPoseId(poseId);
|
poseTransformation.setPoseId(poseId);
|
||||||
|
poseTransformation.setIsLiked((byte)1);
|
||||||
poseTransformation.setCreateTime(LocalDateTime.now());
|
poseTransformation.setCreateTime(LocalDateTime.now());
|
||||||
poseTransformationMapper.insert(poseTransformation);
|
poseTransformationMapper.insert(poseTransformation);
|
||||||
|
|
||||||
@@ -1210,30 +1211,34 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
if (flag) creditsService.updateChangedCredits(accountId, taskId);
|
if (flag) creditsService.updateChangedCredits(accountId, taskId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoseTransformationVO getPoseTransformationResult(String taskId){
|
public List<PoseTransformationVO> getPoseTransformationResult(List<String> taskIdList){
|
||||||
String type = resolveModelType(taskId, CreditsEventsEnum.POSE_TRANSFORMATION.getValue());
|
ArrayList<PoseTransformationVO> poseTransformationVOS = new ArrayList<>();
|
||||||
if (type.equals("wx")){
|
for (String taskId : taskIdList){
|
||||||
return getAnimateResult(taskId);
|
String type = resolveModelType(taskId, CreditsEventsEnum.POSE_TRANSFORMATION.getValue());
|
||||||
}
|
if (type.equals("wx")){
|
||||||
String key = generateResultKey + ":" + taskId;
|
poseTransformationVOS.add(getAnimateResult(taskId));
|
||||||
String resultJson = redisUtil.getFromString(key);
|
}
|
||||||
|
String key = generateResultKey + ":" + taskId;
|
||||||
if (!StringUtil.isNullOrEmpty(resultJson)){
|
String resultJson = redisUtil.getFromString(key);
|
||||||
PoseTransformationVO poseTransformationVO = new Gson().fromJson(redisUtil.getFromString(key), PoseTransformationVO.class);
|
|
||||||
if (poseTransformationVO.getStatus().equals("Success")){
|
if (!StringUtil.isNullOrEmpty(resultJson)){
|
||||||
// 处理各种URL
|
PoseTransformationVO poseTransformationVO = new Gson().fromJson(redisUtil.getFromString(key), PoseTransformationVO.class);
|
||||||
processUrl(poseTransformationVO.getGifUrl(), url ->
|
if (poseTransformationVO.getStatus().equals("Success")){
|
||||||
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
// 处理各种URL
|
||||||
processUrl(poseTransformationVO.getVideoUrl(), url ->
|
processUrl(poseTransformationVO.getGifUrl(), url ->
|
||||||
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
poseTransformationVO.setGifUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||||
processUrl(poseTransformationVO.getFirstFrameUrl(), url ->
|
processUrl(poseTransformationVO.getVideoUrl(), url ->
|
||||||
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
poseTransformationVO.setVideoUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||||
|
processUrl(poseTransformationVO.getFirstFrameUrl(), url ->
|
||||||
|
poseTransformationVO.setFirstFrameUrl(minioUtil.getPreSignedUrl(url, CommonConstant.MINIO_IMAGE_EXPIRE_TIME)));
|
||||||
|
}
|
||||||
|
poseTransformationVO.setResultType(CollectionType.POSE_TRANSFORM.getValue());
|
||||||
|
poseTransformationVOS.add(poseTransformationVO);
|
||||||
|
}else {
|
||||||
|
poseTransformationVOS.add(new PoseTransformationVO(taskId, "Executing"));
|
||||||
}
|
}
|
||||||
poseTransformationVO.setResultType(CollectionType.POSE_TRANSFORM.getValue());
|
|
||||||
return poseTransformationVO;
|
|
||||||
}else {
|
|
||||||
return new PoseTransformationVO(taskId, "Executing");
|
|
||||||
}
|
}
|
||||||
|
return poseTransformationVOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PoseTransformationVO> getPoseTransformationResultList(Long projectId, boolean like){
|
public List<PoseTransformationVO> getPoseTransformationResultList(Long projectId, boolean like){
|
||||||
@@ -2131,7 +2136,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
* @param imagePath 图片minio路径
|
* @param imagePath 图片minio路径
|
||||||
* @return 返回taskId,用于异步获取结果
|
* @return 返回taskId,用于异步获取结果
|
||||||
*/
|
*/
|
||||||
public String flux(CreditsEventsEnum func, String prompt, String imagePath){
|
public String flux(CreditsEventsEnum func, String prompt, String imagePath, boolean childStyle){
|
||||||
String fluxRequestUrl = "https://api.bfl.ai/v1/flux-kontext-pro";
|
String fluxRequestUrl = "https://api.bfl.ai/v1/flux-kontext-pro";
|
||||||
if (StringUtil.isNullOrEmpty(prompt)){
|
if (StringUtil.isNullOrEmpty(prompt)){
|
||||||
switch (func){
|
switch (func){
|
||||||
@@ -2143,6 +2148,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
break;
|
break;
|
||||||
case TO_PRODUCT_IMAGE_FLUX:
|
case TO_PRODUCT_IMAGE_FLUX:
|
||||||
prompt = "change the image to real style, ultra high quality, 8k";
|
prompt = "change the image to real style, ultra high quality, 8k";
|
||||||
|
if (childStyle) prompt = prompt + ", Children's face";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2150,9 +2156,10 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
|
|
||||||
requestBody.set("prompt", prompt);
|
requestBody.set("prompt", prompt);
|
||||||
requestBody.set("seed", 42);
|
requestBody.set("seed", 42);
|
||||||
// requestBody.set("aspect_ratio", "9:16");
|
requestBody.set("aspect_ratio", "9:16");
|
||||||
requestBody.set("output_format", "png");
|
requestBody.set("output_format", "png");
|
||||||
|
|
||||||
|
log.info("flux 请求入参:{}", requestBody);
|
||||||
if (!StringUtil.isNullOrEmpty(imagePath)){
|
if (!StringUtil.isNullOrEmpty(imagePath)){
|
||||||
try {
|
try {
|
||||||
String imageAsBase64 = null;
|
String imageAsBase64 = null;
|
||||||
@@ -2170,6 +2177,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
String resp = sendRequestUtil.sendFluxPost(fluxRequestUrl, requestBody.toString());
|
String resp = sendRequestUtil.sendFluxPost(fluxRequestUrl, requestBody.toString());
|
||||||
|
// JSONObject respObj = JSONUtil.parseObj(null);
|
||||||
JSONObject respObj = JSONUtil.parseObj(resp);
|
JSONObject respObj = JSONUtil.parseObj(resp);
|
||||||
log.info("flux 发起生成请求返回结果: {}", respObj);
|
log.info("flux 发起生成请求返回结果: {}", respObj);
|
||||||
String taskId = respObj.getStr("id");
|
String taskId = respObj.getStr("id");
|
||||||
|
|||||||
@@ -458,7 +458,10 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
}
|
}
|
||||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||||
if (fluxTask){
|
if (fluxTask){
|
||||||
taskId = generateService.flux(CreditsEventsEnum.TO_PRODUCT_IMAGE_FLUX, sb.toString(), tDesignPythonOutfit.getDesignUrl());
|
if (childFlag){
|
||||||
|
sb.append(", Children's face");
|
||||||
|
}
|
||||||
|
taskId = generateService.flux(CreditsEventsEnum.TO_PRODUCT_IMAGE_FLUX, sb.toString(), tDesignPythonOutfit.getDesignUrl(), childFlag);
|
||||||
toProductImageResult.setModelName("flux");
|
toProductImageResult.setModelName("flux");
|
||||||
toProductImageResult.setResultType("ToProductImage");
|
toProductImageResult.setResultType("ToProductImage");
|
||||||
} else {
|
} else {
|
||||||
@@ -475,7 +478,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
toProductImageResult.setCreateTime(LocalDateTime.now());
|
toProductImageResult.setCreateTime(LocalDateTime.now());
|
||||||
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
||||||
// toProductImageResult.setUrl(productImageUrl);
|
// toProductImageResult.setUrl(productImageUrl);
|
||||||
toProductImageResult.setIsLike(0);
|
toProductImageResult.setIsLike(1);
|
||||||
toProductImageResult.setTaskId(taskId);
|
toProductImageResult.setTaskId(taskId);
|
||||||
toProductImageResult.setProjectId(projectId);
|
toProductImageResult.setProjectId(projectId);
|
||||||
if (userLikeGroupId != null) {
|
if (userLikeGroupId != null) {
|
||||||
@@ -497,7 +500,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||||
|
|
||||||
if (fluxTask){
|
if (fluxTask){
|
||||||
taskId = generateService.flux(creditsEventsEnum, sb.toString(), toProductElement.getUrl());
|
taskId = generateService.flux(creditsEventsEnum, sb.toString(), toProductElement.getUrl(), childFlag);
|
||||||
toProductImageResult.setModelName("flux");
|
toProductImageResult.setModelName("flux");
|
||||||
toProductImageResult.setResultType("ToProductImage");
|
toProductImageResult.setResultType("ToProductImage");
|
||||||
} else {
|
} else {
|
||||||
@@ -514,7 +517,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
toProductImageResult.setCreateTime(LocalDateTime.now());
|
toProductImageResult.setCreateTime(LocalDateTime.now());
|
||||||
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
||||||
// toProductImageResult.setUrl(productImageUrl);
|
// toProductImageResult.setUrl(productImageUrl);
|
||||||
toProductImageResult.setIsLike(0);
|
toProductImageResult.setIsLike(1);
|
||||||
toProductImageResult.setTaskId(taskId);
|
toProductImageResult.setTaskId(taskId);
|
||||||
toProductImageResult.setProjectId(projectId);
|
toProductImageResult.setProjectId(projectId);
|
||||||
if (userLikeGroupId != null) {
|
if (userLikeGroupId != null) {
|
||||||
@@ -1045,7 +1048,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
|
|
||||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||||
if (fluxTask){
|
if (fluxTask){
|
||||||
taskId = generateService.flux(creditsEventsEnum, s, toProductImageResult1.getUrl());
|
taskId = generateService.flux(creditsEventsEnum, s, toProductImageResult1.getUrl(), false);
|
||||||
toProductImageResult.setModelName("flux");
|
toProductImageResult.setModelName("flux");
|
||||||
toProductImageResult.setResultType("Relight");
|
toProductImageResult.setResultType("Relight");
|
||||||
} else {
|
} else {
|
||||||
@@ -1057,7 +1060,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
toProductImageResult.setCreateTime(LocalDateTime.now());
|
toProductImageResult.setCreateTime(LocalDateTime.now());
|
||||||
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
||||||
// toProductImageResult.setUrl(productImageUrl);
|
// toProductImageResult.setUrl(productImageUrl);
|
||||||
toProductImageResult.setIsLike(0);
|
toProductImageResult.setIsLike(1);
|
||||||
toProductImageResult.setTaskId(taskId);
|
toProductImageResult.setTaskId(taskId);
|
||||||
toProductImageResult.setProjectId(projectId);
|
toProductImageResult.setProjectId(projectId);
|
||||||
if (null != userLikeGroupId) {
|
if (null != userLikeGroupId) {
|
||||||
@@ -1074,7 +1077,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
ToProductElement toProductElement = toProductElementMapper.selectById(toProductImageVO.getElementId());
|
||||||
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
ToProductImageResult toProductImageResult = new ToProductImageResult();
|
||||||
if (fluxTask){
|
if (fluxTask){
|
||||||
taskId = generateService.flux(CreditsEventsEnum.RELIGHT_FLUX, s, toProductElement.getUrl());
|
taskId = generateService.flux(CreditsEventsEnum.RELIGHT_FLUX, s, toProductElement.getUrl(), false);
|
||||||
toProductImageResult.setModelName("flux");
|
toProductImageResult.setModelName("flux");
|
||||||
toProductImageResult.setResultType("Relight");
|
toProductImageResult.setResultType("Relight");
|
||||||
} else {
|
} else {
|
||||||
@@ -1086,7 +1089,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
|||||||
toProductImageResult.setCreateTime(LocalDateTime.now());
|
toProductImageResult.setCreateTime(LocalDateTime.now());
|
||||||
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
toProductImageResult.setToProductImageRecordId(toProductImageRecord.getId());
|
||||||
// toProductImageResult.setUrl(productImageUrl);
|
// toProductImageResult.setUrl(productImageUrl);
|
||||||
toProductImageResult.setIsLike(0);
|
toProductImageResult.setIsLike(1);
|
||||||
toProductImageResult.setTaskId(taskId);
|
toProductImageResult.setTaskId(taskId);
|
||||||
toProductImageResult.setProjectId(projectId);
|
toProductImageResult.setProjectId(projectId);
|
||||||
if (null != userLikeGroupId) {
|
if (null != userLikeGroupId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user