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