From 5e9101e77dcd3fd3d983b768e2771ec9a90fbfaf Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Fri, 7 Feb 2025 14:21:46 +0800 Subject: [PATCH 1/9] =?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:=20=20s?= =?UTF-8?q?ketch=E6=8B=89=E4=BC=B8=E5=AF=BC=E8=87=B4=E7=9A=84print?= =?UTF-8?q?=E6=AF=94=E4=BE=8B=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20docs=EF=BC=88=E6=96=87=E6=A1=A3=E5=8F=98=E6=9B=B4=EF=BC=89:?= =?UTF-8?q?=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):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design_fast/pipeline/print_painting.py | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/app/service/design_fast/pipeline/print_painting.py b/app/service/design_fast/pipeline/print_painting.py index 417572f..fd5f910 100644 --- a/app/service/design_fast/pipeline/print_painting.py +++ b/app/service/design_fast/pipeline/print_painting.py @@ -53,9 +53,12 @@ class PrintPainting: 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'])): + if not (result['resize_scale'][0] == 1.0 and result['resize_scale'][1] == 1.0): + single_print['location'][i] = (int(single_print['location'][i][0] * result['resize_scale'][0]), int(single_print['location'][i][1] * result['resize_scale'][1])) + image, image_mode = self.read_image(single_print['print_path_list'][i]) if image_mode == "RGBA": - new_size = (int(image.width * single_print['print_scale_list'][i]), int(image.height * single_print['print_scale_list'][i])) + 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) @@ -78,9 +81,12 @@ class PrintPainting: 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[0] * single_print['print_scale_list'][i][0]), int(result['final_image'].shape[1] * single_print['print_scale_list'][i][1]))) + image = cv2.resize(image, (int(result['final_image'].shape[0] * single_print['print_scale_list'][i][0]), int(result['final_image'].shape[1] * single_print['print_scale_list'][i][1]))) # 旋转后的坐标需要重新算 - rotate_mask, _ = self.img_rotate(mask, single_print['print_angle_list'][i], single_print['print_scale_list'][i]) - rotate_image, rotated_new_size = self.img_rotate(image, single_print['print_angle_list'][i], single_print['print_scale_list'][i]) + rotate_mask, _ = self.img_rotate(mask, single_print['print_angle_list'][i]) + rotate_image, rotated_new_size = self.img_rotate(image, single_print['print_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(single_print['location'][i][0] - rotated_new_size[0]), int(single_print['location'][i][1] - rotated_new_size[1]) @@ -157,9 +163,11 @@ class PrintPainting: 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'])): + if not (result['resize_scale'][0] == 1.0 and result['resize_scale'][1] == 1.0): + element_print['location'][i] = (int(element_print['location'][i][0] * result['resize_scale'][0]), int(element_print['location'][i][1] * result['resize_scale'][1])) image, image_mode = self.read_image(element_print['element_path_list'][i]) if image_mode == "RGBA": - new_size = (int(image.width * element_print['element_scale_list'][i]), int(image.height * element_print['element_scale_list'][i])) + 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) @@ -181,9 +189,11 @@ class PrintPainting: 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[0] * single_print['print_scale_list'][i][0]), int(result['final_image'].shape[1] * single_print['print_scale_list'][i][1]))) + image = cv2.resize(image, (int(result['final_image'].shape[0] * single_print['print_scale_list'][i][0]), int(result['final_image'].shape[1] * single_print['print_scale_list'][i][1]))) # 旋转后的坐标需要重新算 - rotate_mask, _ = self.img_rotate(mask, element_print['element_angle_list'][i], element_print['element_scale_list'][i]) - rotate_image, rotated_new_size = self.img_rotate(image, element_print['element_angle_list'][i], element_print['element_scale_list'][i]) + 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]) @@ -425,7 +435,7 @@ class PrintPainting: return high, low @staticmethod - def img_rotate(image, angel, scale): + def img_rotate(image, angel): """顺时针旋转图像任意角度 Args: @@ -440,7 +450,7 @@ class PrintPainting: center = (w // 2, h // 2) # if type(angel) is not int: # angel = 0 - M = cv2.getRotationMatrix2D(center, -angel, scale) + 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])))) @@ -449,7 +459,7 @@ class PrintPainting: # 旋转图像 rotated_img = cv2.warpAffine(image, M, (rotated_w, rotated_h)) - return rotated_img, ((rotated_img.shape[1] - image.shape[1] * scale) // 2, (rotated_img.shape[0] - image.shape[0] * scale) // 2) + 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 From 89e39e37ae3b0a5e05856ba51235515dfdd23c96 Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Fri, 7 Feb 2025 14:46:07 +0800 Subject: [PATCH 2/9] =?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:=20=20s?= =?UTF-8?q?ketch=E6=8B=89=E4=BC=B8=E5=AF=BC=E8=87=B4=E7=9A=84print?= =?UTF-8?q?=E6=AF=94=E4=BE=8B=E4=B8=8D=E6=AD=A3=E7=A1=AE=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20docs=EF=BC=88=E6=96=87=E6=A1=A3=E5=8F=98=E6=9B=B4=EF=BC=89:?= =?UTF-8?q?=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):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/prompt_generation/chatgpt_for_translation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/service/prompt_generation/chatgpt_for_translation.py b/app/service/prompt_generation/chatgpt_for_translation.py index e668500..e86a6bf 100644 --- a/app/service/prompt_generation/chatgpt_for_translation.py +++ b/app/service/prompt_generation/chatgpt_for_translation.py @@ -106,7 +106,7 @@ def get_translation_from_llama3(text): "prompt": f"[{text}]", "stream": False } - + logger.info(f"translation start ********************* {text}") # 将负载转换为 JSON 格式 headers = {'Content-Type': 'application/json'} response = requests.post(url, data=json.dumps(payload), headers=headers) From 2e4c43178d74c3551e56082b28ed86de5d73b768 Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Fri, 7 Feb 2025 15:04:59 +0800 Subject: [PATCH 3/9] =?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:=20=20?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E5=88=A4=E6=96=AD=E9=83=A8=E5=88=86=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=20=E5=85=B3=E5=81=9C=E8=AF=A5=E9=80=BB=E8=BE=91=20doc?= =?UTF-8?q?s=EF=BC=88=E6=96=87=E6=A1=A3=E5=8F=98=E6=9B=B4=EF=BC=89:=20refa?= =?UTF-8?q?ctor=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/prompt_generation/chatgpt_for_translation.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/service/prompt_generation/chatgpt_for_translation.py b/app/service/prompt_generation/chatgpt_for_translation.py index e86a6bf..833eda0 100644 --- a/app/service/prompt_generation/chatgpt_for_translation.py +++ b/app/service/prompt_generation/chatgpt_for_translation.py @@ -95,10 +95,10 @@ def get_translation_from_llama3(text): # 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 = { @@ -106,7 +106,6 @@ def get_translation_from_llama3(text): "prompt": f"[{text}]", "stream": False } - logger.info(f"translation start ********************* {text}") # 将负载转换为 JSON 格式 headers = {'Content-Type': 'application/json'} response = requests.post(url, data=json.dumps(payload), headers=headers) From c73bfcaaa86d4997cc22c6d8dc8ba08056f4465c Mon Sep 17 00:00:00 2001 From: xupei Date: Fri, 7 Feb 2025 15:32:41 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E8=AF=AD=E8=A8=80=E5=88=A4=E6=96=AD=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat_robot/script/service/CallQWen.py | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/app/service/chat_robot/script/service/CallQWen.py b/app/service/chat_robot/script/service/CallQWen.py index cb7669b..780d206 100644 --- a/app/service/chat_robot/script/service/CallQWen.py +++ b/app/service/chat_robot/script/service/CallQWen.py @@ -304,20 +304,38 @@ def tutorial_tool(): def get_language(message: str) -> str: messages = [ { - "content": message, # 用户message + "content": GET_LANGUAGE_PREFIX, # ai message + "role": "system" + }, + { + "content": "Tree", # 用户message "role": "user" }, { - "content": GET_LANGUAGE_PREFIX, # ai message + "content": "English", # 用户message "role": "assistant" + }, + { + "content": "玩具", # 用户message + "role": "user" + }, + { + "content": "Chinese", # 用户message + "role": "assistant" + }, + { + "content": message, # 用户message + "role": "user" } ] first_response = get_response(messages) assistant_output = first_response.output.choices[0].message.content logging.info(f"大模型输出信息:{first_response}\n判断用户输入的语言为:{assistant_output}") + # print(f"大模型输出信息:{first_response}\n判断用户输入的语言为:{assistant_output}") return assistant_output if __name__ == '__main__': - get_language("") + for _ in range(4): + get_language("森林") From ab7534e2c53b96a3c335cfed7d1cefae3b5294e9 Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Fri, 7 Feb 2025 15:35:08 +0800 Subject: [PATCH 5/9] =?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:=20=20?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E5=88=A4=E6=96=AD=E9=83=A8=E5=88=86=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=20=E5=85=B3=E5=81=9C=E8=AF=A5=E9=80=BB=E8=BE=91=20doc?= =?UTF-8?q?s=EF=BC=88=E6=96=87=E6=A1=A3=E5=8F=98=E6=9B=B4=EF=BC=89:=20refa?= =?UTF-8?q?ctor=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/prompt_generation/chatgpt_for_translation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/service/prompt_generation/chatgpt_for_translation.py b/app/service/prompt_generation/chatgpt_for_translation.py index 833eda0..b6d8692 100644 --- a/app/service/prompt_generation/chatgpt_for_translation.py +++ b/app/service/prompt_generation/chatgpt_for_translation.py @@ -95,10 +95,10 @@ def get_translation_from_llama3(text): # 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 = { From b3bd433b2cc7e749b52b8cf8e792ce8bd8553dd4 Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Fri, 7 Feb 2025 16:46:42 +0800 Subject: [PATCH 6/9] =?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:=20=20p?= =?UTF-8?q?rint=5Fpainting.py=20=E5=9D=90=E6=A0=87=E7=AE=97=E6=B3=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20docs=EF=BC=88=E6=96=87=E6=A1=A3=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=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/print_painting.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/service/design_fast/pipeline/print_painting.py b/app/service/design_fast/pipeline/print_painting.py index fd5f910..9405fed 100644 --- a/app/service/design_fast/pipeline/print_painting.py +++ b/app/service/design_fast/pipeline/print_painting.py @@ -53,9 +53,6 @@ class PrintPainting: 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'])): - if not (result['resize_scale'][0] == 1.0 and result['resize_scale'][1] == 1.0): - single_print['location'][i] = (int(single_print['location'][i][0] * result['resize_scale'][0]), int(single_print['location'][i][1] * result['resize_scale'][1])) - image, image_mode = self.read_image(single_print['print_path_list'][i]) if image_mode == "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])) @@ -163,8 +160,6 @@ class PrintPainting: 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'])): - if not (result['resize_scale'][0] == 1.0 and result['resize_scale'][1] == 1.0): - element_print['location'][i] = (int(element_print['location'][i][0] * result['resize_scale'][0]), int(element_print['location'][i][1] * result['resize_scale'][1])) 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])) From ae5ea713800d926aaa9cecc391ffdceff5f9a472 Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Fri, 7 Feb 2025 17:23:35 +0800 Subject: [PATCH 7/9] =?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:=20=20p?= =?UTF-8?q?rint=5Fpainting.py=20=E5=9D=90=E6=A0=87=E7=AE=97=E6=B3=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20docs=EF=BC=88=E6=96=87=E6=A1=A3=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=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/print_painting.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/service/design_fast/pipeline/print_painting.py b/app/service/design_fast/pipeline/print_painting.py index 9405fed..0aa7011 100644 --- a/app/service/design_fast/pipeline/print_painting.py +++ b/app/service/design_fast/pipeline/print_painting.py @@ -79,8 +79,8 @@ class PrintPainting: mask = cv2.cvtColor(mask, cv2.COLOR_GRAY2BGR) mask = cv2.bitwise_not(mask) - mask = cv2.resize(mask, (int(result['final_image'].shape[0] * single_print['print_scale_list'][i][0]), int(result['final_image'].shape[1] * single_print['print_scale_list'][i][1]))) - image = cv2.resize(image, (int(result['final_image'].shape[0] * single_print['print_scale_list'][i][0]), int(result['final_image'].shape[1] * single_print['print_scale_list'][i][1]))) + 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, single_print['print_angle_list'][i]) rotate_image, rotated_new_size = self.img_rotate(image, single_print['print_angle_list'][i]) @@ -184,8 +184,8 @@ class PrintPainting: 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[0] * single_print['print_scale_list'][i][0]), int(result['final_image'].shape[1] * single_print['print_scale_list'][i][1]))) - image = cv2.resize(image, (int(result['final_image'].shape[0] * single_print['print_scale_list'][i][0]), int(result['final_image'].shape[1] * single_print['print_scale_list'][i][1]))) + 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]) From 62509cfc573e49ddb149e3bf75c4a437b0c505c5 Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Fri, 7 Feb 2025 17:55:09 +0800 Subject: [PATCH 8/9] =?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:=20=20p?= =?UTF-8?q?rint=5Fpainting.py=20=E5=9D=90=E6=A0=87=E7=AE=97=E6=B3=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20docs=EF=BC=88=E6=96=87=E6=A1=A3=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=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/print_painting.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/service/design_fast/pipeline/print_painting.py b/app/service/design_fast/pipeline/print_painting.py index 0aa7011..980981c 100644 --- a/app/service/design_fast/pipeline/print_painting.py +++ b/app/service/design_fast/pipeline/print_painting.py @@ -381,10 +381,10 @@ class PrintPainting: 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.3: + 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] + 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] From e2271e31d95cc30a019d32fbad33003c4de9fd00 Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Mon, 10 Feb 2025 17:12:02 +0800 Subject: [PATCH 9/9] =?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:=20=20p?= =?UTF-8?q?rint=5Fpainting.py=20=E5=9D=90=E6=A0=87=E7=AE=97=E6=B3=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=20docs=EF=BC=88=E6=96=87=E6=A1=A3=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=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/print_painting.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/service/design_fast/pipeline/print_painting.py b/app/service/design_fast/pipeline/print_painting.py index 980981c..2f97474 100644 --- a/app/service/design_fast/pipeline/print_painting.py +++ b/app/service/design_fast/pipeline/print_painting.py @@ -407,12 +407,14 @@ class PrintPainting: # y_offset = random.randint(0, image.shape[1] - image_size_w) # 1.拿到偏移量后和resize后的print宽高取余 得到真正偏移量 - x_offset = print_w - int(location[0][1] % print_w) - y_offset = print_w - int(location[0][0] % print_h) + # 偏移量增加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: