From 8dd6fc924c14ef9f68f8e7e4c5fe556b063c3645 Mon Sep 17 00:00:00 2001 From: zhouchengrong Date: Thu, 25 Jul 2024 10:33:25 +0800 Subject: [PATCH] =?UTF-8?q?feat=20fix=20=20design=20load=20image=20?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E5=9B=BE=E7=89=87size=20=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E5=B0=8F=E4=BA=8E50=20=E5=88=99resize=20=E4=B8=80=E5=80=8D=20?= =?UTF-8?q?=EF=BC=8C=E5=90=A6=E5=88=99=E4=B8=8D=E8=83=BD=E6=8E=A8=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/design/items/pipelines/loading.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/service/design/items/pipelines/loading.py b/app/service/design/items/pipelines/loading.py index f0f4188..04dc4d8 100644 --- a/app/service/design/items/pipelines/loading.py +++ b/app/service/design/items/pipelines/loading.py @@ -1,6 +1,5 @@ import cv2 -from app.service.utils.decorator import RunTime, ClassCallRunTime from app.service.utils.oss_client import oss_get_image from ..builder import PIPELINES @@ -47,15 +46,18 @@ class LoadImageFromFile(object): @staticmethod def read_image(image_path): image_mask = None - # file = self.minio_client.get_object(image_path.split("/", 1)[0], image_path.split("/", 1)[1]).data - # image = cv2.imdecode(np.frombuffer(file, np.uint8), 1) - image = oss_get_image(bucket=image_path.split("/", 1)[0], object_name=image_path.split("/", 1)[1], data_type="cv2") if len(image.shape) == 2: image = cv2.cvtColor(image, cv2.COLOR_GRAY2RGB) if image.shape[2] == 4: # 如果是四通道 mask image_mask = image[:, :, 3] image = image[:, :, :3] + + if image.shape[:2] <= (50, 50): + # 计算新尺寸 + new_size = (image.shape[1] * 2, image.shape[0] * 2) + # 调整大小 + image = cv2.resize(image, new_size, interpolation=cv2.INTER_LINEAR) return image, image_mask