Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94c3d1e30d |
@@ -37,7 +37,7 @@ else:
|
||||
CHROMADB_PATH = "/chromadb/"
|
||||
|
||||
# RABBITMQ_ENV = "" # 生产环境
|
||||
RABBITMQ_ENV = os.getenv("RABBITMQ_ENV", "-prod")
|
||||
RABBITMQ_ENV = os.getenv("RABBITMQ_ENV", "-dev")
|
||||
# RABBITMQ_ENV = "-local" # 本地测试环境
|
||||
|
||||
if RABBITMQ_ENV == "-dev":
|
||||
|
||||
@@ -201,10 +201,10 @@ def design_generate_v2(request_data):
|
||||
# 发送结果给java端
|
||||
url = JAVA_STREAM_API_URL
|
||||
# xu_pei_test_url = "https://cd21b9110505.ngrok-free.app/api/third/party/receiveDesignResults"
|
||||
# tianxaing_test_url = "https://c2ae520723c9.ngrok-free.app/api/third/party/receiveDesignResults"
|
||||
tianxaing_test_url = "https://c2ae520723c9.ngrok-free.app/api/third/party/receiveDesignResults"
|
||||
logger.info(f"java 回调 -> {url}")
|
||||
# logger.info(f"xupei java 回调 -> {xu_pei_test_url}")
|
||||
# logger.info(f"tianxiang java 回调 -> {tianxaing_test_url}")
|
||||
logger.info(f"tianxiang java 回调 -> {tianxaing_test_url}")
|
||||
|
||||
headers = {
|
||||
'Accept': "*/*",
|
||||
@@ -220,12 +220,12 @@ def design_generate_v2(request_data):
|
||||
logger.info(response.text)
|
||||
|
||||
# test_response = post_request(xu_pei_test_url, json_data=items_response, headers=headers)
|
||||
# test_response = post_request(tianxaing_test_url, json_data=items_response, headers=headers)
|
||||
test_response = post_request(tianxaing_test_url, json_data=items_response, headers=headers)
|
||||
|
||||
# if test_response:
|
||||
if test_response:
|
||||
# 打印结果
|
||||
# logger.info(f"xupei test response : {test_response.text}")
|
||||
# logger.info(f"tianxiang test response : {test_response.text}")
|
||||
logger.info(f"tianxiang test response : {test_response.text}")
|
||||
|
||||
for step, object in enumerate(objects_data):
|
||||
t = threading.Thread(target=process_object, args=(step, object))
|
||||
|
||||
@@ -22,7 +22,7 @@ class Color:
|
||||
resize_pattern = cv2.resize(pattern, (dim_image_w, dim_image_h), interpolation=cv2.INTER_AREA)
|
||||
# 无色
|
||||
elif "color" not in result.keys() or result['color'] == "":
|
||||
result['no_seg_sketch'] = result['final_image'] = result['pattern_image'] = result['single_image'] = result['image']
|
||||
result['final_image'] = result['pattern_image'] = result['single_image'] = result['image']
|
||||
result['alpha'] = 100 / 255.0
|
||||
return result
|
||||
# 正常颜色
|
||||
@@ -59,8 +59,6 @@ class Color:
|
||||
tmp2 = (result['final_image'] * (temp_fg / 255)).astype(np.uint8)
|
||||
result['single_image'] = cv2.add(tmp1, tmp2)
|
||||
result['alpha'] = 100 / 255.0
|
||||
|
||||
result['no_seg_sketch'] = result['final_image'].copy()
|
||||
return result
|
||||
|
||||
def get_gradient(self, bucket_name, object_name):
|
||||
|
||||
@@ -24,7 +24,6 @@ class PrintPainting:
|
||||
if result['resize_scale'][0] == 1.0 and result['resize_scale'][1] == 1.0:
|
||||
pass
|
||||
else:
|
||||
# 2025-9-19 印花调整 印花坐标按照sketch的缩放比调整
|
||||
height, width = result['pattern_image'].shape[:2]
|
||||
new_width = int(width * result['resize_scale'][0])
|
||||
new_height = int(height * result['resize_scale'][1])
|
||||
@@ -35,7 +34,6 @@ class PrintPainting:
|
||||
result['gray'] = cv2.resize(result['gray'], (new_width, new_height))
|
||||
|
||||
if overall_print['print_path_list']:
|
||||
overall_print['location'][0] = [x * y for x, y in zip(overall_print['location'][0], result['resize_scale'])]
|
||||
painting_dict = {'dim_image_h': result['pattern_image'].shape[0], 'dim_image_w': result['pattern_image'].shape[1]}
|
||||
result['print_image'] = result['pattern_image']
|
||||
if "print_angle_list" in overall_print.keys() and overall_print['print_angle_list'][0] != 0:
|
||||
@@ -52,9 +50,6 @@ class PrintPainting:
|
||||
result['single_image'] = result['final_image'] = result['pattern_image'] = result['print_image']
|
||||
|
||||
if single_print['print_path_list']:
|
||||
# 2025-9-19 印花调整 印花坐标按照sketch的缩放比调整
|
||||
sketch_resize_scale = result['resize_scale']
|
||||
|
||||
print_background = np.zeros((result['pattern_image'].shape[0], result['pattern_image'].shape[1], 3), dtype=np.uint8)
|
||||
mask_background = np.zeros((result['pattern_image'].shape[0], result['pattern_image'].shape[1], 3), dtype=np.uint8)
|
||||
for i in range(len(single_print['print_path_list'])):
|
||||
@@ -72,8 +67,8 @@ class PrintPainting:
|
||||
rotated_resized_source_mask = resized_source_mask.rotate(-single_print['print_angle_list'][i])
|
||||
source_image_pil = Image.fromarray(cv2.cvtColor(print_background, cv2.COLOR_BGR2RGB))
|
||||
source_image_pil_mask = Image.fromarray(cv2.cvtColor(mask_background, cv2.COLOR_BGR2RGB))
|
||||
source_image_pil.paste(rotated_resized_source, (int(single_print['location'][i][0] * sketch_resize_scale[0]), int(single_print['location'][i][1] * sketch_resize_scale[1])), rotated_resized_source)
|
||||
source_image_pil_mask.paste(rotated_resized_source_mask, (int(single_print['location'][i][0] * sketch_resize_scale[0]), int(single_print['location'][i][1] * sketch_resize_scale[1])), rotated_resized_source_mask)
|
||||
source_image_pil.paste(rotated_resized_source, (int(single_print['location'][i][0]), int(single_print['location'][i][1])), rotated_resized_source)
|
||||
source_image_pil_mask.paste(rotated_resized_source_mask, (int(single_print['location'][i][0]), int(single_print['location'][i][1])), rotated_resized_source_mask)
|
||||
print_background = cv2.cvtColor(np.array(source_image_pil), cv2.COLOR_RGBA2BGR)
|
||||
mask_background = cv2.cvtColor(np.array(source_image_pil_mask), cv2.COLOR_RGBA2BGR)
|
||||
ret, mask_background = cv2.threshold(mask_background, 124, 255, cv2.THRESH_BINARY)
|
||||
@@ -151,9 +146,7 @@ class PrintPainting:
|
||||
img_bg = cv2.bitwise_and(result['pattern_image'], result['pattern_image'], mask=cv2.bitwise_not(print_mask))
|
||||
mask_mo = np.expand_dims(print_mask, axis=2).repeat(3, axis=2)
|
||||
gray_mo = np.expand_dims(result['gray'], axis=2).repeat(3, axis=2)
|
||||
img_fg = (img_fg * (mask_mo / 255) * (gray_mo / 255)).astype(np.uint8) # 当sketch 图像为灰色时(非纯白) , 印花*灰度图像会导致印花在sketch上颜色变暗
|
||||
# img_fg = (img_fg * (mask_mo / 255) ).astype(np.uint8) # 不过灰度图像
|
||||
|
||||
img_fg = (img_fg * (mask_mo / 255) * (gray_mo / 255)).astype(np.uint8)
|
||||
result['final_image'] = cv2.add(img_bg, img_fg)
|
||||
canvas = np.full_like(result['final_image'], 255)
|
||||
temp_bg = np.expand_dims(cv2.bitwise_not(result['mask']), axis=2).repeat(3, axis=2)
|
||||
@@ -163,9 +156,6 @@ class PrintPainting:
|
||||
result['single_image'] = cv2.add(tmp1, tmp2)
|
||||
|
||||
if element_print['element_path_list']:
|
||||
# 2025-9-19 印花调整 印花坐标按照sketch的缩放比调整
|
||||
sketch_resize_scale = result['resize_scale']
|
||||
|
||||
print_background = np.zeros((result['final_image'].shape[0], result['final_image'].shape[1], 3), dtype=np.uint8)
|
||||
mask_background = np.zeros((result['final_image'].shape[0], result['final_image'].shape[1], 3), dtype=np.uint8)
|
||||
for i in range(len(element_print['element_path_list'])):
|
||||
@@ -183,8 +173,8 @@ class PrintPainting:
|
||||
source_image_pil = Image.fromarray(cv2.cvtColor(print_background, cv2.COLOR_BGR2RGB))
|
||||
source_image_pil_mask = Image.fromarray(cv2.cvtColor(mask_background, cv2.COLOR_BGR2RGB))
|
||||
|
||||
source_image_pil.paste(rotated_resized_source, (int(element_print['location'][i][0] * sketch_resize_scale[0]), int(element_print['location'][i][1] * sketch_resize_scale[1])), rotated_resized_source)
|
||||
source_image_pil_mask.paste(rotated_resized_source_mask, (int(element_print['location'][i][0] * sketch_resize_scale[1]), int(element_print['location'][i][1] * sketch_resize_scale[1])), rotated_resized_source_mask)
|
||||
source_image_pil.paste(rotated_resized_source, (int(element_print['location'][i][0]), int(element_print['location'][i][1])), rotated_resized_source)
|
||||
source_image_pil_mask.paste(rotated_resized_source_mask, (int(element_print['location'][i][0]), int(element_print['location'][i][1])), rotated_resized_source_mask)
|
||||
|
||||
print_background = cv2.cvtColor(np.array(source_image_pil), cv2.COLOR_RGBA2BGR)
|
||||
mask_background = cv2.cvtColor(np.array(source_image_pil_mask), cv2.COLOR_RGBA2BGR)
|
||||
|
||||
@@ -67,6 +67,7 @@ class Split(object):
|
||||
# mask_image = np.zeros((height, width, 3))
|
||||
# mask_image[front_mask != 0] = [0, 0, 255]
|
||||
|
||||
|
||||
# 切换为原始图片尺寸-------------------------------
|
||||
height, width = ori_front_mask.shape
|
||||
mask_image = np.zeros((height, width, 3))
|
||||
@@ -112,6 +113,7 @@ class Split(object):
|
||||
# mask_image[back_mask != 0] = [0, 255, 0]
|
||||
mask_image[ori_back_mask != 0] = [0, 255, 0]
|
||||
|
||||
|
||||
rbga_mask = rgb_to_rgba(mask_image, ori_front_mask + ori_back_mask)
|
||||
mask_pil = Image.fromarray(cvtColor(rbga_mask.astype(np.uint8), COLOR_BGR2RGBA))
|
||||
image_data = io.BytesIO()
|
||||
@@ -122,7 +124,7 @@ class Split(object):
|
||||
result['mask_url'] = req.bucket_name + "/" + req.object_name
|
||||
|
||||
# 创建中间图层
|
||||
result_pattern_image_rgba = rgb_to_rgba(result['no_seg_sketch'], ori_front_mask + ori_back_mask)
|
||||
result_pattern_image_rgba = rgb_to_rgba(result['pattern_image'], result['mask'])
|
||||
result_pattern_image_pil = Image.fromarray(cvtColor(result_pattern_image_rgba, COLOR_BGR2RGBA))
|
||||
result['pattern_image'], result['pattern_image_url'], _ = upload_png_mask(self.minio_client, result_pattern_image_pil, f'{generate_uuid()}')
|
||||
return result
|
||||
|
||||
@@ -57,15 +57,7 @@ def organize_clothing(layer):
|
||||
|
||||
def organize_accessories(layer):
|
||||
# 起始坐标
|
||||
start_point = (0, 0)
|
||||
layer['clothes_keypoint'] = {
|
||||
'accessories_left': [0, 0]
|
||||
}
|
||||
layer['body_point_test'] = {
|
||||
'accessories_left': [0, 0]
|
||||
}
|
||||
|
||||
start_point = calculate_start_point(layer['keypoint'], layer['scale'], layer['clothes_keypoint'], layer['body_point_test'], layer["offset"], layer["resize_scale"])
|
||||
start_point = calculate_start_point(layer['keypoint'], layer['scale'], {'accessories_left': [0, 0]}, {'accessories_left': [0, 0]}, layer["offset"], layer["resize_scale"])
|
||||
|
||||
# 前片数据
|
||||
front_layer = dict(priority=layer['priority'] if layer.get("layer_order", False) else PRIORITY_DICT.get(f'{layer["name"].lower()}_front', None),
|
||||
|
||||
Reference in New Issue
Block a user