From 1effa5f3fea6b99561812b77e7ef39f0c7d4e280 Mon Sep 17 00:00:00 2001 From: tink2123 Date: Mon, 27 Sep 2021 15:21:27 +0800 Subject: [PATCH] rm anno --- ppocr/data/imaug/label_ops.py | 2 +- ppocr/modeling/backbones/rec_resnet_aster.py | 7 ------- ppocr/modeling/heads/rec_aster_head.py | 1 - ppocr/modeling/transforms/tps_spatial_transformer.py | 5 ----- 4 files changed, 1 insertion(+), 14 deletions(-) diff --git a/ppocr/data/imaug/label_ops.py b/ppocr/data/imaug/label_ops.py index 17fee02d..45bb2a1f 100644 --- a/ppocr/data/imaug/label_ops.py +++ b/ppocr/data/imaug/label_ops.py @@ -369,7 +369,7 @@ class SEEDLabelEncode(BaseRecLabelEncode): return None if len(text) >= self.max_text_len: return None - data['length'] = np.array(len(text)) + 1 # conclue eos + data['length'] = np.array(len(text)) + 1 # conclude eos text = text + [len(self.character) - 1] * (self.max_text_len - len(text) ) data['label'] = np.array(text) diff --git a/ppocr/modeling/backbones/rec_resnet_aster.py b/ppocr/modeling/backbones/rec_resnet_aster.py index 5bb58035..bdecaf46 100644 --- a/ppocr/modeling/backbones/rec_resnet_aster.py +++ b/ppocr/modeling/backbones/rec_resnet_aster.py @@ -138,10 +138,3 @@ class ResNet_ASTER(nn.Layer): return rnn_feat else: return cnn_feat - - -if __name__ == "__main__": - x = paddle.randn([3, 3, 32, 100]) - net = ResNet_ASTER() - encoder_feat = net(x) - print(encoder_feat.shape) diff --git a/ppocr/modeling/heads/rec_aster_head.py b/ppocr/modeling/heads/rec_aster_head.py index ed520669..4961897b 100644 --- a/ppocr/modeling/heads/rec_aster_head.py +++ b/ppocr/modeling/heads/rec_aster_head.py @@ -150,7 +150,6 @@ class AttentionRecognitionHead(nn.Layer): # https://github.com/IBM/pytorch-seq2seq/blob/fede87655ddce6c94b38886089e05321dc9802af/seq2seq/models/TopKDecoder.py batch_size, l, d = x.shape - # inflated_encoder_feats = _inflate(encoder_feats, beam_width, 0) # ABC --> AABBCC -/-> ABCABC x = paddle.tile( paddle.transpose( x.unsqueeze(1), perm=[1, 0, 2, 3]), [beam_width, 1, 1, 1]) diff --git a/ppocr/modeling/transforms/tps_spatial_transformer.py b/ppocr/modeling/transforms/tps_spatial_transformer.py index 731e3ee9..b510acb0 100644 --- a/ppocr/modeling/transforms/tps_spatial_transformer.py +++ b/ppocr/modeling/transforms/tps_spatial_transformer.py @@ -63,8 +63,6 @@ def build_output_control_points(num_control_points, margins): ctrl_pts_y_bottom = np.ones(num_ctrl_pts_per_side) * (1.0 - margin_y) ctrl_pts_top = np.stack([ctrl_pts_x, ctrl_pts_y_top], axis=1) ctrl_pts_bottom = np.stack([ctrl_pts_x, ctrl_pts_y_bottom], axis=1) - # ctrl_pts_top = ctrl_pts_top[1:-1,:] - # ctrl_pts_bottom = ctrl_pts_bottom[1:-1,:] output_ctrl_pts_arr = np.concatenate( [ctrl_pts_top, ctrl_pts_bottom], axis=0) output_ctrl_pts = paddle.to_tensor(output_ctrl_pts_arr) @@ -85,7 +83,6 @@ class TPSSpatialTransformer(nn.Layer): target_control_points = build_output_control_points(num_control_points, margins) N = num_control_points - # N = N - 4 # create padded kernel matrix forward_kernel = paddle.zeros(shape=[N + 3, N + 3]) @@ -112,7 +109,6 @@ class TPSSpatialTransformer(nn.Layer): target_coordinate = paddle.to_tensor(target_coordinate) # HW x 2 Y, X = paddle.split( target_coordinate, target_coordinate.shape[1], axis=1) - #Y, X = target_coordinate.split(1, dim = 1) Y = Y / (self.target_height - 1) X = X / (self.target_width - 1) target_coordinate = paddle.concat( @@ -136,7 +132,6 @@ class TPSSpatialTransformer(nn.Layer): assert source_control_points.ndimension() == 3 assert source_control_points.shape[1] == self.num_control_points assert source_control_points.shape[2] == 2 - #batch_size = source_control_points.shape[0] batch_size = paddle.shape(source_control_points)[0] self.padding_matrix = paddle.expand( -- GitLab