Rename fastdeploy_runtime.h to runtime.h and Frontend to ModelFormat (#263)

rename frontend to model_format
This commit is contained in:
Jason
2022-09-22 13:24:05 +08:00
committed by GitHub
parent 9bebdaa915
commit e227c5625e
126 changed files with 400 additions and 380 deletions

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include "fastdeploy/fastdeploy_runtime.h"
#include "fastdeploy/runtime.h"
namespace fastdeploy {

View File

@@ -118,10 +118,10 @@ void BindRuntime(pybind11::module& m) {
.value("TRT", Backend::TRT)
.value("PDINFER", Backend::PDINFER)
.value("LITE", Backend::LITE);
pybind11::enum_<Frontend>(m, "Frontend", pybind11::arithmetic(),
"Frontend for inference.")
.value("PADDLE", Frontend::PADDLE)
.value("ONNX", Frontend::ONNX);
pybind11::enum_<ModelFormat>(m, "ModelFormat", pybind11::arithmetic(),
"ModelFormat for inference.")
.value("PADDLE", ModelFormat::PADDLE)
.value("ONNX", ModelFormat::ONNX);
pybind11::enum_<Device>(m, "Device", pybind11::arithmetic(),
"Device for inference.")
.value("CPU", Device::CPU)

View File

@@ -20,7 +20,7 @@
#include <type_traits>
#include "fastdeploy/fastdeploy_runtime.h"
#include "fastdeploy/runtime.h"
#ifdef ENABLE_VISION
#include "fastdeploy/vision.h"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "fastdeploy/fastdeploy_runtime.h"
#include "fastdeploy/runtime.h"
#include "fastdeploy/utils/unique_ptr.h"
#include "fastdeploy/utils/utils.h"
@@ -84,57 +84,57 @@ std::string Str(const Backend& b) {
return "UNKNOWN-Backend";
}
std::string Str(const Frontend& f) {
if (f == Frontend::PADDLE) {
return "Frontend::PADDLE";
} else if (f == Frontend::ONNX) {
return "Frontend::ONNX";
std::string Str(const ModelFormat& f) {
if (f == ModelFormat::PADDLE) {
return "ModelFormat::PADDLE";
} else if (f == ModelFormat::ONNX) {
return "ModelFormat::ONNX";
}
return "UNKNOWN-Frontend";
return "UNKNOWN-ModelFormat";
}
bool CheckModelFormat(const std::string& model_file,
const Frontend& model_format) {
if (model_format == Frontend::PADDLE) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::PADDLE) {
if (model_file.size() < 8 ||
model_file.substr(model_file.size() - 8, 8) != ".pdmodel") {
FDERROR << "With model format of Frontend::PADDLE, the model file "
FDERROR << "With model format of ModelFormat::PADDLE, the model file "
"should ends with `.pdmodel`, but now it's "
<< model_file << std::endl;
return false;
}
} else if (model_format == Frontend::ONNX) {
} else if (model_format == ModelFormat::ONNX) {
if (model_file.size() < 5 ||
model_file.substr(model_file.size() - 5, 5) != ".onnx") {
FDERROR << "With model format of Frontend::ONNX, the model file "
FDERROR << "With model format of ModelFormat::ONNX, the model file "
"should ends with `.onnx`, but now it's "
<< model_file << std::endl;
return false;
}
} else {
FDERROR << "Only support model format with frontend Frontend::PADDLE / "
"Frontend::ONNX."
FDERROR << "Only support model format with frontend ModelFormat::PADDLE / "
"ModelFormat::ONNX."
<< std::endl;
return false;
}
return true;
}
Frontend GuessModelFormat(const std::string& model_file) {
ModelFormat GuessModelFormat(const std::string& model_file) {
if (model_file.size() > 8 &&
model_file.substr(model_file.size() - 8, 8) == ".pdmodel") {
FDINFO << "Model Format: PaddlePaddle." << std::endl;
return Frontend::PADDLE;
return ModelFormat::PADDLE;
} else if (model_file.size() > 5 &&
model_file.substr(model_file.size() - 5, 5) == ".onnx") {
FDINFO << "Model Format: ONNX." << std::endl;
return Frontend::ONNX;
return ModelFormat::ONNX;
}
FDERROR << "Cannot guess which model format you are using, please set "
"RuntimeOption::model_format manually."
<< std::endl;
return Frontend::PADDLE;
return ModelFormat::PADDLE;
}
void RuntimeOption::SetModelPath(const std::string& model_path,
@@ -143,10 +143,10 @@ void RuntimeOption::SetModelPath(const std::string& model_path,
if (_model_format == "paddle") {
model_file = model_path;
params_file = params_path;
model_format = Frontend::PADDLE;
model_format = ModelFormat::PADDLE;
} else if (_model_format == "onnx") {
model_file = model_path;
model_format = Frontend::ONNX;
model_format = ModelFormat::ONNX;
} else {
FDASSERT(false, "The model format only can be 'paddle' or 'onnx'.");
}
@@ -258,7 +258,7 @@ void RuntimeOption::SetTrtCacheFile(const std::string& cache_file_path) {
bool Runtime::Init(const RuntimeOption& _option) {
option = _option;
if (option.model_format == Frontend::AUTOREC) {
if (option.model_format == ModelFormat::AUTOREC) {
option.model_format = GuessModelFormat(_option.model_file);
}
if (option.backend == Backend::UNKNOWN) {
@@ -280,29 +280,35 @@ bool Runtime::Init(const RuntimeOption& _option) {
FDASSERT(option.device == Device::CPU || option.device == Device::GPU,
"Backend::ORT only supports Device::CPU/Device::GPU.");
CreateOrtBackend();
FDINFO << "Runtime initialized with Backend::ORT in " << Str(option.device) << "." << std::endl;
FDINFO << "Runtime initialized with Backend::ORT in " << Str(option.device)
<< "." << std::endl;
} else if (option.backend == Backend::TRT) {
FDASSERT(option.device == Device::GPU,
"Backend::TRT only supports Device::GPU.");
CreateTrtBackend();
FDINFO << "Runtime initialized with Backend::TRT in " << Str(option.device) << "." << std::endl;
FDINFO << "Runtime initialized with Backend::TRT in " << Str(option.device)
<< "." << std::endl;
} else if (option.backend == Backend::PDINFER) {
FDASSERT(option.device == Device::CPU || option.device == Device::GPU,
"Backend::TRT only supports Device::CPU/Device::GPU.");
FDASSERT(
option.model_format == Frontend::PADDLE,
"Backend::PDINFER only supports model format of Frontend::PADDLE.");
option.model_format == ModelFormat::PADDLE,
"Backend::PDINFER only supports model format of ModelFormat::PADDLE.");
CreatePaddleBackend();
FDINFO << "Runtime initialized with Backend::PDINFER in " << Str(option.device) << "." << std::endl;
FDINFO << "Runtime initialized with Backend::PDINFER in "
<< Str(option.device) << "." << std::endl;
} else if (option.backend == Backend::OPENVINO) {
FDASSERT(option.device == Device::CPU,
"Backend::OPENVINO only supports Device::CPU");
CreateOpenVINOBackend();
FDINFO << "Runtime initialized with Backend::OPENVINO in " << Str(option.device) << "." << std::endl;
FDINFO << "Runtime initialized with Backend::OPENVINO in "
<< Str(option.device) << "." << std::endl;
} else if (option.backend == Backend::LITE) {
FDASSERT(option.device == Device::CPU, "Backend::LITE only supports Device::CPU");
FDASSERT(option.device == Device::CPU,
"Backend::LITE only supports Device::CPU");
CreateLiteBackend();
FDINFO << "Runtime initialized with Backend::LITE in " << Str(option.device) << "." << std::endl;
FDINFO << "Runtime initialized with Backend::LITE in " << Str(option.device)
<< "." << std::endl;
} else {
FDERROR << "Runtime only support "
"Backend::ORT/Backend::TRT/Backend::PDINFER as backend now."
@@ -343,8 +349,8 @@ void Runtime::CreatePaddleBackend() {
pd_option.gpu_id = option.device_id;
pd_option.delete_pass_names = option.pd_delete_pass_names;
pd_option.cpu_thread_num = option.cpu_thread_num;
FDASSERT(option.model_format == Frontend::PADDLE,
"PaddleBackend only support model format of Frontend::PADDLE.");
FDASSERT(option.model_format == ModelFormat::PADDLE,
"PaddleBackend only support model format of ModelFormat::PADDLE.");
backend_ = utils::make_unique<PaddleBackend>();
auto casted_backend = dynamic_cast<PaddleBackend*>(backend_.get());
FDASSERT(casted_backend->InitFromPaddle(option.model_file, option.params_file,
@@ -361,14 +367,14 @@ void Runtime::CreateOpenVINOBackend() {
#ifdef ENABLE_OPENVINO_BACKEND
auto ov_option = OpenVINOBackendOption();
ov_option.cpu_thread_num = option.cpu_thread_num;
FDASSERT(option.model_format == Frontend::PADDLE ||
option.model_format == Frontend::ONNX,
"OpenVINOBackend only support model format of Frontend::PADDLE / "
"Frontend::ONNX.");
FDASSERT(option.model_format == ModelFormat::PADDLE ||
option.model_format == ModelFormat::ONNX,
"OpenVINOBackend only support model format of ModelFormat::PADDLE / "
"ModelFormat::ONNX.");
backend_ = utils::make_unique<OpenVINOBackend>();
auto casted_backend = dynamic_cast<OpenVINOBackend*>(backend_.get());
if (option.model_format == Frontend::ONNX) {
if (option.model_format == ModelFormat::ONNX) {
FDASSERT(casted_backend->InitFromOnnx(option.model_file, ov_option),
"Load model from ONNX failed while initliazing OrtBackend.");
} else {
@@ -397,13 +403,13 @@ void Runtime::CreateOrtBackend() {
ort_option.remove_multiclass_nms_ = option.remove_multiclass_nms_;
ort_option.custom_op_info_ = option.custom_op_info_;
FDASSERT(option.model_format == Frontend::PADDLE ||
option.model_format == Frontend::ONNX,
"OrtBackend only support model format of Frontend::PADDLE / "
"Frontend::ONNX.");
FDASSERT(option.model_format == ModelFormat::PADDLE ||
option.model_format == ModelFormat::ONNX,
"OrtBackend only support model format of ModelFormat::PADDLE / "
"ModelFormat::ONNX.");
backend_ = utils::make_unique<OrtBackend>();
auto casted_backend = dynamic_cast<OrtBackend*>(backend_.get());
if (option.model_format == Frontend::ONNX) {
if (option.model_format == ModelFormat::ONNX) {
FDASSERT(casted_backend->InitFromOnnx(option.model_file, ort_option),
"Load model from ONNX failed while initliazing OrtBackend.");
} else {
@@ -435,13 +441,13 @@ void Runtime::CreateTrtBackend() {
trt_option.remove_multiclass_nms_ = option.remove_multiclass_nms_;
trt_option.custom_op_info_ = option.custom_op_info_;
FDASSERT(option.model_format == Frontend::PADDLE ||
option.model_format == Frontend::ONNX,
"TrtBackend only support model format of Frontend::PADDLE / "
"Frontend::ONNX.");
FDASSERT(option.model_format == ModelFormat::PADDLE ||
option.model_format == ModelFormat::ONNX,
"TrtBackend only support model format of ModelFormat::PADDLE / "
"ModelFormat::ONNX.");
backend_ = utils::make_unique<TrtBackend>();
auto casted_backend = dynamic_cast<TrtBackend*>(backend_.get());
if (option.model_format == Frontend::ONNX) {
if (option.model_format == ModelFormat::ONNX) {
FDASSERT(casted_backend->InitFromOnnx(option.model_file, trt_option),
"Load model from ONNX failed while initliazing TrtBackend.");
} else {
@@ -459,11 +465,12 @@ void Runtime::CreateTrtBackend() {
void Runtime::CreateLiteBackend() {
#ifdef ENABLE_LITE_BACKEND
auto lite_option = LiteBackendOption();
FDASSERT(option.model_format == Frontend::PADDLE,
"LiteBackend only support model format of Frontend::PADDLE");
FDASSERT(option.model_format == ModelFormat::PADDLE,
"LiteBackend only support model format of ModelFormat::PADDLE");
backend_ = utils::make_unique<LiteBackend>();
auto casted_backend = dynamic_cast<LiteBackend*>(backend_.get());
FDASSERT(casted_backend->InitFromPaddle(option.model_file, option.params_file, lite_option),
FDASSERT(casted_backend->InitFromPaddle(option.model_file, option.params_file,
lite_option),
"Load model from nb file failed while initializing LiteBackend.");
#else
FDASSERT(false,

View File

@@ -23,18 +23,18 @@ namespace fastdeploy {
enum FASTDEPLOY_DECL Backend { UNKNOWN, ORT, TRT, PDINFER, OPENVINO, LITE };
// AUTOREC will according to the name of model file
// to decide which Frontend is
enum FASTDEPLOY_DECL Frontend { AUTOREC, PADDLE, ONNX };
// to decide which ModelFormat is
enum FASTDEPLOY_DECL ModelFormat { AUTOREC, PADDLE, ONNX };
FASTDEPLOY_DECL std::string Str(const Backend& b);
FASTDEPLOY_DECL std::string Str(const Frontend& f);
FASTDEPLOY_DECL std::string Str(const ModelFormat& f);
FASTDEPLOY_DECL std::vector<Backend> GetAvailableBackends();
FASTDEPLOY_DECL bool IsBackendAvailable(const Backend& backend);
bool CheckModelFormat(const std::string& model_file,
const Frontend& model_format);
Frontend GuessModelFormat(const std::string& model_file);
const ModelFormat& model_format);
ModelFormat GuessModelFormat(const std::string& model_file);
struct FASTDEPLOY_DECL RuntimeOption {
// set path of model file and params file
@@ -138,7 +138,7 @@ struct FASTDEPLOY_DECL RuntimeOption {
std::string model_file = ""; // Path of model file
std::string params_file = ""; // Path of parameters file, can be empty
Frontend model_format = Frontend::AUTOREC; // format of input model
ModelFormat model_format = ModelFormat::AUTOREC; // format of input model
// inside parameters, only for inside usage
// remove multiclass_nms in Paddle2ONNX

View File

@@ -165,7 +165,7 @@ UIEModel::UIEModel(const std::string& model_file,
const std::string& vocab_file, float position_prob,
size_t max_length, const std::vector<std::string>& schema,
const fastdeploy::RuntimeOption& custom_option,
const fastdeploy::Frontend& model_format)
const fastdeploy::ModelFormat& model_format)
: max_length_(max_length),
position_prob_(position_prob),
tokenizer_(vocab_file) {
@@ -184,7 +184,7 @@ UIEModel::UIEModel(const std::string& model_file,
const std::string& vocab_file, float position_prob,
size_t max_length, const std::vector<SchemaNode>& schema,
const fastdeploy::RuntimeOption& custom_option,
const fastdeploy::Frontend& model_format)
const fastdeploy::ModelFormat& model_format)
: max_length_(max_length),
position_prob_(position_prob),
tokenizer_(vocab_file) {
@@ -203,7 +203,7 @@ UIEModel::UIEModel(const std::string& model_file,
const std::string& vocab_file, float position_prob,
size_t max_length, const SchemaNode& schema,
const fastdeploy::RuntimeOption& custom_option,
const fastdeploy::Frontend& model_format)
const fastdeploy::ModelFormat& model_format)
: max_length_(max_length),
position_prob_(position_prob),
tokenizer_(vocab_file) {

View File

@@ -91,26 +91,27 @@ struct Schema {
struct FASTDEPLOY_DECL UIEModel {
public:
UIEModel(
const std::string& model_file, const std::string& params_file,
const std::string& vocab_file, float position_prob, size_t max_length,
const std::vector<std::string>& schema,
UIEModel(const std::string& model_file, const std::string& params_file,
const std::string& vocab_file, float position_prob,
size_t max_length, const std::vector<std::string>& schema,
const fastdeploy::RuntimeOption& custom_option =
fastdeploy::RuntimeOption(),
const fastdeploy::Frontend& model_format = fastdeploy::Frontend::PADDLE);
UIEModel(
const std::string& model_file, const std::string& params_file,
const std::string& vocab_file, float position_prob, size_t max_length,
const SchemaNode& schema, const fastdeploy::RuntimeOption& custom_option =
fastdeploy::RuntimeOption(),
const fastdeploy::Frontend& model_format = fastdeploy::Frontend::PADDLE);
UIEModel(
const std::string& model_file, const std::string& params_file,
const std::string& vocab_file, float position_prob, size_t max_length,
const std::vector<SchemaNode>& schema,
const fastdeploy::ModelFormat& model_format =
fastdeploy::ModelFormat::PADDLE);
UIEModel(const std::string& model_file, const std::string& params_file,
const std::string& vocab_file, float position_prob,
size_t max_length, const SchemaNode& schema,
const fastdeploy::RuntimeOption& custom_option =
fastdeploy::RuntimeOption(),
const fastdeploy::Frontend& model_format = fastdeploy::Frontend::PADDLE);
const fastdeploy::ModelFormat& model_format =
fastdeploy::ModelFormat::PADDLE);
UIEModel(const std::string& model_file, const std::string& params_file,
const std::string& vocab_file, float position_prob,
size_t max_length, const std::vector<SchemaNode>& schema,
const fastdeploy::RuntimeOption& custom_option =
fastdeploy::RuntimeOption(),
const fastdeploy::ModelFormat& model_format =
fastdeploy::ModelFormat::PADDLE);
void SetSchema(const std::vector<std::string>& schema);
void SetSchema(const std::vector<SchemaNode>& schema);
void SetSchema(const SchemaNode& schema);

View File

@@ -30,23 +30,24 @@ void BindUIE(pybind11::module& m) {
py::class_<text::UIEModel>(m, "UIEModel")
.def(py::init<std::string, std::string, std::string, float, size_t,
std::vector<std::string>, RuntimeOption, Frontend>(),
std::vector<std::string>, RuntimeOption, ModelFormat>(),
py::arg("model_file"), py::arg("params_file"), py::arg("vocab_file"),
py::arg("position_prob"), py::arg("max_length"), py::arg("schema"),
py::arg("custom_option") = fastdeploy::RuntimeOption(),
py::arg("model_format") = fastdeploy::Frontend::PADDLE)
py::arg("model_format") = fastdeploy::ModelFormat::PADDLE)
.def(
py::init<std::string, std::string, std::string, float, size_t,
std::vector<text::SchemaNode>, RuntimeOption, ModelFormat>(),
py::arg("model_file"), py::arg("params_file"), py::arg("vocab_file"),
py::arg("position_prob"), py::arg("max_length"), py::arg("schema"),
py::arg("custom_option") = fastdeploy::RuntimeOption(),
py::arg("model_format") = fastdeploy::ModelFormat::PADDLE)
.def(py::init<std::string, std::string, std::string, float, size_t,
std::vector<text::SchemaNode>, RuntimeOption, Frontend>(),
text::SchemaNode, RuntimeOption, ModelFormat>(),
py::arg("model_file"), py::arg("params_file"), py::arg("vocab_file"),
py::arg("position_prob"), py::arg("max_length"), py::arg("schema"),
py::arg("custom_option") = fastdeploy::RuntimeOption(),
py::arg("model_format") = fastdeploy::Frontend::PADDLE)
.def(py::init<std::string, std::string, std::string, float, size_t,
text::SchemaNode, RuntimeOption, Frontend>(),
py::arg("model_file"), py::arg("params_file"), py::arg("vocab_file"),
py::arg("position_prob"), py::arg("max_length"), py::arg("schema"),
py::arg("custom_option") = fastdeploy::RuntimeOption(),
py::arg("model_format") = fastdeploy::Frontend::PADDLE)
py::arg("model_format") = fastdeploy::ModelFormat::PADDLE)
.def("set_schema",
static_cast<void (text::UIEModel::*)(
const std::vector<std::string>&)>(&text::UIEModel::SetSchema),

View File

@@ -24,9 +24,10 @@ PaddleClasModel::PaddleClasModel(const std::string& model_file,
const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
const ModelFormat& model_format) {
config_file_ = config_file;
valid_cpu_backends = {Backend::ORT, Backend::OPENVINO, Backend::PDINFER, Backend::LITE};
valid_cpu_backends = {Backend::ORT, Backend::OPENVINO, Backend::PDINFER,
Backend::LITE};
valid_gpu_backends = {Backend::ORT, Backend::PDINFER, Backend::TRT};
runtime_option = custom_option;
runtime_option.model_format = model_format;

View File

@@ -26,7 +26,7 @@ class FASTDEPLOY_DECL PaddleClasModel : public FastDeployModel {
PaddleClasModel(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
virtual std::string ModelName() const { return "PaddleClas/Model"; }

View File

@@ -18,7 +18,7 @@ void BindPaddleClas(pybind11::module& m) {
pybind11::class_<vision::classification::PaddleClasModel, FastDeployModel>(
m, "PaddleClasModel")
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
Frontend>())
ModelFormat>())
.def("predict", [](vision::classification::PaddleClasModel& self,
pybind11::array& data, int topk = 1) {
auto mat = PyArrayToCvMat(data);

View File

@@ -115,8 +115,8 @@ void GFLRegression(const float* logits, size_t reg_num, float* offset) {
NanoDetPlus::NanoDetPlus(const std::string& model_file,
const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {

View File

@@ -31,7 +31,7 @@ class FASTDEPLOY_DECL NanoDetPlus : public FastDeployModel {
NanoDetPlus(const std::string& model_file,
const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
std::string ModelName() const { return "nanodet"; }

View File

@@ -18,7 +18,8 @@ namespace fastdeploy {
void BindNanoDetPlus(pybind11::module& m) {
pybind11::class_<vision::detection::NanoDetPlus, FastDeployModel>(
m, "NanoDetPlus")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::detection::NanoDetPlus& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {

View File

@@ -60,8 +60,8 @@ void ScaledYOLOv4::LetterBox(Mat* mat, const std::vector<int>& size,
ScaledYOLOv4::ScaledYOLOv4(const std::string& model_file,
const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {

View File

@@ -28,7 +28,7 @@ class FASTDEPLOY_DECL ScaledYOLOv4 : public FastDeployModel {
ScaledYOLOv4(const std::string& model_file,
const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
virtual std::string ModelName() const { return "ScaledYOLOv4"; }

View File

@@ -18,7 +18,8 @@ namespace fastdeploy {
void BindScaledYOLOv4(pybind11::module& m) {
pybind11::class_<vision::detection::ScaledYOLOv4, FastDeployModel>(
m, "ScaledYOLOv4")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::detection::ScaledYOLOv4& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {

View File

@@ -58,8 +58,9 @@ void YOLOR::LetterBox(Mat* mat, const std::vector<int>& size,
}
YOLOR::YOLOR(const std::string& model_file, const std::string& params_file,
const RuntimeOption& custom_option, const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const RuntimeOption& custom_option,
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {

View File

@@ -27,7 +27,7 @@ class FASTDEPLOY_DECL YOLOR : public FastDeployModel {
// 当model_format为Paddle时则需同时指定model_file & params_file
YOLOR(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
virtual std::string ModelName() const { return "YOLOR"; }

View File

@@ -17,7 +17,8 @@
namespace fastdeploy {
void BindYOLOR(pybind11::module& m) {
pybind11::class_<vision::detection::YOLOR, FastDeployModel>(m, "YOLOR")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::detection::YOLOR& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {

View File

@@ -58,8 +58,8 @@ void YOLOv5::LetterBox(Mat* mat, std::vector<int> size,
YOLOv5::YOLOv5(const std::string& model_file, const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::OPENVINO, Backend::ORT};
valid_gpu_backends = {Backend::ORT, Backend::TRT};
} else {

View File

@@ -27,7 +27,7 @@ class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel {
// 当model_format为Paddle时则需同时指定model_file & params_file
YOLOv5(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
std::string ModelName() const { return "yolov5"; }

View File

@@ -17,7 +17,8 @@
namespace fastdeploy {
void BindYOLOv5(pybind11::module& m) {
pybind11::class_<vision::detection::YOLOv5, FastDeployModel>(m, "YOLOv5")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::detection::YOLOv5& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {

View File

@@ -84,8 +84,8 @@ void YOLOv5Lite::GenerateAnchors(const std::vector<int>& size,
YOLOv5Lite::YOLOv5Lite(const std::string& model_file,
const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {

View File

@@ -27,7 +27,7 @@ class FASTDEPLOY_DECL YOLOv5Lite : public FastDeployModel {
// 当model_format为Paddle时则需同时指定model_file & params_file
YOLOv5Lite(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
virtual std::string ModelName() const { return "YOLOv5-Lite"; }

View File

@@ -18,7 +18,8 @@ namespace fastdeploy {
void BindYOLOv5Lite(pybind11::module& m) {
pybind11::class_<vision::detection::YOLOv5Lite, FastDeployModel>(m,
"YOLOv5Lite")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::detection::YOLOv5Lite& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {

View File

@@ -61,8 +61,8 @@ void YOLOv6::LetterBox(Mat* mat, std::vector<int> size,
YOLOv6::YOLOv6(const std::string& model_file, const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::OPENVINO, Backend::ORT};
valid_gpu_backends = {Backend::ORT, Backend::TRT};
} else {

View File

@@ -30,7 +30,7 @@ class FASTDEPLOY_DECL YOLOv6 : public FastDeployModel {
// 当model_format为Paddle时则需同时指定model_file & params_file
YOLOv6(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
std::string ModelName() const { return "YOLOv6"; }

View File

@@ -17,7 +17,8 @@
namespace fastdeploy {
void BindYOLOv6(pybind11::module& m) {
pybind11::class_<vision::detection::YOLOv6, FastDeployModel>(m, "YOLOv6")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::detection::YOLOv6& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {

View File

@@ -59,8 +59,8 @@ void YOLOv7::LetterBox(Mat* mat, const std::vector<int>& size,
YOLOv7::YOLOv7(const std::string& model_file, const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::OPENVINO, Backend::ORT};
valid_gpu_backends = {Backend::ORT, Backend::TRT};
} else {

View File

@@ -25,7 +25,7 @@ class FASTDEPLOY_DECL YOLOv7 : public FastDeployModel {
public:
YOLOv7(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
virtual std::string ModelName() const { return "yolov7"; }

View File

@@ -17,7 +17,8 @@
namespace fastdeploy {
void BindYOLOv7(pybind11::module& m) {
pybind11::class_<vision::detection::YOLOv7, FastDeployModel>(m, "YOLOv7")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::detection::YOLOv7& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {

View File

@@ -60,8 +60,8 @@ void YOLOv7End2EndORT::LetterBox(Mat* mat, const std::vector<int>& size,
YOLOv7End2EndORT::YOLOv7End2EndORT(const std::string& model_file,
const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT};
valid_gpu_backends = {Backend::ORT}; // NO TRT
} else {

View File

@@ -26,7 +26,7 @@ class FASTDEPLOY_DECL YOLOv7End2EndORT : public FastDeployModel {
YOLOv7End2EndORT(const std::string& model_file,
const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
virtual std::string ModelName() const { return "yolov7end2end_ort"; }

View File

@@ -18,7 +18,8 @@ namespace fastdeploy {
void BindYOLOv7End2EndORT(pybind11::module& m) {
pybind11::class_<vision::detection::YOLOv7End2EndORT, FastDeployModel>(
m, "YOLOv7End2EndORT")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::detection::YOLOv7End2EndORT& self, pybind11::array& data,
float conf_threshold) {

View File

@@ -60,8 +60,8 @@ void YOLOv7End2EndTRT::LetterBox(Mat* mat, const std::vector<int>& size,
YOLOv7End2EndTRT::YOLOv7End2EndTRT(const std::string& model_file,
const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {}; // NO CPU
valid_gpu_backends = {Backend::TRT}; // NO ORT
} else {

View File

@@ -26,7 +26,7 @@ class FASTDEPLOY_DECL YOLOv7End2EndTRT : public FastDeployModel {
YOLOv7End2EndTRT(const std::string& model_file,
const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
virtual std::string ModelName() const { return "yolov7end2end_trt"; }

View File

@@ -18,7 +18,8 @@ namespace fastdeploy {
void BindYOLOv7End2EndTRT(pybind11::module& m) {
pybind11::class_<vision::detection::YOLOv7End2EndTRT, FastDeployModel>(
m, "YOLOv7End2EndTRT")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::detection::YOLOv7End2EndTRT& self, pybind11::array& data,
float conf_threshold) {

View File

@@ -73,8 +73,9 @@ void LetterBoxWithRightBottomPad(Mat* mat, std::vector<int> size,
}
YOLOX::YOLOX(const std::string& model_file, const std::string& params_file,
const RuntimeOption& custom_option, const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const RuntimeOption& custom_option,
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::OPENVINO, Backend::ORT};
valid_gpu_backends = {Backend::ORT, Backend::TRT};
} else {

View File

@@ -30,7 +30,7 @@ class FASTDEPLOY_DECL YOLOX : public FastDeployModel {
// 当model_format为Paddle时则需同时指定model_file & params_file
YOLOX(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
std::string ModelName() const { return "YOLOX"; }

View File

@@ -17,7 +17,8 @@
namespace fastdeploy {
void BindYOLOX(pybind11::module& m) {
pybind11::class_<vision::detection::YOLOX, FastDeployModel>(m, "YOLOX")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::detection::YOLOX& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {

View File

@@ -22,7 +22,7 @@ MaskRCNN::MaskRCNN(const std::string& model_file,
const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
const ModelFormat& model_format) {
config_file_ = config_file;
valid_cpu_backends = {Backend::PDINFER};
valid_gpu_backends = {Backend::PDINFER};

View File

@@ -24,7 +24,7 @@ class FASTDEPLOY_DECL MaskRCNN : public FasterRCNN {
MaskRCNN(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
virtual std::string ModelName() const { return "PaddleDetection/MaskRCNN"; }

View File

@@ -22,7 +22,7 @@ namespace detection {
PicoDet::PicoDet(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
const ModelFormat& model_format) {
config_file_ = config_file;
valid_cpu_backends = {Backend::PDINFER, Backend::ORT, Backend::LITE};
valid_gpu_backends = {Backend::ORT, Backend::PDINFER, Backend::TRT};

View File

@@ -24,7 +24,7 @@ class FASTDEPLOY_DECL PicoDet : public PPYOLOE {
PicoDet(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
// Only support picodet contains decode and nms
bool CheckIfContainDecodeAndNMS();

View File

@@ -17,7 +17,7 @@ namespace fastdeploy {
void BindPPDet(pybind11::module& m) {
pybind11::class_<vision::detection::PPYOLOE, FastDeployModel>(m, "PPYOLOE")
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
Frontend>())
ModelFormat>())
.def("predict",
[](vision::detection::PPYOLOE& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);
@@ -28,7 +28,7 @@ void BindPPDet(pybind11::module& m) {
pybind11::class_<vision::detection::PPYOLO, FastDeployModel>(m, "PPYOLO")
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
Frontend>())
ModelFormat>())
.def("predict",
[](vision::detection::PPYOLO& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);
@@ -39,7 +39,7 @@ void BindPPDet(pybind11::module& m) {
pybind11::class_<vision::detection::PPYOLOv2, FastDeployModel>(m, "PPYOLOv2")
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
Frontend>())
ModelFormat>())
.def("predict",
[](vision::detection::PPYOLOv2& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);
@@ -50,7 +50,7 @@ void BindPPDet(pybind11::module& m) {
pybind11::class_<vision::detection::PicoDet, FastDeployModel>(m, "PicoDet")
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
Frontend>())
ModelFormat>())
.def("predict",
[](vision::detection::PicoDet& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);
@@ -62,7 +62,7 @@ void BindPPDet(pybind11::module& m) {
pybind11::class_<vision::detection::PaddleYOLOX, FastDeployModel>(
m, "PaddleYOLOX")
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
Frontend>())
ModelFormat>())
.def("predict",
[](vision::detection::PaddleYOLOX& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);
@@ -74,7 +74,7 @@ void BindPPDet(pybind11::module& m) {
pybind11::class_<vision::detection::FasterRCNN, FastDeployModel>(m,
"FasterRCNN")
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
Frontend>())
ModelFormat>())
.def("predict",
[](vision::detection::FasterRCNN& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);
@@ -85,7 +85,7 @@ void BindPPDet(pybind11::module& m) {
pybind11::class_<vision::detection::YOLOv3, FastDeployModel>(m, "YOLOv3")
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
Frontend>())
ModelFormat>())
.def("predict",
[](vision::detection::YOLOv3& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);
@@ -96,7 +96,7 @@ void BindPPDet(pybind11::module& m) {
pybind11::class_<vision::detection::MaskRCNN, FastDeployModel>(m, "MaskRCNN")
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
Frontend>())
ModelFormat>())
.def("predict",
[](vision::detection::MaskRCNN& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);

View File

@@ -21,7 +21,7 @@ namespace detection {
PPYOLO::PPYOLO(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
const ModelFormat& model_format) {
config_file_ = config_file;
valid_cpu_backends = {Backend::OPENVINO, Backend::PDINFER};
valid_gpu_backends = {Backend::PDINFER};

View File

@@ -24,7 +24,7 @@ class FASTDEPLOY_DECL PPYOLO : public PPYOLOE {
PPYOLO(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
virtual std::string ModelName() const { return "PaddleDetection/PPYOLO"; }
@@ -40,8 +40,9 @@ class FASTDEPLOY_DECL PPYOLOv2 : public PPYOLO {
PPYOLOv2(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE) : PPYOLO(model_file, params_file, config_file, custom_option, model_format) {
}
const ModelFormat& model_format = ModelFormat::PADDLE)
: PPYOLO(model_file, params_file, config_file, custom_option,
model_format) {}
virtual std::string ModelName() const { return "PaddleDetection/PPYOLOv2"; }
};

View File

@@ -12,7 +12,7 @@ namespace detection {
PPYOLOE::PPYOLOE(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
const ModelFormat& model_format) {
config_file_ = config_file;
valid_cpu_backends = {Backend::OPENVINO, Backend::ORT, Backend::PDINFER};
valid_gpu_backends = {Backend::ORT, Backend::PDINFER, Backend::TRT};
@@ -25,7 +25,7 @@ PPYOLOE::PPYOLOE(const std::string& model_file, const std::string& params_file,
void PPYOLOE::GetNmsInfo() {
#ifdef ENABLE_PADDLE_FRONTEND
if (runtime_option.model_format == Frontend::PADDLE) {
if (runtime_option.model_format == ModelFormat::PADDLE) {
std::string contents;
if (!ReadBinaryFromFile(runtime_option.model_file, &contents)) {
return;

View File

@@ -28,7 +28,7 @@ class FASTDEPLOY_DECL PPYOLOE : public FastDeployModel {
PPYOLOE(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
virtual std::string ModelName() const { return "PaddleDetection/PPYOLOE"; }

View File

@@ -22,7 +22,7 @@ FasterRCNN::FasterRCNN(const std::string& model_file,
const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
const ModelFormat& model_format) {
config_file_ = config_file;
valid_cpu_backends = {Backend::PDINFER};
valid_gpu_backends = {Backend::PDINFER};

View File

@@ -24,7 +24,7 @@ class FASTDEPLOY_DECL FasterRCNN : public PPYOLOE {
FasterRCNN(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
virtual std::string ModelName() const { return "PaddleDetection/FasterRCNN"; }

View File

@@ -21,7 +21,7 @@ namespace detection {
YOLOv3::YOLOv3(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
const ModelFormat& model_format) {
config_file_ = config_file;
valid_cpu_backends = {Backend::OPENVINO, Backend::ORT, Backend::PDINFER};
valid_gpu_backends = {Backend::ORT, Backend::PDINFER, Backend::TRT};

View File

@@ -24,7 +24,7 @@ class FASTDEPLOY_DECL YOLOv3 : public PPYOLOE {
YOLOv3(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
virtual std::string ModelName() const { return "PaddleDetection/YOLOv3"; }

View File

@@ -22,7 +22,7 @@ PaddleYOLOX::PaddleYOLOX(const std::string& model_file,
const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
const ModelFormat& model_format) {
config_file_ = config_file;
valid_cpu_backends = {Backend::ORT, Backend::PDINFER};
valid_gpu_backends = {Backend::ORT, Backend::PDINFER, Backend::TRT};

View File

@@ -24,7 +24,7 @@ class FASTDEPLOY_DECL PaddleYOLOX : public PPYOLOE {
PaddleYOLOX(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
virtual bool Preprocess(Mat* mat, std::vector<FDTensor>* outputs);

View File

@@ -79,8 +79,8 @@ void GenerateRetinaAnchors(const std::vector<int>& size,
RetinaFace::RetinaFace(const std::string& model_file,
const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {

View File

@@ -29,7 +29,7 @@ class FASTDEPLOY_DECL RetinaFace : public FastDeployModel {
// 当model_format为Paddle时则需同时指定model_file & params_file
RetinaFace(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
std::string ModelName() const { return "Pytorch_Retinaface"; }

View File

@@ -18,7 +18,8 @@ namespace fastdeploy {
void BindRetinaFace(pybind11::module& m) {
pybind11::class_<vision::facedet::RetinaFace, FastDeployModel>(m,
"RetinaFace")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::facedet::RetinaFace& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {

View File

@@ -60,8 +60,9 @@ void SCRFD::LetterBox(Mat* mat, const std::vector<int>& size,
}
SCRFD::SCRFD(const std::string& model_file, const std::string& params_file,
const RuntimeOption& custom_option, const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const RuntimeOption& custom_option,
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {

View File

@@ -30,7 +30,7 @@ class FASTDEPLOY_DECL SCRFD : public FastDeployModel {
// 当model_format为Paddle时则需同时指定model_file & params_file
SCRFD(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
std::string ModelName() const { return "scrfd"; }

View File

@@ -18,7 +18,8 @@ namespace fastdeploy {
void BindSCRFD(pybind11::module& m) {
// Bind SCRFD
pybind11::class_<vision::facedet::SCRFD, FastDeployModel>(m, "SCRFD")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::facedet::SCRFD& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {

View File

@@ -25,8 +25,8 @@ namespace facedet {
UltraFace::UltraFace(const std::string& model_file,
const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {

View File

@@ -29,7 +29,7 @@ class FASTDEPLOY_DECL UltraFace : public FastDeployModel {
// 当model_format为Paddle时则需同时指定model_file & params_file
UltraFace(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
std::string ModelName() const {

View File

@@ -17,7 +17,8 @@
namespace fastdeploy {
void BindUltraFace(pybind11::module& m) {
pybind11::class_<vision::facedet::UltraFace, FastDeployModel>(m, "UltraFace")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::facedet::UltraFace& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {

View File

@@ -62,8 +62,8 @@ void LetterBox(Mat* mat, std::vector<int> size, std::vector<float> color,
YOLOv5Face::YOLOv5Face(const std::string& model_file,
const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {

View File

@@ -29,7 +29,7 @@ class FASTDEPLOY_DECL YOLOv5Face : public FastDeployModel {
// 当model_format为Paddle时则需同时指定model_file & params_file
YOLOv5Face(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
std::string ModelName() const { return "yolov5-face"; }

View File

@@ -18,7 +18,8 @@ namespace fastdeploy {
void BindYOLOv5Face(pybind11::module& m) {
pybind11::class_<vision::facedet::YOLOv5Face, FastDeployModel>(m,
"YOLOv5Face")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::facedet::YOLOv5Face& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {

View File

@@ -24,7 +24,7 @@ namespace faceid {
ArcFace::ArcFace(const std::string& model_file, const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format)
const ModelFormat& model_format)
: InsightFaceRecognitionModel(model_file, params_file, custom_option,
model_format) {
initialized = Initialize();

View File

@@ -31,7 +31,7 @@ class FASTDEPLOY_DECL ArcFace : public InsightFaceRecognitionModel {
// ArcFace支持IResNet, IResNet2060, VIT, MobileFaceNet骨干
ArcFace(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
std::string ModelName() const override {

View File

@@ -19,7 +19,8 @@ void BindArcFace(pybind11::module& m) {
// Bind ArcFace
pybind11::class_<vision::faceid::ArcFace,
vision::faceid::InsightFaceRecognitionModel>(m, "ArcFace")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::faceid::ArcFace& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);

View File

@@ -24,7 +24,7 @@ namespace faceid {
CosFace::CosFace(const std::string& model_file, const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format)
const ModelFormat& model_format)
: InsightFaceRecognitionModel(model_file, params_file, custom_option,
model_format) {
initialized = Initialize();

View File

@@ -31,7 +31,7 @@ class FASTDEPLOY_DECL CosFace : public InsightFaceRecognitionModel {
// ArcFace支持IResNet, IResNet2060, VIT, MobileFaceNet骨干
CosFace(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
// insightface/arcface提供的模型文件包含了cosface

View File

@@ -19,7 +19,8 @@ void BindCosFace(pybind11::module& m) {
// Bind CosFace
pybind11::class_<vision::faceid::CosFace,
vision::faceid::InsightFaceRecognitionModel>(m, "CosFace")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::faceid::CosFace& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);

View File

@@ -24,8 +24,8 @@ namespace faceid {
InsightFaceRecognitionModel::InsightFaceRecognitionModel(
const std::string& model_file, const std::string& params_file,
const RuntimeOption& custom_option, const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const RuntimeOption& custom_option, const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {

View File

@@ -31,7 +31,7 @@ class FASTDEPLOY_DECL InsightFaceRecognitionModel : public FastDeployModel {
InsightFaceRecognitionModel(
const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
virtual std::string ModelName() const { return "deepinsight/insightface"; }

View File

@@ -19,7 +19,8 @@ void BindInsightFaceRecognitionModel(pybind11::module& m) {
// Bind InsightFaceRecognitionModel
pybind11::class_<vision::faceid::InsightFaceRecognitionModel,
FastDeployModel>(m, "InsightFaceRecognitionModel")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::faceid::InsightFaceRecognitionModel& self,
pybind11::array& data) {

View File

@@ -25,7 +25,7 @@ namespace faceid {
PartialFC::PartialFC(const std::string& model_file,
const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format)
const ModelFormat& model_format)
: InsightFaceRecognitionModel(model_file, params_file, custom_option,
model_format) {
initialized = Initialize();

View File

@@ -30,7 +30,7 @@ class FASTDEPLOY_DECL PartialFC : public InsightFaceRecognitionModel {
// 当model_format为Paddle时则需同时指定model_file & params_file
PartialFC(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
std::string ModelName() const override {

View File

@@ -19,7 +19,8 @@ void BindPartialFC(pybind11::module& m) {
// Bind Partial FC
pybind11::class_<vision::faceid::PartialFC,
vision::faceid::InsightFaceRecognitionModel>(m, "PartialFC")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::faceid::PartialFC& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);

View File

@@ -23,7 +23,7 @@ namespace vision {
namespace faceid {
VPL::VPL(const std::string& model_file, const std::string& params_file,
const RuntimeOption& custom_option, const Frontend& model_format)
const RuntimeOption& custom_option, const ModelFormat& model_format)
: InsightFaceRecognitionModel(model_file, params_file, custom_option,
model_format) {
initialized = Initialize();

View File

@@ -31,7 +31,7 @@ class FASTDEPLOY_DECL VPL : public InsightFaceRecognitionModel {
// VPL支持IResNet, IResNet1024骨干
VPL(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
std::string ModelName() const override {

View File

@@ -19,7 +19,8 @@ void BindVPL(pybind11::module& m) {
// Bind VPL
pybind11::class_<vision::faceid::VPL,
vision::faceid::InsightFaceRecognitionModel>(m, "VPL")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::faceid::VPL& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);

View File

@@ -24,8 +24,8 @@ namespace matting {
MODNet::MODNet(const std::string& model_file, const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {

View File

@@ -29,7 +29,7 @@ class FASTDEPLOY_DECL MODNet : public FastDeployModel {
// 当model_format为Paddle时则需同时指定model_file & params_file
MODNet(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::ONNX);
const ModelFormat& model_format = ModelFormat::ONNX);
// 定义模型的名称
std::string ModelName() const { return "matting/MODNet"; }

View File

@@ -18,7 +18,8 @@ namespace fastdeploy {
void BindMODNet(pybind11::module& m) {
// Bind MODNet
pybind11::class_<vision::matting::MODNet, FastDeployModel>(m, "MODNet")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def("predict",
[](vision::matting::MODNet& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);

View File

@@ -24,7 +24,7 @@ PPMatting::PPMatting(const std::string& model_file,
const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
const ModelFormat& model_format) {
config_file_ = config_file;
valid_cpu_backends = {Backend::ORT, Backend::PDINFER};
valid_gpu_backends = {Backend::PDINFER, Backend::TRT};

View File

@@ -25,7 +25,7 @@ class FASTDEPLOY_DECL PPMatting : public FastDeployModel {
PPMatting(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
std::string ModelName() const { return "PaddleMatting"; }

View File

@@ -17,7 +17,7 @@ namespace fastdeploy {
void BindPPMatting(pybind11::module& m) {
pybind11::class_<vision::matting::PPMatting, FastDeployModel>(m, "PPMatting")
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
Frontend>())
ModelFormat>())
.def("predict",
[](vision::matting::PPMatting& self, pybind11::array& data) {
auto mat = PyArrayToCvMat(data);

View File

@@ -24,9 +24,10 @@ Classifier::Classifier() {}
Classifier::Classifier(const std::string& model_file,
const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
valid_cpu_backends = {Backend::ORT, Backend::OPENVINO}; // 指定可用的CPU后端
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT,
Backend::OPENVINO}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {
valid_cpu_backends = {Backend::PDINFER, Backend::ORT, Backend::OPENVINO};

View File

@@ -29,7 +29,7 @@ class FASTDEPLOY_DECL Classifier : public FastDeployModel {
// 当model_format为Paddle时则需同时指定model_file & params_file
Classifier(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
// 定义模型的名称
std::string ModelName() const { return "ppocr/ocr_cls"; }

View File

@@ -24,9 +24,10 @@ DBDetector::DBDetector() {}
DBDetector::DBDetector(const std::string& model_file,
const std::string& params_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
valid_cpu_backends = {Backend::ORT, Backend::OPENVINO}; // 指定可用的CPU后端
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT,
Backend::OPENVINO}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {
valid_cpu_backends = {Backend::PDINFER, Backend::ORT, Backend::OPENVINO};

View File

@@ -28,7 +28,7 @@ class FASTDEPLOY_DECL DBDetector : public FastDeployModel {
DBDetector(const std::string& model_file, const std::string& params_file = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
// 定义模型的名称
std::string ModelName() const { return "ppocr/ocr_det"; }

View File

@@ -18,7 +18,8 @@ namespace fastdeploy {
void BindPPOCRModel(pybind11::module& m) {
// DBDetector
pybind11::class_<vision::ocr::DBDetector, FastDeployModel>(m, "DBDetector")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def(pybind11::init<>())
.def_readwrite("max_side_len", &vision::ocr::DBDetector::max_side_len)
@@ -36,7 +37,8 @@ void BindPPOCRModel(pybind11::module& m) {
// Classifier
pybind11::class_<vision::ocr::Classifier, FastDeployModel>(m, "Classifier")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def(pybind11::init<std::string, std::string, RuntimeOption,
ModelFormat>())
.def(pybind11::init<>())
.def_readwrite("cls_thresh", &vision::ocr::Classifier::cls_thresh)
@@ -48,7 +50,7 @@ void BindPPOCRModel(pybind11::module& m) {
pybind11::class_<vision::ocr::Recognizer, FastDeployModel>(m, "Recognizer")
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
Frontend>())
ModelFormat>())
.def(pybind11::init<>())
.def_readwrite("rec_img_h", &vision::ocr::Recognizer::rec_img_h)

View File

@@ -42,9 +42,10 @@ Recognizer::Recognizer(const std::string& model_file,
const std::string& params_file,
const std::string& label_path,
const RuntimeOption& custom_option,
const Frontend& model_format) {
if (model_format == Frontend::ONNX) {
valid_cpu_backends = {Backend::ORT, Backend::OPENVINO}; // 指定可用的CPU后端
const ModelFormat& model_format) {
if (model_format == ModelFormat::ONNX) {
valid_cpu_backends = {Backend::ORT,
Backend::OPENVINO}; // 指定可用的CPU后端
valid_gpu_backends = {Backend::ORT, Backend::TRT}; // 指定可用的GPU后端
} else {
// NOTE:此模型暂不支持paddle-inference-Gpu推理

View File

@@ -30,7 +30,7 @@ class FASTDEPLOY_DECL Recognizer : public FastDeployModel {
Recognizer(const std::string& model_file, const std::string& params_file = "",
const std::string& label_path = "",
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
// 定义模型的名称
std::string ModelName() const { return "ppocr/ocr_rec"; }

View File

@@ -11,7 +11,7 @@ PaddleSegModel::PaddleSegModel(const std::string& model_file,
const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option,
const Frontend& model_format) {
const ModelFormat& model_format) {
config_file_ = config_file;
valid_cpu_backends = {Backend::OPENVINO, Backend::PDINFER};
valid_gpu_backends = {Backend::PDINFER, Backend::TRT};

View File

@@ -12,7 +12,7 @@ class FASTDEPLOY_DECL PaddleSegModel : public FastDeployModel {
PaddleSegModel(const std::string& model_file, const std::string& params_file,
const std::string& config_file,
const RuntimeOption& custom_option = RuntimeOption(),
const Frontend& model_format = Frontend::PADDLE);
const ModelFormat& model_format = ModelFormat::PADDLE);
std::string ModelName() const { return "PaddleSeg"; }

View File

@@ -18,7 +18,7 @@ void BindPPSeg(pybind11::module& m) {
pybind11::class_<vision::segmentation::PaddleSegModel, FastDeployModel>(
m, "PaddleSegModel")
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
Frontend>())
ModelFormat>())
.def("predict",
[](vision::segmentation::PaddleSegModel& self,
pybind11::array& data) {

View File

@@ -16,7 +16,7 @@ import logging
import os
import sys
from .c_lib_wrap import (Frontend, Backend, FDDataType, TensorInfo, Device,
from .c_lib_wrap import (ModelFormat, Backend, FDDataType, TensorInfo, Device,
FDTensor, is_built_with_gpu, is_built_with_ort,
is_built_with_paddle, is_built_with_trt,
get_default_cuda_directory)

Some files were not shown because too many files have changed in this diff Show More