目录
PSE代码分析,实现模型性能优化;
1.数据增强
对文本样本数据进行数据增强:
def augmentation(im: np.ndarray, text_polys: np.ndarray, scales: np.ndarray, degrees: int, input_size: int) -> tuple:
# the images are rescaled with ratio {0.5, 1.0, 2.0, 3.0} randomly
im, text_polys = data_aug.random_scale(im, text_polys, scales) #从scales中随机选择一个尺度,对图片和文本框进行缩放
# the images are horizontally fliped and rotated in range [−10◦, 10◦] randomly
if random.random() < 0.5:
im, text_polys = data_aug.horizontal_flip(im, text_polys)#对图片和文本框进行水平翻转
if random.random() < 0.5:
im, text_polys = data_aug.random_rotate_img_bbox(im, text_polys, degrees)#从给定的角度中选择一个角度,对图片和文本框进行旋转
if random.random() < 0.2:
im = data_aug.to_grayImg(im) #彩色图片转灰度图片
# 640 × 640 random samples are cropped from the transformed images
# im, text_polys &