TASK: 1、更换pose,重新生成templateId
2、brandDNA 开启分析attributes功能
This commit is contained in:
@@ -11,12 +11,18 @@ import java.util.stream.Collectors;
|
||||
@Getter
|
||||
public enum PoseEnum {
|
||||
|
||||
POSE_1(1, "aida-sys-image/pose/pose-1.mp4", "aida-sys-image/pose/pose-1.gif", "aida-sys-image/pose/pose-1-first_frame.jpeg", "AACT.8090e67b.-E3pujumEfCbDTI_rjSH-A.LwIlGT3j"),
|
||||
POSE_2(2, "aida-sys-image/pose/pose-2.mp4", "aida-sys-image/pose/pose-2.gif", "aida-sys-image/pose/pose-2-first_frame.jpeg", "AACT.8090e67b.TwJLxEv3EfCbDTI_rjSH-A.IOQZCYhf"),
|
||||
POSE_3(3, "aida-sys-image/pose/pose-3.mp4", "aida-sys-image/pose/pose-3.gif", "aida-sys-image/pose/pose-3-first_frame.jpeg", "AACT.8090e67b.gd3OCkv4EfCxyZo8eQGF2Q.qMm-a1XI"),
|
||||
POSE_4(4, "aida-sys-image/pose/pose-4.mp4", "aida-sys-image/pose/pose-4.gif", "aida-sys-image/pose/pose-4-first_frame.jpeg", "AACT.8090e67b.AUDnuEwDEfCEHBaRJeW4dg.rlx36xEY"),
|
||||
POSE_5(5, "aida-sys-image/pose/pose-5.mp4", "aida-sys-image/pose/pose-5.gif", "aida-sys-image/pose/pose-5-first_frame.jpeg", "AACT.8090e67b.G8BvkEwEEfCxyZo8eQGF2Q.fo4ryrgR"),
|
||||
POSE_6(6, "aida-sys-image/pose/pose-6.mp4", "aida-sys-image/pose/pose-6.gif", "aida-sys-image/pose/pose-6-first_frame.jpeg", "AACT.8090e67b.yBIPnEwEEfCxyZo8eQGF2Q.boSFwTG9");
|
||||
// POSE_1(1, "aida-sys-image/pose/pose-1.mp4", "aida-sys-image/pose/pose-1.gif", "aida-sys-image/pose/pose-1-first_frame.jpeg", "AACT.8090e67b.-E3pujumEfCbDTI_rjSH-A.LwIlGT3j"),
|
||||
POSE_1(1, "aida-sys-image/pose/pose-1-1.mp4", "aida-sys-image/pose/pose-1-1.gif", "aida-sys-image/pose/pose-1-first_frame.jpeg", "AACT.8090e67b.qNMWJlyKEfCuORaRJeW4dg.x3wUteVO"),
|
||||
// POSE_2(2, "aida-sys-image/pose/pose-2.mp4", "aida-sys-image/pose/pose-2.gif", "aida-sys-image/pose/pose-2-first_frame.jpeg", "AACT.8090e67b.TwJLxEv3EfCbDTI_rjSH-A.IOQZCYhf"),
|
||||
POSE_2(2, "aida-sys-image/pose/pose-2-1.mp4", "aida-sys-image/pose/pose-2-1.gif", "aida-sys-image/pose/pose-2-first_frame.jpeg", "AACT.8090e67b.QpaGOlyLEfCuuJo8eQGF2Q.62EiJj-6"),
|
||||
// POSE_3(3, "aida-sys-image/pose/pose-3.mp4", "aida-sys-image/pose/pose-3.gif", "aida-sys-image/pose/pose-3-first_frame.jpeg", "AACT.8090e67b.gd3OCkv4EfCxyZo8eQGF2Q.qMm-a1XI"),
|
||||
POSE_3(3, "aida-sys-image/pose/pose-3-1.mp4", "aida-sys-image/pose/pose-3-1.gif", "aida-sys-image/pose/pose-3-first_frame.jpeg", "AACT.8090e67b.2q5qjFyLEfCImjI_rjSH-A.5cFMwOvi"),
|
||||
// POSE_4(4, "aida-sys-image/pose/pose-4.mp4", "aida-sys-image/pose/pose-4.gif", "aida-sys-image/pose/pose-4-first_frame.jpeg", "AACT.8090e67b.AUDnuEwDEfCEHBaRJeW4dg.rlx36xEY"),
|
||||
POSE_4(4, "aida-sys-image/pose/pose-4-1.mp4", "aida-sys-image/pose/pose-4-1.gif", "aida-sys-image/pose/pose-4-first_frame.jpeg", "AACT.8090e67b.KoYMplyPEfCuORaRJeW4dg.MuuBTG78"),
|
||||
// POSE_5(5, "aida-sys-image/pose/pose-5.mp4", "aida-sys-image/pose/pose-5.gif", "aida-sys-image/pose/pose-5-first_frame.jpeg", "AACT.8090e67b.G8BvkEwEEfCxyZo8eQGF2Q.fo4ryrgR"),
|
||||
POSE_5(5, "aida-sys-image/pose/pose-5-1.mp4", "aida-sys-image/pose/pose-5-1.gif", "aida-sys-image/pose/pose-5-first_frame.jpeg", "AACT.8090e67b.x54FNFyPEfCuuJo8eQGF2Q.P1egmEZ_"),
|
||||
// POSE_6(6, "aida-sys-image/pose/pose-6.mp4", "aida-sys-image/pose/pose-6.gif", "aida-sys-image/pose/pose-6-first_frame.jpeg", "AACT.8090e67b.yBIPnEwEEfCxyZo8eQGF2Q.boSFwTG9");
|
||||
POSE_6(6, "aida-sys-image/pose/pose-6-1.mp4", "aida-sys-image/pose/pose-6-1.gif", "aida-sys-image/pose/pose-6-first_frame.jpeg", "AACT.8090e67b.QSCvBlyQEfCImjI_rjSH-A.G9-Z5ffW");
|
||||
|
||||
|
||||
private final Integer id;
|
||||
|
||||
@@ -30,7 +30,9 @@ public class QueryLibraryPageDTO extends PageQueryBaseVo {
|
||||
@ApiModelProperty("交集还是并集:1交集2并集")
|
||||
private Integer intersection;
|
||||
|
||||
@ApiModelProperty("年龄段")
|
||||
private String ageGroup;
|
||||
|
||||
@ApiModelProperty("brandId")
|
||||
private Long brandId;
|
||||
}
|
||||
|
||||
@@ -4011,7 +4011,7 @@ public class PythonService {
|
||||
//关闭FastJson的引用检测 防止出现$ref 现象
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("image_url", url);
|
||||
map.put("is_brand_dna", Boolean.FALSE);
|
||||
map.put("is_brand_dna", Boolean.TRUE);
|
||||
log.info("bright请求python 参数:####{}", map);
|
||||
String param = JSON.toJSONString(map, SerializerFeature.WriteNullStringAsEmpty);
|
||||
log.info(param);
|
||||
|
||||
@@ -1244,7 +1244,6 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
ArrayList<PoseTransformationVO> poseTransformationVOS = new ArrayList<>();
|
||||
for (String taskId : taskIdList) {
|
||||
String type = resolveModelType(taskId, CreditsEventsEnum.POSE_TRANSFORMATION.getValue());
|
||||
PoseTransformation poseTransformation = poseTransformationMapper.selectOne(new QueryWrapper<PoseTransformation>().eq("unique_id", taskId));
|
||||
|
||||
String key = generateResultKey + ":" + taskId;
|
||||
String resultJson = redisUtil.getFromString(key);
|
||||
@@ -1266,11 +1265,15 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
} else {
|
||||
poseTransformationVO = new PoseTransformationVO(taskId, "Executing");
|
||||
}
|
||||
|
||||
PoseTransformation poseTransformation = poseTransformationMapper.selectOne(new QueryWrapper<PoseTransformation>().eq("unique_id", taskId));
|
||||
if (Objects.nonNull(poseTransformation)) {
|
||||
ToProductImageResult productResultByPath = getProductResultByPath(poseTransformation.getProductImage());
|
||||
if (Objects.nonNull(productResultByPath)) {
|
||||
Long parentId = userLikeGroupService.getParentIdByElementIdAndElementType(productResultByPath.getId(), CollectionType.TO_PRODUCT_IMAGE.getValue());
|
||||
poseTransformationVO.setParentId(parentId);
|
||||
}
|
||||
}
|
||||
poseTransformationVOS.add(poseTransformationVO);
|
||||
}
|
||||
return poseTransformationVOS;
|
||||
@@ -1380,6 +1383,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
|
||||
@Resource
|
||||
private LibraryModelPointService libraryModelPointService;
|
||||
|
||||
public String modifyModelProportion(ModifyModelProportionDTO proportionDTO) {
|
||||
log.info("modifyModelProportion params: {}", proportionDTO);
|
||||
String name;
|
||||
@@ -1434,6 +1438,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
* String collagePicture(Base64)
|
||||
* List<DTO(id, type)> elements
|
||||
* File file
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -1580,6 +1585,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
|
||||
/**
|
||||
* 创建异步任务
|
||||
*
|
||||
* @return taskId
|
||||
*/
|
||||
public String createAsyncTask(GenerateThroughImageTextDTO generateThroughImageTextDTO) {
|
||||
@@ -1633,8 +1639,9 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
|
||||
/**
|
||||
* 获取异步任务结果
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* */
|
||||
*/
|
||||
public GenerateResultVO getAsyncTaskResult(String taskId) {
|
||||
ImageSynthesis imageSynthesis = new ImageSynthesis();
|
||||
ImageSynthesisResult result = null;
|
||||
@@ -1706,6 +1713,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
private static final String TEMPLATE_ID_GEN = "https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/aa-template-generation/";
|
||||
private static final String GET_ASYNC_RESULT = "https://dashscope.aliyuncs.com/api/v1/tasks/";
|
||||
private static final String ANIMATE = "https://dashscope.aliyuncs.com/api/v1/services/aigc/image2video/video-synthesis/";
|
||||
|
||||
public String animateAnyone(PoseTransformDTO poseTransformDTO, Long accountId) {
|
||||
String inputImage = poseTransformDTO.getProductImage();
|
||||
String inputImageUrl = minioUtil.getPreSignedUrl(inputImage, CommonConstant.MINIO_IMAGE_EXPIRE_TIME);
|
||||
@@ -1941,6 +1949,10 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
Long accountId = poseTransformation.getAccountId();
|
||||
Boolean flag = creditsService.taskCreditsDeduction(accountId, taskId);
|
||||
if (flag) creditsService.updateChangedCredits(String.valueOf(accountId), taskId);
|
||||
|
||||
// 保存数据到redis
|
||||
String key = generateResultKey + ":" + taskId;
|
||||
redisUtil.addToString(key, new Gson().toJson(poseTransformationVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
}
|
||||
break;
|
||||
case STATUS_FAILED:
|
||||
@@ -1958,9 +1970,6 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
poseTransformationVO.setStatus("Fail");
|
||||
}
|
||||
poseTransformationVO.setTaskId(taskId);
|
||||
// 保存数据到redis
|
||||
String key = generateResultKey + ":" + taskId;
|
||||
redisUtil.addToString(key, new Gson().toJson(poseTransformationVO), CommonConstant.GENERATE_RESULT_EXPIRE_TIME);
|
||||
|
||||
return poseTransformationVO;
|
||||
}
|
||||
@@ -2172,6 +2181,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
|
||||
/**
|
||||
* 接入flux模型,用于imageToSketch(sketch extract) || relighting || to product image
|
||||
*
|
||||
* @param func 功能枚举名
|
||||
* @param prompt 用户输入
|
||||
* @param imagePath 图片minio路径
|
||||
|
||||
@@ -17,6 +17,8 @@ import com.ai.da.service.ProductImageService;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
@@ -29,6 +31,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ProductImageServiceImpl implements ProductImageService {
|
||||
|
||||
@@ -87,17 +90,18 @@ public class ProductImageServiceImpl implements ProductImageService {
|
||||
category = obj.getString("category_male");
|
||||
}*/
|
||||
String imgUrl = obj.getString("img_url");
|
||||
// JSONObject attribute = obj.getJSONObject("attribute");
|
||||
// AttributeRecognitionJSON attrJSON = attribute.toJavaObject(AttributeRecognitionJSON.class);
|
||||
// ProductImageAttribute attr = toAttrDict(attrJSON);
|
||||
ProductImageAttribute attr = new ProductImageAttribute();
|
||||
JSONObject attribute = obj.getJSONObject("attribute");
|
||||
AttributeRecognitionJSON attrJSON = attribute.toJavaObject(AttributeRecognitionJSON.class);
|
||||
ProductImageAttribute attr = toAttrDict(attrJSON);
|
||||
// ProductImageAttribute attr = new ProductImageAttribute();
|
||||
attr.setGender(gender);
|
||||
attr.setCategory(category);
|
||||
attr.setImgUrl(imgUrl);
|
||||
attr.setLibraryId(libraryId);
|
||||
String imageName = UUID.randomUUID().toString();
|
||||
String objectName = userHolder.getId() + "/imageToSketch/" + imageName;
|
||||
String sketchPath = pythonService.imageToSketch(imgUrl, userBucket, objectName, "2", "");
|
||||
String productImagePath = StringUtil.isNullOrEmpty(imgUrl) ? url : imgUrl;
|
||||
String sketchPath = pythonService.imageToSketch(productImagePath, userBucket, objectName, "2", "");
|
||||
attr.setImgUrl(sketchPath);
|
||||
productImageAttributeMapper.insert(attr);
|
||||
}
|
||||
@@ -110,7 +114,7 @@ public class ProductImageServiceImpl implements ProductImageService {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
log.error(e.getMessage());
|
||||
// log.error("初始化失败", e);
|
||||
redisUtil.setTaskProgressDTO(progressKey, new ProgressDTO(0, 0, true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user