删除check_static函数
This commit is contained in:
parent
122c82e93f
commit
bbe375352e
|
@ -21,7 +21,6 @@ __dir__ = os.path.dirname(os.path.abspath(__file__))
|
||||||
sys.path.append(__dir__)
|
sys.path.append(__dir__)
|
||||||
sys.path.append('/home/zhoujun20/PaddleOCR')
|
sys.path.append('/home/zhoujun20/PaddleOCR')
|
||||||
|
|
||||||
import paddle
|
|
||||||
from paddle import nn
|
from paddle import nn
|
||||||
from ppocr.modeling.transform import build_transform
|
from ppocr.modeling.transform import build_transform
|
||||||
from ppocr.modeling.backbones import build_backbone
|
from ppocr.modeling.backbones import build_backbone
|
||||||
|
@ -84,39 +83,3 @@ class Model(nn.Layer):
|
||||||
x = self.neck(x)
|
x = self.neck(x)
|
||||||
x = self.head(x)
|
x = self.head(x)
|
||||||
return 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()
|
|
||||||
|
|
Loading…
Reference in New Issue