From 1f45fe48a394fd13c3ae56dfe3d5edf7794d8d85 Mon Sep 17 00:00:00 2001 From: zhh Date: Tue, 23 Sep 2025 10:12:19 +0800 Subject: [PATCH 01/13] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:=20=20=20fix=EF=BC=88=E4=BF=AE=E5=A4=8Dbug=EF=BC=89:?= =?UTF-8?q?=20:=20refactor=EF=BC=88=E9=87=8D=E6=9E=84=EF=BC=89:=20test(?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95):=20=20=E5=BE=90=E4=BD=A9d?= =?UTF-8?q?esign=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design_fast/design_generate.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/service/design_fast/design_generate.py b/app/service/design_fast/design_generate.py index 786c6ba..b3e3a10 100644 --- a/app/service/design_fast/design_generate.py +++ b/app/service/design_fast/design_generate.py @@ -200,10 +200,10 @@ def design_generate_v2(request_data): items_response['synthesis_url'] = synthesis_single(item_result['front_image'], item_result['back_image']) # 发送结果给java端 url = JAVA_STREAM_API_URL - # xu_pei_test_url = "https://cd21b9110505.ngrok-free.app/api/third/party/receiveDesignResults" + xu_pei_test_url = "https://137f6b5c3490.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"xupei java 回调 -> {xu_pei_test_url}") logger.info(f"tianxiang java 回调 -> {tianxaing_test_url}") headers = { @@ -219,12 +219,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_xp_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) if test_response: # 打印结果 - # logger.info(f"xupei test response : {test_response.text}") + logger.info(f"xupei test response : {test_xp_response.text}") logger.info(f"tianxiang test response : {test_response.text}") for step, object in enumerate(objects_data): From 8f486867d5ae6a042582f2da98797d8ee267a570 Mon Sep 17 00:00:00 2001 From: zhh Date: Tue, 23 Sep 2025 10:18:06 +0800 Subject: [PATCH 02/13] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:=20=20=20fix=EF=BC=88=E4=BF=AE=E5=A4=8Dbug=EF=BC=89:?= =?UTF-8?q?=20:=20refactor=EF=BC=88=E9=87=8D=E6=9E=84=EF=BC=89:=20test(?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95):=20=20=E5=BE=90=E4=BD=A9d?= =?UTF-8?q?esign=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design_fast/design_generate.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/service/design_fast/design_generate.py b/app/service/design_fast/design_generate.py index b3e3a10..5d8bad2 100644 --- a/app/service/design_fast/design_generate.py +++ b/app/service/design_fast/design_generate.py @@ -224,8 +224,9 @@ def design_generate_v2(request_data): if test_response: # 打印结果 - logger.info(f"xupei test response : {test_xp_response.text}") logger.info(f"tianxiang test response : {test_response.text}") + if test_xp_response: + logger.info(f"xupei test response : {test_xp_response.text}") for step, object in enumerate(objects_data): t = threading.Thread(target=process_object, args=(step, object)) From d720bf2209365bc32ab309a2bd927718b9756150 Mon Sep 17 00:00:00 2001 From: zhh Date: Thu, 25 Sep 2025 15:32:23 +0800 Subject: [PATCH 03/13] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:design=20=E6=96=B0=E5=A2=9E=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E4=B8=AD=E9=97=B4=E7=BB=93=E6=9E=9C(=E6=9C=AA=E5=88=86?= =?UTF-8?q?=E5=89=B2=E5=9B=BE=E5=B1=82)=201.color=20+=20overall=5Fprint=20?= =?UTF-8?q?=202.color=20+=20overall=5Fprint=20+=20print=20fix=EF=BC=88?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=EF=BC=89:=20refactor=EF=BC=88=E9=87=8D?= =?UTF-8?q?=E6=9E=84=EF=BC=89:=20test(=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design_fast/design_generate.py | 24 +- app/service/design_fast/item.py | 5 +- app/service/design_fast/pipeline/__init__.py | 2 + app/service/design_fast/pipeline/color.py | 2 +- .../pipeline/no_seg_print_painting.py | 422 ++++++++++++++++++ .../design_fast/pipeline/print_painting.py | 2 +- app/service/design_fast/pipeline/split.py | 10 +- 7 files changed, 454 insertions(+), 13 deletions(-) create mode 100644 app/service/design_fast/pipeline/no_seg_print_painting.py diff --git a/app/service/design_fast/design_generate.py b/app/service/design_fast/design_generate.py index 5d8bad2..4c3f320 100644 --- a/app/service/design_fast/design_generate.py +++ b/app/service/design_fast/design_generate.py @@ -90,7 +90,9 @@ def design_generate(request_data): 'gradient_string': lay['gradient_string'] if 'gradient_string' in lay.keys() else "", 'mask_url': lay['mask_url'], 'image_url': lay['image_url'] if 'image_url' in lay.keys() else None, - 'pattern_image_url': lay['pattern_image_url'] if 'pattern_image_url' in lay.keys() else None, + 'pattern_overall_image': lay['pattern_overall_image'] if 'pattern_overall_image' in lay.keys() else None, + 'pattern_print_image': lay['pattern_print_image'] if 'pattern_print_image' in lay.keys() else None, + # 'back_perspective_url': lay['back_perspective_url'] if 'back_perspective_url' in lay.keys() else None, }) items_response['synthesis_url'] = synthesis(layers, new_size, basic) @@ -104,7 +106,9 @@ def design_generate(request_data): 'image_url': item_result['front_image_url'], 'mask_url': item_result['mask_url'], "gradient_string": item_result['gradient_string'] if 'gradient_string' in item_result.keys() else "", - 'pattern_image_url': item_result['pattern_image_url'] if 'pattern_image_url' in item_result.keys() else None, + 'pattern_overall_image': item_result['pattern_overall_image'] if 'pattern_overall_image' in item_result.keys() else None, + 'pattern_print_image': item_result['pattern_print_image'] if 'pattern_print_image' in item_result.keys() else None, + }) items_response['layers'].append({ 'image_category': f"{item_result['name']}_back", @@ -114,7 +118,9 @@ def design_generate(request_data): 'image_url': item_result['back_image_url'], 'mask_url': item_result['mask_url'], "gradient_string": item_result['gradient_string'] if 'gradient_string' in item_result.keys() else "", - 'pattern_image_url': item_result['pattern_image_url'] if 'pattern_image_url' in item_result.keys() else None, + 'pattern_overall_image': item_result['pattern_overall_image'] if 'pattern_overall_image' in item_result.keys() else None, + 'pattern_print_image': item_result['pattern_print_image'] if 'pattern_print_image' in item_result.keys() else None, + }) items_response['synthesis_url'] = synthesis_single(item_result['front_image'], item_result['back_image']) update_progress(process_id, total) @@ -171,7 +177,9 @@ def design_generate_v2(request_data): 'gradient_string': lay['gradient_string'] if 'gradient_string' in lay.keys() else "", 'mask_url': lay['mask_url'], 'image_url': lay['image_url'] if 'image_url' in lay.keys() else None, - 'pattern_image_url': lay['pattern_image_url'] if 'pattern_image_url' in lay.keys() else None, + 'pattern_overall_image': lay['pattern_overall_image'] if 'pattern_overall_image' in lay.keys() else None, + 'pattern_print_image': lay['pattern_print_image'] if 'pattern_print_image' in lay.keys() else None, + # 'back_perspective_url': lay['back_perspective_url'] if 'back_perspective_url' in lay.keys() else None, }) items_response['synthesis_url'] = synthesis(layers, new_size, basic) @@ -185,7 +193,9 @@ def design_generate_v2(request_data): 'image_url': item_result['front_image_url'], 'mask_url': item_result['mask_url'], "gradient_string": item_result['gradient_string'] if 'gradient_string' in item_result.keys() else "", - 'pattern_image_url': item_result['pattern_image_url'] if 'pattern_image_url' in item_result.keys() else None, + 'pattern_overall_image': item_result['pattern_overall_image'] if 'pattern_overall_image' in item_result.keys() else None, + 'pattern_print_image': item_result['pattern_print_image'] if 'pattern_print_image' in item_result.keys() else None, + }) items_response['layers'].append({ 'image_category': f"{item_result['name']}_back", @@ -195,7 +205,9 @@ def design_generate_v2(request_data): 'image_url': item_result['back_image_url'], 'mask_url': item_result['mask_url'], "gradient_string": item_result['gradient_string'] if 'gradient_string' in item_result.keys() else "", - 'pattern_image_url': item_result['pattern_image_url'] if 'pattern_image_url' in item_result.keys() else None, + 'pattern_overall_image': item_result['pattern_overall_image'] if 'pattern_overall_image' in item_result.keys() else None, + 'pattern_print_image': item_result['pattern_print_image'] if 'pattern_print_image' in item_result.keys() else None, + }) items_response['synthesis_url'] = synthesis_single(item_result['front_image'], item_result['back_image']) # 发送结果给java端 diff --git a/app/service/design_fast/item.py b/app/service/design_fast/item.py index 30aa309..74ca0c4 100644 --- a/app/service/design_fast/item.py +++ b/app/service/design_fast/item.py @@ -1,4 +1,4 @@ -from app.service.design_fast.pipeline import LoadImage, KeyPoint, Segmentation, Color, PrintPainting, Scaling, Split, LoadBodyImage, ContourDetection +from app.service.design_fast.pipeline import LoadImage, KeyPoint, Segmentation, Color, PrintPainting, Scaling, Split, LoadBodyImage, ContourDetection, NoSegPrintPainting class BaseItem: @@ -19,6 +19,7 @@ class AccessoriesItem(BaseItem): Segmentation(minio_client), # BackPerspective(minio_client), Color(minio_client), + NoSegPrintPainting(minio_client), PrintPainting(minio_client), Scaling(), Split(minio_client) @@ -39,6 +40,7 @@ class TopItem(BaseItem): Segmentation(minio_client), # BackPerspective(minio_client), Color(minio_client), + NoSegPrintPainting(minio_client), PrintPainting(minio_client), Scaling(), Split(minio_client) @@ -60,6 +62,7 @@ class BottomItem(BaseItem): Segmentation(minio_client), # BackPerspective(minio_client), Color(minio_client), + NoSegPrintPainting(minio_client), PrintPainting(minio_client), Scaling(), Split(minio_client) diff --git a/app/service/design_fast/pipeline/__init__.py b/app/service/design_fast/pipeline/__init__.py index f265bbe..dc07541 100644 --- a/app/service/design_fast/pipeline/__init__.py +++ b/app/service/design_fast/pipeline/__init__.py @@ -5,6 +5,7 @@ from .keypoint import KeyPoint from .keypoint import KeyPoint from .loading import LoadImage, LoadBodyImage from .print_painting import PrintPainting +from .no_seg_print_painting import NoSegPrintPainting from .scale import Scaling from .segmentation import Segmentation from .split import Split @@ -16,6 +17,7 @@ __all__ = [ 'Segmentation', 'BackPerspective', 'Color', + 'NoSegPrintPainting', 'PrintPainting', 'Scaling', 'Split' diff --git a/app/service/design_fast/pipeline/color.py b/app/service/design_fast/pipeline/color.py index e1d7edc..e554063 100644 --- a/app/service/design_fast/pipeline/color.py +++ b/app/service/design_fast/pipeline/color.py @@ -60,7 +60,7 @@ class Color: result['single_image'] = cv2.add(tmp1, tmp2) result['alpha'] = 100 / 255.0 - result['no_seg_sketch'] = result['final_image'].copy() + result['no_seg_sketch'] = result['no_seg_sketch_print'] = result['final_image'].copy() return result def get_gradient(self, bucket_name, object_name): diff --git a/app/service/design_fast/pipeline/no_seg_print_painting.py b/app/service/design_fast/pipeline/no_seg_print_painting.py new file mode 100644 index 0000000..492968a --- /dev/null +++ b/app/service/design_fast/pipeline/no_seg_print_painting.py @@ -0,0 +1,422 @@ +import random + +import cv2 +import numpy as np +from PIL import Image + +from app.service.utils.new_oss_client import oss_get_image + + +class NoSegPrintPainting: + def __init__(self, minio_client): + self.minio_client = minio_client + + def __call__(self, result): + single_print = result['print']['single'] + overall_print = result['print']['overall'] + element_print = result['print']['element'] + result['single_image'] = None + result['print_image'] = None + + if overall_print['print_path_list']: + painting_dict = {'dim_image_h': result['pattern_image'].shape[0], 'dim_image_w': result['pattern_image'].shape[1]} + if "print_angle_list" in overall_print.keys() and overall_print['print_angle_list'][0] != 0: + painting_dict = self.painting_collection(painting_dict, overall_print, print_trigger=True) + painting_dict['tile_print'] = self.rotate_crop_image(img=painting_dict['tile_print'], angle=-overall_print['print_angle_list'][0], crop=True) + painting_dict['mask_inv_print'] = self.rotate_crop_image(img=painting_dict['mask_inv_print'], angle=-overall_print['print_angle_list'][0], crop=True) + + # resize 到sketch大小 + painting_dict['tile_print'] = self.resize_and_crop(img=painting_dict['tile_print'], target_width=painting_dict['dim_image_w'], target_height=painting_dict['dim_image_h']) + painting_dict['mask_inv_print'] = self.resize_and_crop(img=painting_dict['mask_inv_print'], target_width=painting_dict['dim_image_w'], target_height=painting_dict['dim_image_h']) + else: + painting_dict = self.painting_collection(painting_dict, overall_print, print_trigger=True, is_single=False) + result['no_seg_sketch_print'] = self.printpaint(result, painting_dict, print_=True) + result['pattern_image'] = result['no_seg_sketch_print'] + + if single_print['print_path_list']: + 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'])): + image, image_mode = self.read_image(single_print['print_path_list'][i]) + + if image_mode == "RGB": + image_rgba = cv2.cvtColor(image, cv2.COLOR_BGR2RGBA) + image = Image.fromarray(image_rgba) + + new_size = (int(result['pattern_image'].shape[1] * single_print['print_scale_list'][i][0]), int(result['pattern_image'].shape[0] * single_print['print_scale_list'][i][1])) + mask = image.split()[3] + resized_source = image.resize(new_size) + resized_source_mask = mask.resize(new_size) + rotated_resized_source = resized_source.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_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_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) + print_mask = cv2.bitwise_and(result['mask'], cv2.cvtColor(mask_background, cv2.COLOR_BGR2GRAY)) + img_fg = cv2.bitwise_or(print_background, print_background, mask=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) + 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) # 不过灰度图像 + + final_image = cv2.add(img_bg, img_fg) + canvas = np.full_like(final_image, 255) + temp_bg = np.expand_dims(cv2.bitwise_not(result['mask']), axis=2).repeat(3, axis=2) + tmp1 = (canvas * (temp_bg / 255)).astype(np.uint8) + temp_fg = np.expand_dims(result['mask'], axis=2).repeat(3, axis=2) + tmp2 = (final_image * (temp_fg / 255)).astype(np.uint8) + single_image = cv2.add(tmp1, tmp2) + result['no_seg_sketch_print'] = single_image + + if element_print['element_path_list']: + 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'])): + image, image_mode = self.read_image(element_print['element_path_list'][i]) + if image_mode == "RGBA": + new_size = (int(result['final_image'].shape[1] * element_print['element_scale_list'][i][0]), int(result['final_image'].shape[0] * element_print['element_scale_list'][i][1])) + + mask = image.split()[3] + resized_source = image.resize(new_size) + resized_source_mask = mask.resize(new_size) + + rotated_resized_source = resized_source.rotate(-element_print['element_angle_list'][i]) + rotated_resized_source_mask = resized_source_mask.rotate(-element_print['element_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(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) + else: + mask = self.get_mask_inv(image) + mask = np.expand_dims(mask, axis=2) + mask = cv2.cvtColor(mask, cv2.COLOR_GRAY2BGR) + mask = cv2.bitwise_not(mask) + mask = cv2.resize(mask, (int(result['final_image'].shape[1] * single_print['print_scale_list'][i][0]), int(result['final_image'].shape[0] * single_print['print_scale_list'][i][1]))) + image = cv2.resize(image, (int(result['final_image'].shape[1] * single_print['print_scale_list'][i][0]), int(result['final_image'].shape[0] * single_print['print_scale_list'][i][1]))) + # 旋转后的坐标需要重新算 + rotate_mask, _ = self.img_rotate(mask, element_print['element_angle_list'][i]) + rotate_image, rotated_new_size = self.img_rotate(image, element_print['element_angle_list'][i]) + # x, y = int(result['print']['location'][i][0] - rotated_new_size[0] - (rotate_mask.shape[0] - image.shape[0]) / 2), int(result['print']['location'][i][1] - rotated_new_size[1] - (rotate_mask.shape[1] - image.shape[1]) / 2) + x, y = int(element_print['location'][i][0] - rotated_new_size[0]), int(element_print['location'][i][1] - rotated_new_size[1]) + + image_x = print_background.shape[1] + image_y = print_background.shape[0] + print_x = rotate_image.shape[1] + print_y = rotate_image.shape[0] + + if x <= 0: + rotate_image = rotate_image[:, -x:] + rotate_mask = rotate_mask[:, -x:] + start_x = x = 0 + else: + start_x = x + + if y <= 0: + rotate_image = rotate_image[-y:, :] + rotate_mask = rotate_mask[-y:, :] + start_y = y = 0 + else: + start_y = y + + if x + print_x > image_x: + rotate_image = rotate_image[:, :image_x - x] + rotate_mask = rotate_mask[:, :image_x - x] + + if y + print_y > image_y: + rotate_image = rotate_image[:image_y - y, :] + rotate_mask = rotate_mask[:image_y - y, :] + + mask_background = self.stack_prin(mask_background, result['pattern_image'], rotate_mask, start_y, y, start_x, x) + print_background = self.stack_prin(print_background, result['pattern_image'], rotate_image, start_y, y, start_x, x) + + print_mask = cv2.bitwise_and(result['mask'], cv2.cvtColor(mask_background, cv2.COLOR_BGR2GRAY)) + img_fg = cv2.bitwise_or(print_background, print_background, mask=print_mask) + three_channel_image = cv2.merge([cv2.bitwise_not(print_mask), cv2.bitwise_not(print_mask), cv2.bitwise_not(print_mask)]) + img_bg = cv2.bitwise_and(result['final_image'], three_channel_image) + 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) + tmp1 = (canvas * (temp_bg / 255)).astype(np.uint8) + temp_fg = np.expand_dims(result['mask'], axis=2).repeat(3, axis=2) + tmp2 = (result['final_image'] * (temp_fg / 255)).astype(np.uint8) + result['no_seg_sketch_print'] = cv2.add(tmp1, tmp2) + + return result + + @staticmethod + def stack_prin(print_background, pattern_image, rotate_image, start_y, y, start_x, x): + temp_print = np.zeros((pattern_image.shape[0], pattern_image.shape[1], 3), dtype=np.uint8) + temp_print[start_y:y + rotate_image.shape[0], start_x:x + rotate_image.shape[1]] = rotate_image + img2gray = cv2.cvtColor(temp_print, cv2.COLOR_BGR2GRAY) + ret, mask_ = cv2.threshold(img2gray, 1, 255, cv2.THRESH_BINARY) + mask_inv = cv2.bitwise_not(mask_) + img1_bg = cv2.bitwise_and(print_background, print_background, mask=mask_inv) + img2_fg = cv2.bitwise_and(temp_print, temp_print, mask=mask_) + print_background = img1_bg + img2_fg + return print_background + + def painting_collection(self, painting_dict, print_dict, print_trigger=False, is_single=False): + if print_trigger: + print_ = self.get_print(print_dict) + painting_dict['Trigger'] = not is_single + painting_dict['location'] = print_['location'] + single_mask_inv_print = self.get_mask_inv(print_['image']) + dim_max = max(painting_dict['dim_image_h'], painting_dict['dim_image_w']) + dim_pattern = (int(dim_max * print_['scale'] / 5), int(dim_max * print_['scale'] / 5)) + if not is_single: + self.random_seed = random.randint(0, 1000) + # 如果print 模式为overall 且 有角度的话 , 组合的print为正方形,方便裁剪 + if "print_angle_list" in print_dict.keys() and print_dict['print_angle_list'][0] != 0: + painting_dict['mask_inv_print'] = self.tile_image(single_mask_inv_print, dim_pattern, print_['scale'], dim_max, dim_max, painting_dict['location'], trigger=True) + painting_dict['tile_print'] = self.tile_image(print_['image'], dim_pattern, print_['scale'], dim_max, dim_max, painting_dict['location'], trigger=True) + else: + painting_dict['mask_inv_print'] = self.tile_image(single_mask_inv_print, dim_pattern, print_['scale'], painting_dict['dim_image_h'], painting_dict['dim_image_w'], painting_dict['location'], trigger=True) + painting_dict['tile_print'] = self.tile_image(print_['image'], dim_pattern, print_['scale'], painting_dict['dim_image_h'], painting_dict['dim_image_w'], painting_dict['location'], trigger=True) + else: + painting_dict['mask_inv_print'] = self.tile_image(single_mask_inv_print, dim_pattern, print_['scale'], painting_dict['dim_image_h'], painting_dict['dim_image_w'], painting_dict['location']) + painting_dict['tile_print'] = self.tile_image(print_['image'], dim_pattern, print_['scale'], painting_dict['dim_image_h'], painting_dict['dim_image_w'], painting_dict['location']) + painting_dict['dim_print_h'], painting_dict['dim_print_w'] = dim_pattern + return painting_dict + + def tile_image(self, pattern, dim, scale, dim_image_h, dim_image_w, location, trigger=False): + tile = None + if not trigger: + tile = cv2.resize(pattern, dim, interpolation=cv2.INTER_AREA) + else: + resize_pattern = cv2.resize(pattern, dim, interpolation=cv2.INTER_AREA) + if len(pattern.shape) == 2: + tile = np.tile(resize_pattern, (int((5 + 1) / scale) + 4, int((5 + 1) / scale) + 4)) + if len(pattern.shape) == 3: + tile = np.tile(resize_pattern, (int((5 + 1) / scale) + 4, int((5 + 1) / scale) + 4, 1)) + tile = self.crop_image(tile, dim_image_h, dim_image_w, location, resize_pattern.shape) + return tile + + def get_mask_inv(self, print_): + if print_[0][0][0] == 255 and print_[0][0][1] == 255 and print_[0][0][2] == 255: + bg_color = cv2.cvtColor(print_, cv2.COLOR_BGR2LAB)[0][0] + print_tile = cv2.cvtColor(print_, cv2.COLOR_BGR2LAB) + bg_l, bg_a, bg_b = bg_color[0], bg_color[1], bg_color[2] + bg_L_high, bg_L_low = self.get_low_high_lab(bg_l, L=True) + bg_a_high, bg_a_low = self.get_low_high_lab(bg_a) + bg_b_high, bg_b_low = self.get_low_high_lab(bg_b) + lower = np.array([bg_L_low, bg_a_low, bg_b_low]) + upper = np.array([bg_L_high, bg_a_high, bg_b_high]) + mask_inv = cv2.inRange(print_tile, lower, upper) + return mask_inv + else: + mask_inv = np.zeros(print_.shape[:2], dtype=np.uint8) + return mask_inv + + @staticmethod + def printpaint(result, painting_dict, print_=False): + + if print_ and painting_dict['Trigger']: + print_mask = cv2.bitwise_and(result['mask'], cv2.bitwise_not(painting_dict['mask_inv_print'])) + img_fg = cv2.bitwise_and(painting_dict['tile_print'], painting_dict['tile_print'], mask=print_mask) + else: + print_mask = result['mask'] + img_fg = result['final_image'] + if print_ and not painting_dict['Trigger']: + index_ = None + try: + index_ = len(painting_dict['location']) + except: + assert f'there must be parameter of location if choose IfSingle' + + for i in range(index_): + start_h, start_w = int(painting_dict['location'][i][1]), int(painting_dict['location'][i][0]) + + length_h = min(start_h + painting_dict['dim_print_h'], img_fg.shape[0]) + length_w = min(start_w + painting_dict['dim_print_w'], img_fg.shape[1]) + + change_region = img_fg[start_h: length_h, start_w: length_w, :] + # problem in change_mask + change_mask = print_mask[start_h: length_h, start_w: length_w] + # get real part into change mask + _, change_mask = cv2.threshold(change_mask, 220, 255, cv2.THRESH_BINARY) + mask = cv2.bitwise_not(painting_dict['mask_inv_print']) + img_fg[start_h:start_h + painting_dict['dim_print_h'], start_w:start_w + painting_dict['dim_print_w'], :] = change_region + + clothes_mask_print = cv2.bitwise_not(print_mask) + + img_bg = cv2.bitwise_and(result['pattern_image'], result['pattern_image'], mask=clothes_mask_print) + 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) + print_image = cv2.add(img_bg, img_fg) + return print_image + + def get_print(self, print_dict): + if 'print_scale_list' not in print_dict.keys() or print_dict['print_scale_list'][0][0] < 0.3: + print_dict['scale'] = 0.3 + else: + print_dict['scale'] = print_dict['print_scale_list'][0][0] + + bucket_name = print_dict['print_path_list'][0].split("/", 1)[0] + object_name = print_dict['print_path_list'][0].split("/", 1)[1] + image = oss_get_image(oss_client=self.minio_client, bucket=bucket_name, object_name=object_name, data_type="PIL") + # 判断图片格式,如果是RGBA 则贴在一张纯白图片上 防止透明转黑 + if image.mode == "RGBA": + new_background = Image.new('RGB', image.size, (255, 255, 255)) + new_background.paste(image, mask=image.split()[3]) + image = new_background + print_dict['image'] = cv2.cvtColor(np.asarray(image), cv2.COLOR_RGB2BGR) + return print_dict + + def crop_image(self, image, image_size_h, image_size_w, location, print_shape): + print_w = print_shape[1] + print_h = print_shape[0] + + random.seed(self.random_seed) + + # 1.拿到偏移量后和resize后的print宽高取余 得到真正偏移量 + # 偏移量增加2分之print.w 使坐标位于图中间 如果要位于左上角删除+ print_w // 2 即可 + x_offset = print_w - int(location[0][1] % print_w) + print_w // 2 + y_offset = print_h - int(location[0][0] % print_h) + print_h // 2 + + # y_offset = int(location[0][0]) + # x_offset = int(location[0][1]) + + if len(image.shape) == 2: + image = image[x_offset: x_offset + image_size_h, y_offset: y_offset + image_size_w] + elif len(image.shape) == 3: + image = image[x_offset: x_offset + image_size_h, y_offset: y_offset + image_size_w, :] + return image + + @staticmethod + def get_low_high_lab(Lab_value, L=False): + if L: + high = Lab_value + 30 if Lab_value + 30 < 255 else 255 + low = Lab_value - 30 if Lab_value - 30 > 0 else 0 + else: + high = Lab_value + 30 if Lab_value + 30 < 255 else 255 + low = Lab_value - 30 if Lab_value - 30 > 0 else 0 + return high, low + + @staticmethod + def img_rotate(image, angel): + """顺时针旋转图像任意角度 + + Args: + image (np.array): [原始图像] + angel (float): [逆时针旋转的角度] + + Returns: + [array]: [旋转后的图像] + """ + + h, w = image.shape[:2] + center = (w // 2, h // 2) + # if type(angel) is not int: + # angel = 0 + M = cv2.getRotationMatrix2D(center, -angel, 1) + # 调整旋转后的图像长宽 + rotated_h = int((w * np.abs(M[0, 1]) + (h * np.abs(M[0, 0])))) + rotated_w = int((h * np.abs(M[0, 1]) + (w * np.abs(M[0, 0])))) + M[0, 2] += (rotated_w - w) // 2 + M[1, 2] += (rotated_h - h) // 2 + # 旋转图像 + rotated_img = cv2.warpAffine(image, M, (rotated_w, rotated_h)) + + return rotated_img, ((rotated_img.shape[1] - image.shape[1]) // 2, (rotated_img.shape[0] - image.shape[0]) // 2) + # return rotated_img, (0, 0) + + @staticmethod + def rotate_crop_image(img, angle, crop): + """ + angle: 旋转的角度 + crop: 是否需要进行裁剪,布尔向量 + """ + if not isinstance(crop, bool): + raise ValueError("The 'crop' parameter must be a boolean.") + + crop_image = lambda img, x0, y0, w, h: img[y0:y0 + h, x0:x0 + w] + h, w = img.shape[:2] + # 旋转角度的周期是360° + angle %= 360 + # 计算仿射变换矩阵 + M_rotation = cv2.getRotationMatrix2D((w / 2, h / 2), angle, 1) + # 得到旋转后的图像 + img_rotated = cv2.warpAffine(img, M_rotation, (w, h)) + + # 如果需要去除黑边 + if crop: + # 裁剪角度的等效周期是180° + angle_crop = angle % 180 + if angle_crop > 90: + angle_crop = 180 - angle_crop + # 转化角度为弧度 + theta = angle_crop * np.pi / 180 + # 计算高宽比 + hw_ratio = float(h) / float(w) + # 计算裁剪边长系数的分子项 + tan_theta = np.tan(theta) + numerator = np.cos(theta) + np.sin(theta) * np.tan(theta) + + # 计算分母中和高宽比相关的项 + r = hw_ratio if h > w else 1 / hw_ratio + # 计算分母项 + denominator = r * tan_theta + 1 + # 最终的边长系数 + crop_mult = numerator / denominator + + # 得到裁剪区域 + w_crop = int(crop_mult * w) + h_crop = int(crop_mult * h) + x0 = int((w - w_crop) / 2) + y0 = int((h - h_crop) / 2) + + img_rotated = crop_image(img_rotated, x0, y0, w_crop, h_crop) + + return img_rotated + + def read_image(self, image_url): + image = oss_get_image(oss_client=self.minio_client, bucket=image_url.split("/", 1)[0], object_name=image_url.split("/", 1)[1], data_type="cv2") + if image.shape[2] == 4: + image_rgb = cv2.cvtColor(image, cv2.COLOR_BGRA2RGBA) + image = Image.fromarray(image_rgb) + image_mode = "RGBA" + else: + image_mode = "RGB" + return image, image_mode + + @staticmethod + def resize_and_crop(img, target_width, target_height): + # 获取原始图像的尺寸 + original_height, original_width = img.shape[:2] + + # 计算目标尺寸的宽高比 + target_ratio = target_width / target_height + + # 计算原始图像的宽高比 + original_ratio = original_width / original_height + + # 调整尺寸 + if original_ratio > target_ratio: + # 原始图像更宽,按高度resize,然后裁剪宽度 + new_height = target_height + new_width = int(original_width * (target_height / original_height)) + resized_img = cv2.resize(img, (new_width, new_height)) + # 裁剪宽度 + start_x = (new_width - target_width) // 2 + cropped_img = resized_img[:, start_x:start_x + target_width] + else: + # 原始图像更高,按宽度resize,然后裁剪高度 + new_width = target_width + new_height = int(original_height * (target_width / original_width)) + resized_img = cv2.resize(img, (new_width, new_height)) + # 裁剪高度 + start_y = (new_height - target_height) // 2 + cropped_img = resized_img[start_y:start_y + target_height, :] + + return cropped_img diff --git a/app/service/design_fast/pipeline/print_painting.py b/app/service/design_fast/pipeline/print_painting.py index b9bebfc..2dff103 100644 --- a/app/service/design_fast/pipeline/print_painting.py +++ b/app/service/design_fast/pipeline/print_painting.py @@ -184,7 +184,7 @@ class PrintPainting: 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_mask.paste(rotated_resized_source_mask, (int(element_print['location'][i][0] * sketch_resize_scale[0]), 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) mask_background = cv2.cvtColor(np.array(source_image_pil_mask), cv2.COLOR_RGBA2BGR) diff --git a/app/service/design_fast/pipeline/split.py b/app/service/design_fast/pipeline/split.py index 1abba05..5b0184f 100644 --- a/app/service/design_fast/pipeline/split.py +++ b/app/service/design_fast/pipeline/split.py @@ -121,10 +121,12 @@ class Split(object): req = oss_upload_image(oss_client=self.minio_client, bucket=AIDA_CLOTHING, object_name=f"mask/mask_{generate_uuid()}.png", image_bytes=image_bytes) 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_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()}') + # 创建中间图层(未分割图层) 1.color + overall_print 2.color + overall_print + print + result_pattern_overall_image_pil = Image.fromarray(cvtColor(rgb_to_rgba(result['no_seg_sketch'], ori_front_mask + ori_back_mask), COLOR_BGR2RGBA)) + result['pattern_overall_image'], result['pattern_overall_image_url'], _ = upload_png_mask(self.minio_client, result_pattern_overall_image_pil, f'{generate_uuid()}') + + result_pattern_print_image_pil = Image.fromarray(cvtColor(rgb_to_rgba(result['no_seg_sketch_print'], ori_front_mask + ori_back_mask), COLOR_BGR2RGBA)) + result['pattern_print_image'], result['pattern_print_image_url'], _ = upload_png_mask(self.minio_client, result_pattern_print_image_pil, f'{generate_uuid()}') return result except Exception as e: logging.warning(f"split runtime exception : {e} image_id : {result['image_id']}") From bf1fb8e514df99ad35d6bf33a4d684c730832ea7 Mon Sep 17 00:00:00 2001 From: zhh Date: Thu, 25 Sep 2025 15:39:17 +0800 Subject: [PATCH 04/13] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:design=20=E6=96=B0=E5=A2=9E=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E4=B8=AD=E9=97=B4=E7=BB=93=E6=9E=9C(=E6=9C=AA=E5=88=86?= =?UTF-8?q?=E5=89=B2=E5=9B=BE=E5=B1=82)=201.color=20+=20overall=5Fprint=20?= =?UTF-8?q?=202.color=20+=20overall=5Fprint=20+=20print=20fix=EF=BC=88?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=EF=BC=89:=20refactor=EF=BC=88=E9=87=8D?= =?UTF-8?q?=E6=9E=84=EF=BC=89:=20test(=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design_fast/design_generate.py | 26 +++++++++++----------- app/service/design_fast/utils/organize.py | 13 +++++++---- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/service/design_fast/design_generate.py b/app/service/design_fast/design_generate.py index 4c3f320..1ef5a3b 100644 --- a/app/service/design_fast/design_generate.py +++ b/app/service/design_fast/design_generate.py @@ -79,7 +79,7 @@ def design_generate(request_data): layers = sorted(layers, key=lambda s: s.get("priority", float('inf'))) layers, new_size = update_base_size_priority(layers, body_size) - + # pattern_overall_image_url 、 pattern_print_image_url for lay in layers: items_response['layers'].append({ 'image_category': "body" if lay['name'] == 'mannequin' else lay['name'], @@ -90,8 +90,8 @@ def design_generate(request_data): 'gradient_string': lay['gradient_string'] if 'gradient_string' in lay.keys() else "", 'mask_url': lay['mask_url'], 'image_url': lay['image_url'] if 'image_url' in lay.keys() else None, - 'pattern_overall_image': lay['pattern_overall_image'] if 'pattern_overall_image' in lay.keys() else None, - 'pattern_print_image': lay['pattern_print_image'] if 'pattern_print_image' in lay.keys() else None, + 'pattern_overall_image_url': lay['pattern_overall_image_url'] if 'pattern_overall_image_url' in lay.keys() else None, + 'pattern_print_image_url': lay['pattern_print_image_url'] if 'pattern_print_image_url' in lay.keys() else None, # 'back_perspective_url': lay['back_perspective_url'] if 'back_perspective_url' in lay.keys() else None, }) @@ -106,8 +106,8 @@ def design_generate(request_data): 'image_url': item_result['front_image_url'], 'mask_url': item_result['mask_url'], "gradient_string": item_result['gradient_string'] if 'gradient_string' in item_result.keys() else "", - 'pattern_overall_image': item_result['pattern_overall_image'] if 'pattern_overall_image' in item_result.keys() else None, - 'pattern_print_image': item_result['pattern_print_image'] if 'pattern_print_image' in item_result.keys() else None, + 'pattern_overall_image_url': item_result['pattern_overall_image_url'] if 'pattern_overall_image_url' in item_result.keys() else None, + 'pattern_print_image_url': item_result['pattern_print_image_url'] if 'pattern_print_image_url' in item_result.keys() else None, }) items_response['layers'].append({ @@ -118,8 +118,8 @@ def design_generate(request_data): 'image_url': item_result['back_image_url'], 'mask_url': item_result['mask_url'], "gradient_string": item_result['gradient_string'] if 'gradient_string' in item_result.keys() else "", - 'pattern_overall_image': item_result['pattern_overall_image'] if 'pattern_overall_image' in item_result.keys() else None, - 'pattern_print_image': item_result['pattern_print_image'] if 'pattern_print_image' in item_result.keys() else None, + 'pattern_overall_image_url': item_result['pattern_overall_image_url'] if 'pattern_overall_image_url' in item_result.keys() else None, + 'pattern_print_image_url': item_result['pattern_print_image_url'] if 'pattern_print_image_url' in item_result.keys() else None, }) items_response['synthesis_url'] = synthesis_single(item_result['front_image'], item_result['back_image']) @@ -177,8 +177,8 @@ def design_generate_v2(request_data): 'gradient_string': lay['gradient_string'] if 'gradient_string' in lay.keys() else "", 'mask_url': lay['mask_url'], 'image_url': lay['image_url'] if 'image_url' in lay.keys() else None, - 'pattern_overall_image': lay['pattern_overall_image'] if 'pattern_overall_image' in lay.keys() else None, - 'pattern_print_image': lay['pattern_print_image'] if 'pattern_print_image' in lay.keys() else None, + 'pattern_overall_image_url': lay['pattern_overall_image_url'] if 'pattern_overall_image_url' in lay.keys() else None, + 'pattern_print_image_url': lay['pattern_print_image_url'] if 'pattern_print_image_url' in lay.keys() else None, # 'back_perspective_url': lay['back_perspective_url'] if 'back_perspective_url' in lay.keys() else None, }) @@ -193,8 +193,8 @@ def design_generate_v2(request_data): 'image_url': item_result['front_image_url'], 'mask_url': item_result['mask_url'], "gradient_string": item_result['gradient_string'] if 'gradient_string' in item_result.keys() else "", - 'pattern_overall_image': item_result['pattern_overall_image'] if 'pattern_overall_image' in item_result.keys() else None, - 'pattern_print_image': item_result['pattern_print_image'] if 'pattern_print_image' in item_result.keys() else None, + 'pattern_overall_image_url': item_result['pattern_overall_image_url'] if 'pattern_overall_image_url' in item_result.keys() else None, + 'pattern_print_image_url': item_result['pattern_print_image_url'] if 'pattern_print_image_url' in item_result.keys() else None, }) items_response['layers'].append({ @@ -205,8 +205,8 @@ def design_generate_v2(request_data): 'image_url': item_result['back_image_url'], 'mask_url': item_result['mask_url'], "gradient_string": item_result['gradient_string'] if 'gradient_string' in item_result.keys() else "", - 'pattern_overall_image': item_result['pattern_overall_image'] if 'pattern_overall_image' in item_result.keys() else None, - 'pattern_print_image': item_result['pattern_print_image'] if 'pattern_print_image' in item_result.keys() else None, + 'pattern_overall_image_url': item_result['pattern_overall_image_url'] if 'pattern_overall_image_url' in item_result.keys() else None, + 'pattern_print_image_url': item_result['pattern_print_image_url'] if 'pattern_print_image_url' in item_result.keys() else None, }) items_response['synthesis_url'] = synthesis_single(item_result['front_image'], item_result['back_image']) diff --git a/app/service/design_fast/utils/organize.py b/app/service/design_fast/utils/organize.py index 26bfa48..f5c8144 100644 --- a/app/service/design_fast/utils/organize.py +++ b/app/service/design_fast/utils/organize.py @@ -32,7 +32,9 @@ def organize_clothing(layer): resize_scale=layer["resize_scale"], mask=cv2.resize(layer['mask'], layer["front_image"].size), gradient_string=layer['gradient_string'] if 'gradient_string' in layer.keys() else "", - pattern_image_url=layer['pattern_image_url'], + pattern_overall_image_url=layer['pattern_overall_image_url'], + pattern_print_image_url=layer['pattern_print_image_url'], + pattern_image=layer['pattern_image'], # back_perspective_url=layer['back_perspective_url'] if 'back_perspective_url' in layer.keys() else "" ) @@ -49,7 +51,8 @@ def organize_clothing(layer): resize_scale=layer["resize_scale"], mask=cv2.resize(layer['mask'], layer["front_image"].size), gradient_string=layer['gradient_string'] if 'gradient_string' in layer.keys() else "", - pattern_image_url=layer['pattern_image_url'], + pattern_overall_image_url=layer['pattern_overall_image_url'], + pattern_print_image_url=layer['pattern_print_image_url'], # back_perspective_url=layer['back_perspective_url'] if 'back_perspective_url' in layer.keys() else "" ) return front_layer, back_layer @@ -80,7 +83,8 @@ def organize_accessories(layer): resize_scale=layer["resize_scale"], mask=cv2.resize(layer['mask'], layer["front_image"].size), gradient_string=layer['gradient_string'] if 'gradient_string' in layer.keys() else "", - pattern_image_url=layer['pattern_image_url'], + pattern_overall_image_url=layer['pattern_overall_image_url'], + pattern_print_image_url=layer['pattern_print_image_url'], pattern_image=layer['pattern_image'], # back_perspective_url=layer['back_perspective_url'] if 'back_perspective_url' in layer.keys() else "" ) @@ -97,7 +101,8 @@ def organize_accessories(layer): resize_scale=layer["resize_scale"], mask=cv2.resize(layer['mask'], layer["front_image"].size), gradient_string=layer['gradient_string'] if 'gradient_string' in layer.keys() else "", - pattern_image_url=layer['pattern_image_url'], + pattern_overall_image_url=layer['pattern_overall_image_url'], + pattern_print_image_url=layer['pattern_print_image_url'], # back_perspective_url=layer['back_perspective_url'] if 'back_perspective_url' in layer.keys() else "" ) return front_layer, back_layer From 4bc79e62ca95087d19b24dda338eb816a8b2e678 Mon Sep 17 00:00:00 2001 From: zhh Date: Thu, 25 Sep 2025 16:01:28 +0800 Subject: [PATCH 05/13] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:design=20=E6=96=B0=E5=A2=9E=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E4=B8=AD=E9=97=B4=E7=BB=93=E6=9E=9C(=E6=9C=AA=E5=88=86?= =?UTF-8?q?=E5=89=B2=E5=9B=BE=E5=B1=82)=201.color=20+=20overall=5Fprint=20?= =?UTF-8?q?=202.color=20+=20overall=5Fprint=20+=20print=20fix=EF=BC=88?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=EF=BC=89:=20refactor=EF=BC=88=E9=87=8D?= =?UTF-8?q?=E6=9E=84=EF=BC=89:=20test(=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design_fast/pipeline/color.py | 4 ++-- app/service/design_fast/pipeline/no_seg_print_painting.py | 4 ++-- app/service/design_fast/pipeline/split.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/service/design_fast/pipeline/color.py b/app/service/design_fast/pipeline/color.py index e554063..32e550b 100644 --- a/app/service/design_fast/pipeline/color.py +++ b/app/service/design_fast/pipeline/color.py @@ -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['no_seg_sketch_overall'] = result['no_seg_sketch_print'] = result['final_image'] = result['pattern_image'] = result['single_image'] = result['image'] result['alpha'] = 100 / 255.0 return result # 正常颜色 @@ -60,7 +60,7 @@ class Color: result['single_image'] = cv2.add(tmp1, tmp2) result['alpha'] = 100 / 255.0 - result['no_seg_sketch'] = result['no_seg_sketch_print'] = result['final_image'].copy() + result['no_seg_sketch_overall'] = result['no_seg_sketch_print'] = result['final_image'].copy() return result def get_gradient(self, bucket_name, object_name): diff --git a/app/service/design_fast/pipeline/no_seg_print_painting.py b/app/service/design_fast/pipeline/no_seg_print_painting.py index 492968a..145dd41 100644 --- a/app/service/design_fast/pipeline/no_seg_print_painting.py +++ b/app/service/design_fast/pipeline/no_seg_print_painting.py @@ -30,8 +30,8 @@ class NoSegPrintPainting: painting_dict['mask_inv_print'] = self.resize_and_crop(img=painting_dict['mask_inv_print'], target_width=painting_dict['dim_image_w'], target_height=painting_dict['dim_image_h']) else: painting_dict = self.painting_collection(painting_dict, overall_print, print_trigger=True, is_single=False) - result['no_seg_sketch_print'] = self.printpaint(result, painting_dict, print_=True) - result['pattern_image'] = result['no_seg_sketch_print'] + result['no_seg_sketch_overall'] = self.printpaint(result, painting_dict, print_=True) + result['pattern_image'] = result['no_seg_sketch_overall'] if single_print['print_path_list']: print_background = np.zeros((result['pattern_image'].shape[0], result['pattern_image'].shape[1], 3), dtype=np.uint8) diff --git a/app/service/design_fast/pipeline/split.py b/app/service/design_fast/pipeline/split.py index 5b0184f..d0d7511 100644 --- a/app/service/design_fast/pipeline/split.py +++ b/app/service/design_fast/pipeline/split.py @@ -122,7 +122,7 @@ class Split(object): result['mask_url'] = req.bucket_name + "/" + req.object_name # 创建中间图层(未分割图层) 1.color + overall_print 2.color + overall_print + print - result_pattern_overall_image_pil = Image.fromarray(cvtColor(rgb_to_rgba(result['no_seg_sketch'], ori_front_mask + ori_back_mask), COLOR_BGR2RGBA)) + result_pattern_overall_image_pil = Image.fromarray(cvtColor(rgb_to_rgba(result['no_seg_sketch_overall'], ori_front_mask + ori_back_mask), COLOR_BGR2RGBA)) result['pattern_overall_image'], result['pattern_overall_image_url'], _ = upload_png_mask(self.minio_client, result_pattern_overall_image_pil, f'{generate_uuid()}') result_pattern_print_image_pil = Image.fromarray(cvtColor(rgb_to_rgba(result['no_seg_sketch_print'], ori_front_mask + ori_back_mask), COLOR_BGR2RGBA)) From 0d4d464e3f01cc0b3077555970f0b4a342452202 Mon Sep 17 00:00:00 2001 From: zhh Date: Fri, 26 Sep 2025 10:29:39 +0800 Subject: [PATCH 06/13] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:=201=E3=80=81design-print=E4=B8=BA=E8=A7=A3=E5=86=B3s?= =?UTF-8?q?ketch=E5=8E=9F=E5=9B=BE=E5=A4=AA=E7=81=B0=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=8D=B0=E8=8A=B1=E9=A2=9C=E8=89=B2=E4=BE=BF=E6=9A=97=202?= =?UTF-8?q?=E3=80=81cv2.resize=20=20=E6=8F=92=E5=80=BC=E7=AE=97=E6=B3=95?= =?UTF-8?q?=E6=9B=B4=E6=8D=A2=EF=BC=8C=E6=8F=90=E5=8D=87resize=E5=90=8E?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=B4=A8=E9=87=8F=20fix=EF=BC=88=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dbug=EF=BC=89:=20refactor=EF=BC=88=E9=87=8D=E6=9E=84?= =?UTF-8?q?=EF=BC=89:=20test(=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design_fast/pipeline/loading.py | 33 ++++++++++++++++++++- app/service/design_fast/pipeline/split.py | 14 ++++----- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/app/service/design_fast/pipeline/loading.py b/app/service/design_fast/pipeline/loading.py index 5a55d9d..329e14b 100644 --- a/app/service/design_fast/pipeline/loading.py +++ b/app/service/design_fast/pipeline/loading.py @@ -1,5 +1,6 @@ import io import logging +import os import cv2 import numpy as np @@ -38,12 +39,42 @@ class LoadImage: def __call__(self, result): result['image'], result['pre_mask'] = self.read_image(result['path']) - result['gray'] = cv2.cvtColor(result['image'], cv2.COLOR_BGR2GRAY) + # if 'extract_lines' in result.keys(): + # if result['extract_lines']: + # result['gray'] = self.get_lines(cv2.cvtColor(result['image'], cv2.COLOR_BGR2GRAY), result['path']) + # else: + # result['gray'] = cv2.cvtColor(result['image'], cv2.COLOR_BGR2GRAY) + # else: + # result['gray'] = cv2.cvtColor(result['image'], cv2.COLOR_BGR2GRAY) + + result['gray'] = self.get_lines(cv2.cvtColor(result['image'], cv2.COLOR_BGR2GRAY), result['path']) result['keypoint'] = self.get_keypoint(result['name']) result['img_shape'] = result['image'].shape result['ori_shape'] = result['image'].shape return result + def get_lines(self, img, path): + binary = cv2.adaptiveThreshold(img, 255, + cv2.ADAPTIVE_THRESH_GAUSSIAN_C, + cv2.THRESH_BINARY_INV, + 25, 10) + + # 步骤2:细化边缘(可选,让线条更干净) + # kernel = np.ones((1, 1), np.uint8) + # clean = cv2.morphologyEx(binary, cv2.MORPH_OPEN, kernel) + + thinned = cv2.ximgproc.thinning(binary, thinningType=cv2.ximgproc.THINNING_ZHANGSUEN) # thinning算法细化线条 + mask = thinned > 0 + result = np.ones_like(img) * 255 + result[mask] = img[mask] + + # 步骤3:反转回 白底黑线 + # lines = cv2.bitwise_not(thinned) + # cv2.imwrite(os.path.join('/home/user/PycharmProjects/trinity_client_aida/test/lines_original_result_5', f"Original_{path.replace('/', '-')}.png"), img) + # cv2.imwrite(os.path.join('/home/user/PycharmProjects/trinity_client_aida/test/lines_original_result_5', f"Line_{path.replace('/', '-')}.png"), result) + + return result + def read_image(self, image_path): image_mask = None image = oss_get_image(oss_client=self.minio_client, bucket=image_path.split("/", 1)[0], object_name=image_path.split("/", 1)[1], data_type="cv2") diff --git a/app/service/design_fast/pipeline/split.py b/app/service/design_fast/pipeline/split.py index d0d7511..5c62899 100644 --- a/app/service/design_fast/pipeline/split.py +++ b/app/service/design_fast/pipeline/split.py @@ -32,14 +32,14 @@ class Split(object): new_width = int(width * result['resize_scale'][0]) new_height = int(height * result['resize_scale'][1]) - front_mask = cv2.resize(result['front_mask'], (new_width, new_height)) - back_mask = cv2.resize(result['back_mask'], (new_width, new_height)) + front_mask = cv2.resize(result['front_mask'], (new_width, new_height), interpolation=cv2.INTER_AREA) + back_mask = cv2.resize(result['back_mask'], (new_width, new_height), interpolation=cv2.INTER_AREA) rgba_image = rgb_to_rgba(result['final_image'], front_mask + back_mask) new_size = (int(rgba_image.shape[1] * result["scale"]), int(rgba_image.shape[0] * result["scale"])) - rgba_image = cv2.resize(rgba_image, new_size) + rgba_image = cv2.resize(rgba_image, new_size, interpolation=cv2.INTER_AREA) result_front_image = np.zeros_like(rgba_image) - front_mask = cv2.resize(front_mask, new_size) + front_mask = cv2.resize(front_mask, new_size, interpolation=cv2.INTER_AREA) result_front_image[front_mask != 0] = rgba_image[front_mask != 0] result_front_image_pil = Image.fromarray(cvtColor(result_front_image, COLOR_BGR2RGBA)) if 'transparent' in result.keys(): @@ -48,7 +48,7 @@ class Split(object): if transparent['mask_url'] is not None and transparent['mask_url'] != "": # 预处理用户自选区mask seg_mask = oss_get_image(oss_client=self.minio_client, bucket=transparent['mask_url'].split('/')[0], object_name=transparent['mask_url'][transparent['mask_url'].find('/') + 1:], data_type="cv2") - seg_mask = cv2.resize(seg_mask, new_size, interpolation=cv2.INTER_NEAREST) + seg_mask = cv2.resize(seg_mask, new_size, interpolation=cv2.INTER_AREA) # 转换颜色空间为 RGB(OpenCV 默认是 BGR) image_rgb = cv2.cvtColor(seg_mask, cv2.COLOR_BGR2RGB) @@ -75,7 +75,7 @@ class Split(object): # if result["name"] in ('blouse', 'dress', 'outwear', 'tops'): # result_back_image = np.zeros_like(rgba_image) - # back_mask = cv2.resize(back_mask, new_size) + # back_mask = cv2.resize(back_mask, new_size, interpolation=cv2.INTER_AREA) # result_back_image[back_mask != 0] = rgba_image[back_mask != 0] # result_back_image_pil = Image.fromarray(cvtColor(result_back_image, COLOR_BGR2RGBA)) # result['back_image'], result["back_image_url"], _ = upload_png_mask(self.minio_client, result_back_image_pil, f'{generate_uuid()}', mask=None) @@ -104,7 +104,7 @@ class Split(object): # # result['back_mask_image'] = None result_back_image = np.zeros_like(rgba_image) - back_mask = cv2.resize(back_mask, new_size) + back_mask = cv2.resize(back_mask, new_size, interpolation=cv2.INTER_AREA) result_back_image[back_mask != 0] = rgba_image[back_mask != 0] result_back_image_pil = Image.fromarray(cvtColor(result_back_image, COLOR_BGR2RGBA)) result['back_image'], result["back_image_url"], _ = upload_png_mask(self.minio_client, result_back_image_pil, f'{generate_uuid()}', mask=None) From e966ed5aa5e0dfeb8b952399b3881dd345340c31 Mon Sep 17 00:00:00 2001 From: zhh Date: Fri, 26 Sep 2025 10:44:29 +0800 Subject: [PATCH 07/13] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:=201=E3=80=81design-print=E4=B8=BA=E8=A7=A3=E5=86=B3s?= =?UTF-8?q?ketch=E5=8E=9F=E5=9B=BE=E5=A4=AA=E7=81=B0=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=8D=B0=E8=8A=B1=E9=A2=9C=E8=89=B2=E4=BE=BF=E6=9A=97=20=20?= =?UTF-8?q?=E4=B8=8A=E8=89=B2=E9=83=A8=E5=88=86=E4=BD=BF=E7=94=A8=E5=8E=9F?= =?UTF-8?q?=E5=A7=8B=E6=96=B9=E6=A1=88=202=E3=80=81cv2.resize=20=20?= =?UTF-8?q?=E6=8F=92=E5=80=BC=E7=AE=97=E6=B3=95=E6=9B=B4=E6=8D=A2=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E5=8D=87resize=E5=90=8E=E5=9B=BE=E7=89=87=E8=B4=A8?= =?UTF-8?q?=E9=87=8F=20fix=EF=BC=88=E4=BF=AE=E5=A4=8Dbug=EF=BC=89:=20refac?= =?UTF-8?q?tor=EF=BC=88=E9=87=8D=E6=9E=84=EF=BC=89:=20test(=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B5=8B=E8=AF=95):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design_fast/pipeline/color.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/service/design_fast/pipeline/color.py b/app/service/design_fast/pipeline/color.py index 32e550b..99ba8eb 100644 --- a/app/service/design_fast/pipeline/color.py +++ b/app/service/design_fast/pipeline/color.py @@ -48,7 +48,7 @@ class Color: resize_pattern[mask_3ch] = png_rgb[mask_3ch] resize_pattern = cv2.resize(resize_pattern, (dim_image_w, dim_image_h), interpolation=cv2.INTER_AREA) closed_mo = np.expand_dims(result['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(cv2.cvtColor(result['image'], cv2.COLOR_BGR2GRAY), axis=2).repeat(3, axis=2) get_image_fir = resize_pattern * (closed_mo / 255) * (gray_mo / 255) result['pattern_image'] = get_image_fir.astype(np.uint8) result['final_image'] = result['pattern_image'] From 95647be6105560f9f74e90268d30438d8ec449c7 Mon Sep 17 00:00:00 2001 From: zhh Date: Fri, 26 Sep 2025 13:20:26 +0800 Subject: [PATCH 08/13] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:=20=20fix=EF=BC=88=E4=BF=AE=E5=A4=8Dbug=EF=BC=89:desi?= =?UTF-8?q?gn=E7=9A=84=E5=AE=BD=E5=BA=A6=E8=87=AA=E9=80=82=E5=BA=94-?= =?UTF-8?q?=E5=AE=BD=E5=BA=A6=E7=AE=97=E6=B3=95=E4=BF=AE=E5=A4=8D=20refact?= =?UTF-8?q?or=EF=BC=88=E9=87=8D=E6=9E=84=EF=BC=89:=20test(=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B5=8B=E8=AF=95):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design_fast/utils/synthesis_item.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/service/design_fast/utils/synthesis_item.py b/app/service/design_fast/utils/synthesis_item.py index 79e53df..d46795e 100644 --- a/app/service/design_fast/utils/synthesis_item.py +++ b/app/service/design_fast/utils/synthesis_item.py @@ -207,7 +207,9 @@ def update_base_size_priority(layers, size): if info['name'] == 'mannequin': new_height = info['image'].height max_x = max(x_list) - new_width = max_x - min_x * 2 + + # x坐标中最小偏移量的绝对值 + 最大偏移量 + new_width = max_x + abs(min_x) # 更新坐标 for info in layers: info['adaptive_position'] = (info['position'][0], info['position'][1] - min_x) From b8cf3d25b4455ad317bd6dd47ea171f14248ee51 Mon Sep 17 00:00:00 2001 From: zhh Date: Fri, 26 Sep 2025 14:46:03 +0800 Subject: [PATCH 09/13] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:=E6=9B=B4=E6=8D=A2=E7=BF=BB=E8=AF=91=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=EF=BC=8C=E5=85=B3=E9=97=AD=E8=AF=AD=E7=A7=8D=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=80=BB=E8=BE=91=20=20fix=EF=BC=88=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?bug=EF=BC=89:=20refactor=EF=BC=88=E9=87=8D=E6=9E=84=EF=BC=89:?= =?UTF-8?q?=20test(=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prompt_generation/chatgpt_for_translation.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/service/prompt_generation/chatgpt_for_translation.py b/app/service/prompt_generation/chatgpt_for_translation.py index 4c50d0b..7933952 100644 --- a/app/service/prompt_generation/chatgpt_for_translation.py +++ b/app/service/prompt_generation/chatgpt_for_translation.py @@ -90,20 +90,20 @@ def get_response(messages): def get_translation_from_llama3(text): start_time = time.time() - url = "http://10.1.1.240:11434/api/generate" - # url = "http://10.1.1.240:1143/api/generate" + # url = "http://10.1.1.240:11434/api/generate" + url = "http://10.1.1.243:11434/api/generate" # prompt = f"System: {prefix_for_llama}\nUser:[{text}]" # 先获取用户输入文本的语言 - language = get_language(text) + # language = get_language(text) - if 'English' in language: - return text + # if 'English' in language: + # return text # 创建请求的负载 translator是自定义的翻译模型 payload = { - "model": "translator", + "model": "zcr_gemma3_translator:4b", "prompt": f"[{text}]", "stream": False } @@ -178,7 +178,7 @@ def get_prompt_from_image(image_path, text): def main(): """Main function""" - text = get_translation_from_llama3("[火焰]") + text = get_translation_from_llama3("[123]") print(text) From 242ebfc1df9f85cf0b6c598293405aa8a3e5e1d4 Mon Sep 17 00:00:00 2001 From: zhh Date: Fri, 26 Sep 2025 14:51:24 +0800 Subject: [PATCH 10/13] =?UTF-8?q?Revert=20"feat=EF=BC=88=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=89:=E6=9B=B4=E6=8D=A2=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=EF=BC=8C=E5=85=B3=E9=97=AD=E8=AF=AD=E7=A7=8D?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91=20=20fix=EF=BC=88=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dbug=EF=BC=89:=20refactor=EF=BC=88=E9=87=8D=E6=9E=84?= =?UTF-8?q?=EF=BC=89:=20test(=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95):"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit b8cf3d25b4455ad317bd6dd47ea171f14248ee51. --- .../prompt_generation/chatgpt_for_translation.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/service/prompt_generation/chatgpt_for_translation.py b/app/service/prompt_generation/chatgpt_for_translation.py index 7933952..4c50d0b 100644 --- a/app/service/prompt_generation/chatgpt_for_translation.py +++ b/app/service/prompt_generation/chatgpt_for_translation.py @@ -90,20 +90,20 @@ def get_response(messages): def get_translation_from_llama3(text): start_time = time.time() - # url = "http://10.1.1.240:11434/api/generate" - url = "http://10.1.1.243:11434/api/generate" + url = "http://10.1.1.240:11434/api/generate" + # url = "http://10.1.1.240:1143/api/generate" # prompt = f"System: {prefix_for_llama}\nUser:[{text}]" # 先获取用户输入文本的语言 - # language = get_language(text) + language = get_language(text) - # if 'English' in language: - # return text + if 'English' in language: + return text # 创建请求的负载 translator是自定义的翻译模型 payload = { - "model": "zcr_gemma3_translator:4b", + "model": "translator", "prompt": f"[{text}]", "stream": False } @@ -178,7 +178,7 @@ def get_prompt_from_image(image_path, text): def main(): """Main function""" - text = get_translation_from_llama3("[123]") + text = get_translation_from_llama3("[火焰]") print(text) From d1fefceebf0dbbde001e52d27b6b216d024d0ea9 Mon Sep 17 00:00:00 2001 From: zhh Date: Fri, 26 Sep 2025 17:52:24 +0800 Subject: [PATCH 11/13] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:single=20=E5=89=8D=E5=90=8E=E7=89=87=E4=BC=98?= =?UTF-8?q?=E5=85=88=E7=BA=A7=E9=BB=98=E8=AE=A4=E4=B8=BA20,-20=20=20fix?= =?UTF-8?q?=EF=BC=88=E4=BF=AE=E5=A4=8Dbug=EF=BC=89:=20refactor=EF=BC=88?= =?UTF-8?q?=E9=87=8D=E6=9E=84=EF=BC=89:=20test(=E5=A2=9E=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design_fast/design_generate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/service/design_fast/design_generate.py b/app/service/design_fast/design_generate.py index 1ef5a3b..8a18ab7 100644 --- a/app/service/design_fast/design_generate.py +++ b/app/service/design_fast/design_generate.py @@ -102,7 +102,7 @@ def design_generate(request_data): 'image_category': f"{item_result['name']}_front", 'image_size': item_result['back_image'].size if item_result['back_image'] else None, 'position': None, - 'priority': 0, + 'priority': 20, 'image_url': item_result['front_image_url'], 'mask_url': item_result['mask_url'], "gradient_string": item_result['gradient_string'] if 'gradient_string' in item_result.keys() else "", @@ -114,7 +114,7 @@ def design_generate(request_data): 'image_category': f"{item_result['name']}_back", 'image_size': item_result['front_image'].size if item_result['front_image'] else None, 'position': None, - 'priority': 0, + 'priority': -20, 'image_url': item_result['back_image_url'], 'mask_url': item_result['mask_url'], "gradient_string": item_result['gradient_string'] if 'gradient_string' in item_result.keys() else "", From 1d90963dedf79e58b96b9bb4ec8e6630d9d331bc Mon Sep 17 00:00:00 2001 From: zhh Date: Fri, 26 Sep 2025 18:05:46 +0800 Subject: [PATCH 12/13] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:=E5=9B=9E=E6=BA=AF-single=20=E5=89=8D=E5=90=8E?= =?UTF-8?q?=E7=89=87=E4=BC=98=E5=85=88=E7=BA=A7=E9=BB=98=E8=AE=A4=E4=B8=BA?= =?UTF-8?q?20,-20=20=20fix=EF=BC=88=E4=BF=AE=E5=A4=8Dbug=EF=BC=89:=20refac?= =?UTF-8?q?tor=EF=BC=88=E9=87=8D=E6=9E=84=EF=BC=89:=20test(=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B5=8B=E8=AF=95):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design_fast/design_generate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/service/design_fast/design_generate.py b/app/service/design_fast/design_generate.py index 8a18ab7..1ef5a3b 100644 --- a/app/service/design_fast/design_generate.py +++ b/app/service/design_fast/design_generate.py @@ -102,7 +102,7 @@ def design_generate(request_data): 'image_category': f"{item_result['name']}_front", 'image_size': item_result['back_image'].size if item_result['back_image'] else None, 'position': None, - 'priority': 20, + 'priority': 0, 'image_url': item_result['front_image_url'], 'mask_url': item_result['mask_url'], "gradient_string": item_result['gradient_string'] if 'gradient_string' in item_result.keys() else "", @@ -114,7 +114,7 @@ def design_generate(request_data): 'image_category': f"{item_result['name']}_back", 'image_size': item_result['front_image'].size if item_result['front_image'] else None, 'position': None, - 'priority': -20, + 'priority': 0, 'image_url': item_result['back_image_url'], 'mask_url': item_result['mask_url'], "gradient_string": item_result['gradient_string'] if 'gradient_string' in item_result.keys() else "", From 02ad5db26973909eb0f99fccfb6d459b67b5cde7 Mon Sep 17 00:00:00 2001 From: zhh Date: Fri, 26 Sep 2025 22:58:11 +0800 Subject: [PATCH 13/13] =?UTF-8?q?feat=EF=BC=88=E6=96=B0=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=89:=20fix=EF=BC=88=E4=BF=AE=E5=A4=8Dbug=EF=BC=89:?= =?UTF-8?q?=E4=B8=A4=E7=A7=8D=E6=9C=AA=E5=88=86=E5=89=B2sketch=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20refactor=EF=BC=88=E9=87=8D=E6=9E=84=EF=BC=89:=20tes?= =?UTF-8?q?t(=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design_fast/pipeline/no_seg_print_painting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/service/design_fast/pipeline/no_seg_print_painting.py b/app/service/design_fast/pipeline/no_seg_print_painting.py index 145dd41..029d580 100644 --- a/app/service/design_fast/pipeline/no_seg_print_painting.py +++ b/app/service/design_fast/pipeline/no_seg_print_painting.py @@ -30,7 +30,7 @@ class NoSegPrintPainting: painting_dict['mask_inv_print'] = self.resize_and_crop(img=painting_dict['mask_inv_print'], target_width=painting_dict['dim_image_w'], target_height=painting_dict['dim_image_h']) else: painting_dict = self.painting_collection(painting_dict, overall_print, print_trigger=True, is_single=False) - result['no_seg_sketch_overall'] = self.printpaint(result, painting_dict, print_=True) + result['no_seg_sketch_overall'] = result['no_seg_sketch_print'] = self.printpaint(result, painting_dict, print_=True) result['pattern_image'] = result['no_seg_sketch_overall'] if single_print['print_path_list']: