feat
fix design load image 判断图片size 如果小于50 则resize 一倍 ,否则不能推理
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
from app.service.utils.decorator import RunTime, ClassCallRunTime
|
|
||||||
from app.service.utils.oss_client import oss_get_image
|
from app.service.utils.oss_client import oss_get_image
|
||||||
from ..builder import PIPELINES
|
from ..builder import PIPELINES
|
||||||
|
|
||||||
@@ -47,15 +46,18 @@ class LoadImageFromFile(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def read_image(image_path):
|
def read_image(image_path):
|
||||||
image_mask = None
|
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")
|
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:
|
if len(image.shape) == 2:
|
||||||
image = cv2.cvtColor(image, cv2.COLOR_GRAY2RGB)
|
image = cv2.cvtColor(image, cv2.COLOR_GRAY2RGB)
|
||||||
if image.shape[2] == 4: # 如果是四通道 mask
|
if image.shape[2] == 4: # 如果是四通道 mask
|
||||||
image_mask = image[:, :, 3]
|
image_mask = image[:, :, 3]
|
||||||
image = 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
|
return image, image_mask
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user