Skip to content

Commit 88882e4

Browse files
committed
add onnx model and test data
1 parent 87f2521 commit 88882e4

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed
224 Bytes
Binary file not shown.
512 Bytes
Binary file not shown.

testdata/dnn/onnx/generate_onnx_models.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import torch.nn.init as init
55
import torch.nn as nn
66
import torch.nn.functional as F
7+
import paddle # version 2.1.1
78
import numpy as np
89
import os.path
910
import onnx
@@ -1356,3 +1357,26 @@ def forward(self, x):
13561357
x = Variable(torch.randn([2, 3]))
13571358
model = NormalizeFusion()
13581359
save_data_and_model("normalize_fusion", x, model)
1360+
1361+
#paddle2onnx model
1362+
class Resize_HumanSeg(paddle.nn.Layer):
1363+
def __init__(self, ):
1364+
super(Resize_HumanSeg, self).__init__()
1365+
1366+
def forward(self, x0):
1367+
x1 = paddle.nn.functional.interpolate(x0,size=[6,8],mode='bilinear',align_corners=False)
1368+
return x1
1369+
1370+
def save_data_and_paddle_model(model, name, input_data):
1371+
model.eval()
1372+
np.save(os.path.join("data", "input_" + name + ".npy"), input_data.numpy())
1373+
output = model(input_data)
1374+
np.save(os.path.join("data", "output_" + name + ".npy"), output.numpy())
1375+
inputs = [paddle.static.InputSpec(shape=input_data.shape, dtype="float32")]
1376+
paddle.onnx.export(model, "models/" + name,
1377+
input_spec=inputs,
1378+
opset_version=11)
1379+
1380+
input_shape = [1, 2, 3, 4]
1381+
x = paddle.rand(input_shape, dtype="float32")
1382+
save_data_and_paddle_model(Resize_HumanSeg(), "resize_humanseg", x)
834 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)