From f17b96b96ffaab1e32d5f0479263c4977c0df039 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Tue, 19 Jan 2021 17:42:28 +0800 Subject: [PATCH] Delete useless code --- ppocr/modeling/transforms/tps.py | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/ppocr/modeling/transforms/tps.py b/ppocr/modeling/transforms/tps.py index 340f6c44..3de25193 100644 --- a/ppocr/modeling/transforms/tps.py +++ b/ppocr/modeling/transforms/tps.py @@ -310,34 +310,3 @@ class TPS(nn.Layer): [-1, image.shape[2], image.shape[3], 2]) batch_I_r = F.grid_sample(x=image, grid=batch_P_prime) return batch_I_r - - -if __name__ == '__main__': - import paddle - from ppocr.utils.save_load import load_dygraph_pretrain - from ppocr.utils.logging import get_logger - - np.random.seed(0) - img = np.random.random((1, 3, 32, 100)).astype(np.float32) - x = paddle.to_tensor(img) - - batch_P_prime = np.load( - '/Users/zhoujun20/Desktop/code/static/PaddleOCR/output/tps1.npy') - batch_P_prime = paddle.to_tensor(batch_P_prime) - - model = TPS(in_channels=3, num_fiducial=20, loc_lr=0.1, model_name='small') - load_dygraph_pretrain( - model, - get_logger(), - '/Users/zhoujun20/Desktop/code/static/PaddleOCR/output/tps', - load_static_weights=True) - - model.eval() - y = model(x) - print(y.shape) - - static = np.load( - '/Users/zhoujun20/Desktop/code/static/PaddleOCR/output/tps.npy') - print(static.dtype, y.numpy().dtype, static.shape, y.numpy().shape) - diff = y.numpy() - static - print(diff.max()) -- GitLab