(self, data: dict)
return data
从scales中随机选择一个尺度，对图片和文本框进行缩放
        :param data: {'img':,'text_polys':,'texts':,'ignore_tags':}
        :return:
从scales中随机选择一个尺度，对图片和文本框进行缩放
        :param data: {'img':,'text_polys':,'texts':,'ignore_tags':}
        :return:
从scales中随机选择一个尺度，对图片和文本框进行缩放 : param data : { img : text_polys : texts : ignore_tags : } : return :
def __call__(self, data: dict) -> dict:
        """
        从scales中随机选择一个尺度，对图片和文本框进行缩放
        :param data: {'img':,'text_polys':,'texts':,'ignore_tags':}
        :return:
        """
        if random.random() > self.random_rate:
            return data
        im = data['img']
        text_polys = data['text_polys']

        if self.keep_ratio:
            # 将图片短边pad到和长边一样
            h, w, c = im.shape
            max_h = max(h, self.size[0])
            max_w = max(w, self.size[1])
            im_padded = np.zeros((max_h, max_w, c), dtype=np.uint8)
            im_padded[:h, :w] = im.copy()
            im = im_padded
        text_polys = text_polys.astype(np.float32)
        h, w, _ = im.shape
        im = cv2.resize(im, self.size)
        w_scale = self.size[0] / float(w)
        h_scale = self.size[1] / float(h)
        text_polys[:, :, 0] *= w_scale
        text_polys[:, :, 1] *= h_scale

        data['img'] = im
        data['text_polys'] = text_polys
        return data
def __call__ ( self , data : dict ) -> dict : if random . random ( ) > self . random_rate : return data im = data [ 'img' ] text_polys = data [ 'text_polys' ] if self . keep_ratio : # 将图片短边pad到和长边一样 h , w , c = im . shape max_h = max ( h , self . size [ 0 ] ) max_w = max ( w , self . size [ 1 ] ) im_padded = np . zeros ( ( max_h , max_w , c ) , dtype = np . uint8 ) im_padded [ : h , : w ] = im . copy ( ) im = im_padded text_polys = text_polys . astype ( np . float32 ) h , w , _ = im . shape im = cv2 . resize ( im , self . size ) w_scale = self . size [ 0 ] / float ( w ) h_scale = self . size [ 1 ] / float ( h ) text_polys [ : , : , 0 ] *= w_scale text_polys [ : , : , 1 ] *= h_scale data [ 'img' ] = im data [ 'text_polys' ] = text_polys return data