删除check_static函数

This commit is contained in:
WenmuZhou 2020-10-27 11:23:26 +08:00
parent 122c82e93f
commit bbe375352e
1 changed files with 1 additions and 38 deletions

View File

@ -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