Skip to content

Commit

Permalink
Delete useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
WenmuZhou committed Jan 19, 2021
1 parent f2ebeae commit f17b96b
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions ppocr/modeling/transforms/tps.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,34 +310,3 @@ def forward(self, image):
[-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())

0 comments on commit f17b96b

Please sign in to comment.