(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:
        """
        image = data['img']
        text_polys = data['text_polys']
        ignore_tags = data['ignore_tags']

        h, w = image.shape[:2]
        text_polys, ignore_tags = self.validate_polygons(text_polys, ignore_tags, h, w)
        gt = np.zeros((h, w), dtype=np.float32)
        mask = np.ones((h, w), dtype=np.float32)
        for i in range(len(text_polys)):
            polygon = text_polys[i]
            height = max(polygon[:, 1]) - min(polygon[:, 1])
            width = max(polygon[:, 0]) - min(polygon[:, 0])
            if ignore_tags[i] or min(height, width) < self.min_text_size:
                cv2.fillPoly(mask, polygon.astype(np.int32)[np.newaxis, :, :], 0)
                ignore_tags[i] = True
            else:
                shrinked = self.shrink_func(polygon, self.shrink_ratio)
                if shrinked.size == 0:
                    cv2.fillPoly(mask, polygon.astype(np.int32)[np.newaxis, :, :], 0)
                    ignore_tags[i] = True
                    continue
                cv2.fillPoly(gt, [shrinked.astype(np.int32)], 1)

        data['shrink_map'] = gt
        data['shrink_mask'] = mask
        return data
def __call__ ( self , data : dict ) -> dict : image = data [ 'img' ] text_polys = data [ 'text_polys' ] ignore_tags = data [ 'ignore_tags' ] h , w = image . shape [ : 2 ] text_polys , ignore_tags = self . validate_polygons ( text_polys , ignore_tags , h , w ) gt = np . zeros ( ( h , w ) , dtype = np . float32 ) mask = np . ones ( ( h , w ) , dtype = np . float32 ) for i in range ( len ( text_polys ) ) : polygon = text_polys [ i ] height = max ( polygon [ : , 1 ] ) - min ( polygon [ : , 1 ] ) width = max ( polygon [ : , 0 ] ) - min ( polygon [ : , 0 ] ) if ignore_tags [ i ] or min ( height , width ) < self . min_text_size : cv2 . fillPoly ( mask , polygon . astype ( np . int32 ) [ np . newaxis , : , : ] , 0 ) ignore_tags [ i ] = True else : shrinked = self . shrink_func ( polygon , self . shrink_ratio ) if shrinked . size == 0 : cv2 . fillPoly ( mask , polygon . astype ( np . int32 ) [ np . newaxis , : , : ] , 0 ) ignore_tags [ i ] = True continue cv2 . fillPoly ( gt , [ shrinked . astype ( np . int32 ) ] , 1 ) data [ 'shrink_map' ] = gt data [ 'shrink_mask' ] = mask return data