fix  design load image 判断图片size 如果小于50 则resize 一倍 ,否则不能推理
This commit is contained in:
zhouchengrong
2024-07-25 10:33:25 +08:00
parent 795411f96c
commit 8dd6fc924c

View File

@@ -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