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 的 caffe 模型 #1071

Merged
merged 25 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
1 change: 0 additions & 1 deletion test_benchmark/Caffe/3class/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/Caffe/3class/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
import paddle
import paddle.fluid as fluid
import sys
import os
import numpy as np
Expand All @@ -16,11 +15,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)
# test dygraph
paddle.disable_static()
from pd_model_dygraph.x2paddle_code import main
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/Caffe/AlexNet/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/Caffe/AlexNet/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
import paddle
import paddle.fluid as fluid
import sys
import os
import numpy as np
Expand All @@ -18,11 +17,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)
# test dygraph
paddle.disable_static()
from pd_model_dygraph.x2paddle_code import main
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/Caffe/FaceDetction/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
9 changes: 3 additions & 6 deletions test_benchmark/Caffe/FaceDetction/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
import paddle
import paddle.fluid as fluid
import sys
import os
import numpy as np
Expand All @@ -16,11 +15,9 @@

# test dygraph
paddle.enable_static()
[prog, feed_target_names, fetch_targets] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, feed_target_names,
fetch_targets] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)

result = exe.run(prog,
feed={feed_target_names[0]: input_data},
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/Caffe/MNasNet/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
9 changes: 3 additions & 6 deletions test_benchmark/Caffe/MNasNet/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
import paddle
import paddle.fluid as fluid
import sys
import os
import numpy as np
Expand All @@ -19,11 +18,9 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, feed_target_names, fetch_targets] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, feed_target_names,
fetch_targets] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
result = exe.run(prog,
feed={feed_target_names[0]: input_data},
fetch_list=fetch_targets)
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/Caffe/MTCNN1/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
9 changes: 3 additions & 6 deletions test_benchmark/Caffe/MTCNN1/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
import paddle
import paddle.fluid as fluid
import sys
import os
import numpy as np
Expand All @@ -19,11 +18,9 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, feed_target_names, fetch_targets] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, feed_target_names,
fetch_targets] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
result = exe.run(prog,
feed={feed_target_names[0]: input_data},
fetch_list=fetch_targets)
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/Caffe/MTCNN2/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
9 changes: 3 additions & 6 deletions test_benchmark/Caffe/MTCNN2/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
import paddle
import paddle.fluid as fluid
import sys
import os
import numpy as np
Expand All @@ -19,11 +18,9 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, feed_target_names, fetch_targets] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, feed_target_names,
fetch_targets] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
result = exe.run(prog,
feed={feed_target_names[0]: input_data},
fetch_list=fetch_targets)
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/Caffe/MTCNN3/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
9 changes: 3 additions & 6 deletions test_benchmark/Caffe/MTCNN3/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
import paddle
import paddle.fluid as fluid
import sys
import os
import numpy as np
Expand All @@ -19,11 +18,9 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, feed_target_names, fetch_targets] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, feed_target_names,
fetch_targets] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
result = exe.run(prog,
feed={feed_target_names[0]: input_data},
fetch_list=fetch_targets)
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/Caffe/MobileNetV1/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
9 changes: 3 additions & 6 deletions test_benchmark/Caffe/MobileNetV1/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
import paddle
import paddle.fluid as fluid
import sys
import os
import numpy as np
Expand All @@ -19,11 +18,9 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, feed_target_names, fetch_targets] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, feed_target_names,
fetch_targets] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
result = exe.run(prog,
feed={feed_target_names[0]: input_data},
fetch_list=fetch_targets)
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/Caffe/MobileNetV2/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
9 changes: 3 additions & 6 deletions test_benchmark/Caffe/MobileNetV2/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
import paddle
import paddle.fluid as fluid
import sys
import os
import numpy as np
Expand All @@ -19,11 +18,9 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, feed_target_names, fetch_targets] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, feed_target_names,
fetch_targets] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
result = exe.run(prog,
feed={feed_target_names[0]: input_data},
fetch_list=fetch_targets)
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/Caffe/ResNet18/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
9 changes: 3 additions & 6 deletions test_benchmark/Caffe/ResNet18/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
import paddle
import paddle.fluid as fluid
import sys
import os
import numpy as np
Expand All @@ -19,11 +18,9 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, feed_target_names, fetch_targets] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, feed_target_names,
fetch_targets] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
result = exe.run(prog,
feed={feed_target_names[0]: input_data},
fetch_list=fetch_targets)
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/Caffe/ResNet50/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
9 changes: 3 additions & 6 deletions test_benchmark/Caffe/ResNet50/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
import paddle
import paddle.fluid as fluid
import sys
import os
import numpy as np
Expand All @@ -19,11 +18,9 @@
exe = paddle.static.Executor(paddle.CPUPlace())

# test dygraph
[prog, feed_target_names, fetch_targets] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, feed_target_names,
fetch_targets] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
result = exe.run(prog,
feed={feed_target_names[0]: input_data},
fetch_list=fetch_targets)
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/Caffe/SSD/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
11 changes: 4 additions & 7 deletions test_benchmark/Caffe/SSD/pd_infer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
import paddle
import paddle.fluid as fluid
import sys
import os
import numpy as np
Expand All @@ -18,16 +17,14 @@
paddle.enable_static()
exe = paddle.static.Executor(paddle.CPUPlace())
# test dygraph
[prog, feed_target_names, fetch_targets] = fluid.io.load_inference_model(
dirname="pd_model_dygraph/inference_model/",
executor=exe,
model_filename="model.pdmodel",
params_filename="model.pdiparams")
[prog, feed_target_names,
fetch_targets] = paddle.static.load_inference_model(
path_prefix="pd_model_dygraph/inference_model/model", executor=exe)
result = exe.run(prog,
feed={feed_target_names[0]: input_data},
fetch_list=fetch_targets,
return_numpy=False)
lod = result[0].lod()[0]
lod = result[0].lod()
res_pd = np.asarray(result[0])
res_cf = caffe_output['detection_out'][0]
diffTest = True
Expand Down
8 changes: 2 additions & 6 deletions test_benchmark/Caffe/SegFlow/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)
with open("../dataset/SegFlow/inputs_segflow_0314.pkl", "rb") as fr:
input_list = pickle.load(fr)
result = exe.run(prog,
Expand Down
1 change: 0 additions & 1 deletion test_benchmark/Caffe/ShuffleNet/deploy_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.inference import Config
from paddle.inference import create_predictor

Expand Down
Loading