(self, batch, output, box_thresh=0.6)
return results
batch: (image, polygons, ignore_tags
        batch: a dict produced by dataloaders.
            image: tensor of shape (N, C, H, W).
            polygons: tensor of shape (N, K, 4, 2), the polygons of objective regions.
            ignore_tags: tensor of shape (N, K), indicates whether a region is ignorable or not.
            shape: the original shape of images.
            filename: the original filenames of images.
        output: (polygons, ...)
batch: (image, polygons, ignore_tags
        batch: a dict produced by dataloaders.
            image: tensor of shape (N, C, H, W).
            polygons: tensor of shape (N, K, 4, 2), the polygons of objective regions.
            ignore_tags: tensor of shape (N, K), indicates whether a region is ignorable or not.
            shape: the original shape of images.
            filename: the original filenames of images.
        output: (polygons, ...)
batch : ( image polygons ignore_tags batch : a dict produced by dataloaders . image : tensor of shape ( N C H W ) . polygons : tensor of shape ( N K 4 2 ) the polygons of objective regions . ignore_tags : tensor of shape ( N K ) indicates whether a region is ignorable or not . shape : the original shape of images . filename : the original filenames of images . output : ( polygons ... )
def measure(self, batch, output, box_thresh=0.6):
        '''
        batch: (image, polygons, ignore_tags
        batch: a dict produced by dataloaders.
            image: tensor of shape (N, C, H, W).
            polygons: tensor of shape (N, K, 4, 2), the polygons of objective regions.
            ignore_tags: tensor of shape (N, K), indicates whether a region is ignorable or not.
            shape: the original shape of images.
            filename: the original filenames of images.
        output: (polygons, ...)
        '''
        results = []
        gt_polyons_batch = batch['text_polys']
        ignore_tags_batch = batch['ignore_tags']
        pred_polygons_batch = np.array(output[0])
        pred_scores_batch = np.array(output[1])
        for polygons, pred_polygons, pred_scores, ignore_tags in zip(gt_polyons_batch, pred_polygons_batch, pred_scores_batch, ignore_tags_batch):
            gt = [dict(points=np.int64(polygons[i]), ignore=ignore_tags[i]) for i in range(len(polygons))]
            if self.is_output_polygon:
                pred = [dict(points=pred_polygons[i]) for i in range(len(pred_polygons))]
            else:
                pred = []
                # print(pred_polygons.shape)
                for i in range(pred_polygons.shape[0]):
                    if pred_scores[i] >= box_thresh:
                        # print(pred_polygons[i,:,:].tolist())
                        pred.append(dict(points=pred_polygons[i, :, :].astype(np.int)))
                # pred = [dict(points=pred_polygons[i,:,:].tolist()) if pred_scores[i] >= box_thresh for i in range(pred_polygons.shape[0])]
            results.append(self.evaluator.evaluate_image(gt, pred))
        return results
def measure ( self , batch , output , box_thresh = 0.6 ) : results = [ ] gt_polyons_batch = batch [ 'text_polys' ] ignore_tags_batch = batch [ 'ignore_tags' ] pred_polygons_batch = np . array ( output [ 0 ] ) pred_scores_batch = np . array ( output [ 1 ] ) for polygons , pred_polygons , pred_scores , ignore_tags in zip ( gt_polyons_batch , pred_polygons_batch , pred_scores_batch , ignore_tags_batch ) : gt = [ dict ( points = np . int64 ( polygons [ i ] ) , ignore = ignore_tags [ i ] ) for i in range ( len ( polygons ) ) ] if self . is_output_polygon : pred = [ dict ( points = pred_polygons [ i ] ) for i in range ( len ( pred_polygons ) ) ] else : pred = [ ] # print(pred_polygons.shape) for i in range ( pred_polygons . shape [ 0 ] ) : if pred_scores [ i ] >= box_thresh : # print(pred_polygons[i,:,:].tolist()) pred . append ( dict ( points = pred_polygons [ i , : , : ] . astype ( np . int ) ) ) # pred = [dict(points=pred_polygons[i,:,:].tolist()) if pred_scores[i] >= box_thresh for i in range(pred_polygons.shape[0])] results . append ( self . evaluator . evaluate_image ( gt , pred ) ) return results