Skip to content

Commit

Permalink
[PaddleV3] 修复部分依赖 paddle.fluid 的 onnx 模型 part 1 (#1067)
Browse files Browse the repository at this point in the history
* [Fix] version check

* [Fix] onnx facenet

* [Fix] onnx gpen

* [Fix] onnx idg p1

* [Fix] onnx idg p2

* [Fix] onnx idg selection

* [Fix] onnx idg vis

* [Fix] onnx idg multi crop

* [Fix] onnx idg multi cnn

* [Fix] onnx idg multi seq

* [Fix] onnx idg test process

* [Fix] onnx idg test sim

* [Fix] onnx mlperf resnet50

* [Fix] onnx poselandmarks

* [Fix] onnx seg

* [Fix] onnx vit online

* [Fix] onnx alexnet

* [Fix] onnx basenet

* [Fix] onnx tools

* [Fix] tensorflow tools

* [Update] black.list
  • Loading branch information
megemini authored Oct 23, 2024
1 parent 4236c2a commit def20d7
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 131 deletions.
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

0 comments on commit def20d7

Please sign in to comment.