feat
fix 重写所有resize代码,mmcv替换为cv
This commit is contained in:
@@ -27,7 +27,10 @@ from app.core.config import *
|
||||
def keypoint_preprocess(img_path):
|
||||
img = mmcv.imread(img_path)
|
||||
img_scale = (256, 256)
|
||||
img, w_scale, h_scale = mmcv.imresize(img, img_scale, return_scale=True)
|
||||
h, w = img.shape[:2]
|
||||
w_scale = img_scale[0] / w
|
||||
h_scale = img_scale[1] / h
|
||||
img = cv2.resize(img, img_scale, interpolation=cv2.INTER_LINEAR)
|
||||
img = mmcv.imnormalize(img, mean=np.array([123.675, 116.28, 103.53]), std=np.array([58.395, 57.12, 57.375]), to_rgb=True)
|
||||
preprocessed_img = np.expand_dims(img.transpose(2, 0, 1), axis=0)
|
||||
return preprocessed_img, (w_scale, h_scale)
|
||||
@@ -80,9 +83,8 @@ def seg_preprocess(img_path):
|
||||
img_scale_h = 1024
|
||||
# 如果图片size任意一边 大于 1024, 则会resize 成1024
|
||||
if ori_shape != (img_scale_w, img_scale_h):
|
||||
# TODO 取消代码中所有 关于mmcv的resize
|
||||
# mmcv.imresize(img, img_scale_h, img_scale_w) # 老代码 引以为戒!哈哈哈~ h和w写反了
|
||||
img = cv2.resize(img, (img_scale_h, img_scale_w))
|
||||
img = cv2.resize(img, (img_scale_h, img_scale_w), interpolation=cv2.INTER_LINEAR)
|
||||
img = mmcv.imnormalize(img, mean=np.array([123.675, 116.28, 103.53]), std=np.array([58.395, 57.12, 57.375]), to_rgb=True)
|
||||
preprocessed_img = np.expand_dims(img.transpose(2, 0, 1), axis=0)
|
||||
return preprocessed_img, ori_shape
|
||||
@@ -130,12 +132,12 @@ def key_point_show(image_path, key_point_result=None):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
image = cv2.imread("./14162b58-f259-4833-98cb-89b9b496b251.jfif")
|
||||
image = cv2.imread("9070101c-e5be-49b5-9602-4113a968969b.png")
|
||||
a = get_keypoint_result(image, "up")
|
||||
new_list = []
|
||||
print(list)
|
||||
for i in a[0]:
|
||||
new_list.append((int(i[0]), int(i[1])))
|
||||
key_point_show("./14162b58-f259-4833-98cb-89b9b496b251.jfif", new_list)
|
||||
key_point_show("9070101c-e5be-49b5-9602-4113a968969b.png", new_list)
|
||||
# a = get_seg_result(1, image)
|
||||
print(a)
|
||||
|
||||
Reference in New Issue
Block a user