Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PaddleV3] 修复部分依赖 paddle.fluid 的 onnx 模型 part 1 #1067

Merged
merged 22 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions test_benchmark/ONNX/FaceNet/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import paddle
import paddle.fluid as fluid

import numpy as np
import pickle
import sys
Expand All @@ -10,11 +10,8 @@
paddle.enable_static()
exe = paddle.static.Executor(paddle.CPUPlace())
# test Dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
data = np.load("../dataset/FaceNet/input.npy")
result = exe.run(prog, feed={inputs[0]: data}, fetch_list=outputs)

Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/GPEN/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import paddle.fluid as fluid
import paddle
import numpy as np
import sys
Expand All @@ -10,11 +9,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
data = np.load('../dataset/GPEN/input.npy')
result = exe.run(prog, feed={inputs[0]: data}, fetch_list=outputs)

Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/IDG_detection_registration_p1/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import paddle
import paddle.fluid as fluid
import numpy as np
import pickle
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="./pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
with open(
"../dataset/IDG_detection_registration_p1/detection_registration_p1_inputs.pkl",
"rb") as fr:
Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/IDG_detection_registration_p2/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import paddle
import paddle.fluid as fluid
import numpy as np
import pickle
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="./pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
with open(
"../dataset/IDG_detection_registration_p2/detection_registration_p2_inputs.pkl",
"rb") as fr:
Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/IDG_keypoint_selection/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import paddle
import paddle.fluid as fluid
import numpy as np
import pickle
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="./pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
with open("../dataset/IDG_keypoint_selection/keypoint_selection_inputs.pkl",
"rb") as fr:
inputs_list = pickle.load(fr)
Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/IDG_local_vis/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import paddle
import paddle.fluid as fluid
import numpy as np
import pickle
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="./pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
with open("../dataset/IDG_local_vis/local_vis_inputs.pkl", "rb") as fr:
inputs_list = pickle.load(fr)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import paddle
import paddle.fluid as fluid
import numpy as np
import pickle
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="./pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
with open(
"../dataset/IDG_multi_modal_crop_cnn_model/multi_modal_crop_cnn_model_inputs_1221.pkl",
"rb") as fr:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import paddle
import paddle.fluid as fluid
import numpy as np
import pickle
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="./pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
with open(
"../dataset/IDG_multi_modal_fully_cnn_model/multi_modal_fully_cnn_model_inputs_1222.pkl",
"rb") as fr:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import paddle
import paddle.fluid as fluid
import numpy as np
import pickle
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="./pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
with open(
"../dataset/IDG_multi_modal_sequential_model/multi_modal_sequential_model_inputs_1222.pkl",
"rb") as fr:
Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/IDG_test_process/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import paddle
import paddle.fluid as fluid
import numpy as np
import pickle
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CUDAPlace(0))

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="./pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
with open("../dataset/IDG_test_process/test_process_inputs.pkl",
"rb") as fr:
inputs_list = pickle.load(fr)
Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/IDG_test_sim_feat_new/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import paddle
import paddle.fluid as fluid
import numpy as np
import pickle
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="./pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
with open("../dataset/IDG_test_sim_feat_new/test_sim_feat_new_inputs.pkl",
"rb") as fr:
inputs_list = pickle.load(fr)
Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/MLPerf_ResNet50/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import paddle
import paddle.fluid as fluid
import numpy as np
import pickle
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
data = np.load('../dataset/MLPerf_ResNet50/input_0.npy')
result = exe.run(prog, feed={inputs[0]: data}, fetch_list=outputs)

Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/Poselandmarks/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import paddle.fluid as fluid
import paddle
import numpy as np
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
data = np.load('../dataset/Poselandmarks/input.npy')
result = exe.run(prog, feed={inputs[0]: data}, fetch_list=outputs)

Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/Seg/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import paddle.fluid as fluid
import paddle
import numpy as np
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
data = np.load('../dataset/Seg/input.npy')
result = exe.run(prog, feed={inputs[0]: data}, fetch_list=outputs)

Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/VIT_online/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import paddle.fluid as fluid
import paddle
import numpy as np
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CUDAPlace(0))

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
LN_nums = 0
for i, op in enumerate(prog.block(0).ops):
if op.type in ['feed', 'fetch']:
Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/alexnet/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import paddle
import paddle.fluid as fluid
import numpy as np
import sys

Expand All @@ -10,11 +9,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
data = np.load('../dataset/alexnet/input_0.npy')
result = exe.run(prog, feed={inputs[0]: data}, fetch_list=outputs)
paddle.disable_static()
Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/basnet/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import paddle
import paddle.fluid as fluid
import numpy as np
import pickle
import sys
Expand All @@ -11,11 +10,8 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test Dygraph
[prog, inputs, outputs] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
data = np.load("../dataset/basnet/input_0.npy")
result = exe.run(prog, feed={inputs[0]: data}, fetch_list=outputs)

Expand Down
17 changes: 0 additions & 17 deletions test_benchmark/ONNX/black.list
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
FaceNet
GPEN
IDG_detection_registration_p1
IDG_detection_registration_p2
IDG_keypoint_selection
IDG_local_vis
IDG_multi_modal_crop_cnn_model
IDG_multi_modal_fully_cnn_model
IDG_multi_modal_sequential_model
IDG_test_process
IDG_test_sim_feat_new
MLPerf_ResNet50
Poselandmarks
Seg
SwinTransformer
VIT_online
alexnet
basnet
bert6
best_float32
cifarnet
Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/ONNX/tools/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import yaml
import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import create_predictor, PrecisionType
from paddle.inference import Config
from benchmark_utils import PaddleInferBenchmark
Expand Down Expand Up @@ -201,11 +200,8 @@ def analysis_operators(self, model_dir):
paddle.enable_static()
exe = paddle.static.Executor(paddle.CPUPlace())
# test Dygraph
[prog, inputs, outputs
] = fluid.io.load_inference_model(dirname=model_dir,
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, inputs, outputs] = paddle.static.load_inference_model(
path_prefix=model_dir + "/model", executor=exe)
#test op nums
op_dict = dict()
op_nums = 0
Expand Down
Loading