From bbe375352e6a6f9fb48d459a0497b5efddb184d9 Mon Sep 17 00:00:00 2001 From: WenmuZhou Date: Tue, 27 Oct 2020 11:23:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4check=5Fstatic=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ppocr/modeling/architectures/model.py | 39 +-------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/ppocr/modeling/architectures/model.py b/ppocr/modeling/architectures/model.py index 65769596..222b08d6 100644 --- a/ppocr/modeling/architectures/model.py +++ b/ppocr/modeling/architectures/model.py @@ -21,7 +21,6 @@ __dir__ = os.path.dirname(os.path.abspath(__file__)) sys.path.append(__dir__) sys.path.append('/home/zhoujun20/PaddleOCR') -import paddle from paddle import nn from ppocr.modeling.transform import build_transform from ppocr.modeling.backbones import build_backbone @@ -83,40 +82,4 @@ class Model(nn.Layer): if self.use_neck: x = self.neck(x) x = self.head(x) - return x - - -def check_static(): - import numpy as np - from ppocr.utils.save_load import load_dygraph_pretrain - from ppocr.utils.logging import get_logger - from tools import program - - config = program.load_config('configs/det/det_r50_vd_db.yml') - - logger = get_logger() - np.random.seed(0) - data = np.random.rand(1, 3, 640, 640).astype(np.float32) - - paddle.disable_static() - - x = paddle.to_tensor(data) - - config['Architecture']['in_channels'] = 3 - config['Architecture']["Head"]['out_channels'] = 37 - model = Model(config['Architecture']) - model.eval() - load_dygraph_pretrain( - model, logger, 'det_r50_vd_db/best_accuracy', load_static_weights=True) - - y = model(x) - for y1 in y: - print(y1.shape) - - static_out = np.load('static_out.npy') - diff = y.numpy() - static_out - print(y.shape, static_out.shape, diff.mean()) - - -if __name__ == '__main__': - check_static() + return x \ No newline at end of file -- GitLab