diff --git a/fastdeploy/fastdeploy_model.h b/fastdeploy/fastdeploy_model.h index 57d3a754e..cf452aaac 100644 --- a/fastdeploy/fastdeploy_model.h +++ b/fastdeploy/fastdeploy_model.h @@ -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 { diff --git a/fastdeploy/pybind/fastdeploy_runtime.cc b/fastdeploy/pybind/fastdeploy_runtime.cc index cf1d0f029..f5cbdce6c 100644 --- a/fastdeploy/pybind/fastdeploy_runtime.cc +++ b/fastdeploy/pybind/fastdeploy_runtime.cc @@ -118,10 +118,10 @@ void BindRuntime(pybind11::module& m) { .value("TRT", Backend::TRT) .value("PDINFER", Backend::PDINFER) .value("LITE", Backend::LITE); - pybind11::enum_(m, "Frontend", pybind11::arithmetic(), - "Frontend for inference.") - .value("PADDLE", Frontend::PADDLE) - .value("ONNX", Frontend::ONNX); + pybind11::enum_(m, "ModelFormat", pybind11::arithmetic(), + "ModelFormat for inference.") + .value("PADDLE", ModelFormat::PADDLE) + .value("ONNX", ModelFormat::ONNX); pybind11::enum_(m, "Device", pybind11::arithmetic(), "Device for inference.") .value("CPU", Device::CPU) diff --git a/fastdeploy/pybind/main.h b/fastdeploy/pybind/main.h index 6eb3857dd..2392c9f2c 100644 --- a/fastdeploy/pybind/main.h +++ b/fastdeploy/pybind/main.h @@ -20,7 +20,7 @@ #include -#include "fastdeploy/fastdeploy_runtime.h" +#include "fastdeploy/runtime.h" #ifdef ENABLE_VISION #include "fastdeploy/vision.h" diff --git a/fastdeploy/fastdeploy_runtime.cc b/fastdeploy/runtime.cc similarity index 84% rename from fastdeploy/fastdeploy_runtime.cc rename to fastdeploy/runtime.cc index 92ecc2424..9f876ed00 100644 --- a/fastdeploy/fastdeploy_runtime.cc +++ b/fastdeploy/runtime.cc @@ -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(); auto casted_backend = dynamic_cast(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(); auto casted_backend = dynamic_cast(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(); auto casted_backend = dynamic_cast(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(); auto casted_backend = dynamic_cast(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(); auto casted_backend = dynamic_cast(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, diff --git a/fastdeploy/fastdeploy_runtime.h b/fastdeploy/runtime.h similarity index 94% rename from fastdeploy/fastdeploy_runtime.h rename to fastdeploy/runtime.h index c2a5e664b..65585efec 100644 --- a/fastdeploy/fastdeploy_runtime.h +++ b/fastdeploy/runtime.h @@ -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 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 diff --git a/fastdeploy/text/uie/model.cc b/fastdeploy/text/uie/model.cc index 682380871..6f71dd394 100644 --- a/fastdeploy/text/uie/model.cc +++ b/fastdeploy/text/uie/model.cc @@ -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& 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& 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) { diff --git a/fastdeploy/text/uie/model.h b/fastdeploy/text/uie/model.h index 5cbc9f43d..e867c21a8 100644 --- a/fastdeploy/text/uie/model.h +++ b/fastdeploy/text/uie/model.h @@ -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& 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& 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& schema, + const fastdeploy::RuntimeOption& custom_option = + fastdeploy::RuntimeOption(), + 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::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& schema, + const fastdeploy::RuntimeOption& custom_option = + fastdeploy::RuntimeOption(), + const fastdeploy::ModelFormat& model_format = + fastdeploy::ModelFormat::PADDLE); void SetSchema(const std::vector& schema); void SetSchema(const std::vector& schema); void SetSchema(const SchemaNode& schema); diff --git a/fastdeploy/text/uie/uie_pybind.cc b/fastdeploy/text/uie/uie_pybind.cc index d178eddc6..9e47c326f 100644 --- a/fastdeploy/text/uie/uie_pybind.cc +++ b/fastdeploy/text/uie/uie_pybind.cc @@ -30,23 +30,24 @@ void BindUIE(pybind11::module& m) { py::class_(m, "UIEModel") .def(py::init, RuntimeOption, Frontend>(), + std::vector, 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, 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, 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(), - 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&)>(&text::UIEModel::SetSchema), diff --git a/fastdeploy/vision/classification/ppcls/model.cc b/fastdeploy/vision/classification/ppcls/model.cc index fb02125fc..5f962f266 100644 --- a/fastdeploy/vision/classification/ppcls/model.cc +++ b/fastdeploy/vision/classification/ppcls/model.cc @@ -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; @@ -150,6 +151,6 @@ bool PaddleClasModel::Predict(cv::Mat* im, ClassifyResult* result, int topk) { return true; } -} // namespace classification -} // namespace vision -} // namespace fastdeploy +} // namespace classification +} // namespace vision +} // namespace fastdeploy diff --git a/fastdeploy/vision/classification/ppcls/model.h b/fastdeploy/vision/classification/ppcls/model.h index b412bcb2e..e3082bc2f 100644 --- a/fastdeploy/vision/classification/ppcls/model.h +++ b/fastdeploy/vision/classification/ppcls/model.h @@ -24,9 +24,9 @@ namespace classification { class FASTDEPLOY_DECL PaddleClasModel : public FastDeployModel { public: 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 std::string& config_file, + const RuntimeOption& custom_option = RuntimeOption(), + const ModelFormat& model_format = ModelFormat::PADDLE); virtual std::string ModelName() const { return "PaddleClas/Model"; } diff --git a/fastdeploy/vision/classification/ppcls/ppcls_pybind.cc b/fastdeploy/vision/classification/ppcls/ppcls_pybind.cc index 64fda235e..ea4e386f2 100644 --- a/fastdeploy/vision/classification/ppcls/ppcls_pybind.cc +++ b/fastdeploy/vision/classification/ppcls/ppcls_pybind.cc @@ -18,7 +18,7 @@ void BindPaddleClas(pybind11::module& m) { pybind11::class_( m, "PaddleClasModel") .def(pybind11::init()) + ModelFormat>()) .def("predict", [](vision::classification::PaddleClasModel& self, pybind11::array& data, int topk = 1) { auto mat = PyArrayToCvMat(data); diff --git a/fastdeploy/vision/detection/contrib/nanodet_plus.cc b/fastdeploy/vision/detection/contrib/nanodet_plus.cc index 267012c11..1d29fc531 100644 --- a/fastdeploy/vision/detection/contrib/nanodet_plus.cc +++ b/fastdeploy/vision/detection/contrib/nanodet_plus.cc @@ -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 { diff --git a/fastdeploy/vision/detection/contrib/nanodet_plus.h b/fastdeploy/vision/detection/contrib/nanodet_plus.h index a407b8715..9dfb9f65a 100644 --- a/fastdeploy/vision/detection/contrib/nanodet_plus.h +++ b/fastdeploy/vision/detection/contrib/nanodet_plus.h @@ -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"; } diff --git a/fastdeploy/vision/detection/contrib/nanodet_plus_pybind.cc b/fastdeploy/vision/detection/contrib/nanodet_plus_pybind.cc index b415c0b3b..e1fc19012 100644 --- a/fastdeploy/vision/detection/contrib/nanodet_plus_pybind.cc +++ b/fastdeploy/vision/detection/contrib/nanodet_plus_pybind.cc @@ -18,7 +18,8 @@ namespace fastdeploy { void BindNanoDetPlus(pybind11::module& m) { pybind11::class_( m, "NanoDetPlus") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::detection::NanoDetPlus& self, pybind11::array& data, float conf_threshold, float nms_iou_threshold) { diff --git a/fastdeploy/vision/detection/contrib/scaledyolov4.cc b/fastdeploy/vision/detection/contrib/scaledyolov4.cc index dff2118f3..5308a612f 100644 --- a/fastdeploy/vision/detection/contrib/scaledyolov4.cc +++ b/fastdeploy/vision/detection/contrib/scaledyolov4.cc @@ -60,8 +60,8 @@ void ScaledYOLOv4::LetterBox(Mat* mat, const std::vector& 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 { diff --git a/fastdeploy/vision/detection/contrib/scaledyolov4.h b/fastdeploy/vision/detection/contrib/scaledyolov4.h index bb7ff0a28..d48a5036c 100644 --- a/fastdeploy/vision/detection/contrib/scaledyolov4.h +++ b/fastdeploy/vision/detection/contrib/scaledyolov4.h @@ -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"; } diff --git a/fastdeploy/vision/detection/contrib/scaledyolov4_pybind.cc b/fastdeploy/vision/detection/contrib/scaledyolov4_pybind.cc index 3e8e43b9e..c15c426a0 100644 --- a/fastdeploy/vision/detection/contrib/scaledyolov4_pybind.cc +++ b/fastdeploy/vision/detection/contrib/scaledyolov4_pybind.cc @@ -18,7 +18,8 @@ namespace fastdeploy { void BindScaledYOLOv4(pybind11::module& m) { pybind11::class_( m, "ScaledYOLOv4") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::detection::ScaledYOLOv4& self, pybind11::array& data, float conf_threshold, float nms_iou_threshold) { diff --git a/fastdeploy/vision/detection/contrib/yolor.cc b/fastdeploy/vision/detection/contrib/yolor.cc index 5e6fa2fdd..ec770f32d 100644 --- a/fastdeploy/vision/detection/contrib/yolor.cc +++ b/fastdeploy/vision/detection/contrib/yolor.cc @@ -58,8 +58,9 @@ void YOLOR::LetterBox(Mat* mat, const std::vector& 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 { diff --git a/fastdeploy/vision/detection/contrib/yolor.h b/fastdeploy/vision/detection/contrib/yolor.h index 2de7a456f..8940969a5 100644 --- a/fastdeploy/vision/detection/contrib/yolor.h +++ b/fastdeploy/vision/detection/contrib/yolor.h @@ -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"; } diff --git a/fastdeploy/vision/detection/contrib/yolor_pybind.cc b/fastdeploy/vision/detection/contrib/yolor_pybind.cc index 0e0a21ca5..ea8be92f9 100644 --- a/fastdeploy/vision/detection/contrib/yolor_pybind.cc +++ b/fastdeploy/vision/detection/contrib/yolor_pybind.cc @@ -17,7 +17,8 @@ namespace fastdeploy { void BindYOLOR(pybind11::module& m) { pybind11::class_(m, "YOLOR") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::detection::YOLOR& self, pybind11::array& data, float conf_threshold, float nms_iou_threshold) { diff --git a/fastdeploy/vision/detection/contrib/yolov5.cc b/fastdeploy/vision/detection/contrib/yolov5.cc index b582bf299..b9be704c2 100644 --- a/fastdeploy/vision/detection/contrib/yolov5.cc +++ b/fastdeploy/vision/detection/contrib/yolov5.cc @@ -58,8 +58,8 @@ void YOLOv5::LetterBox(Mat* mat, std::vector 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 { diff --git a/fastdeploy/vision/detection/contrib/yolov5.h b/fastdeploy/vision/detection/contrib/yolov5.h index 1d2acb9ae..5f44acbe5 100644 --- a/fastdeploy/vision/detection/contrib/yolov5.h +++ b/fastdeploy/vision/detection/contrib/yolov5.h @@ -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"; } diff --git a/fastdeploy/vision/detection/contrib/yolov5_pybind.cc b/fastdeploy/vision/detection/contrib/yolov5_pybind.cc index 24d318a83..0f6d2a5c3 100644 --- a/fastdeploy/vision/detection/contrib/yolov5_pybind.cc +++ b/fastdeploy/vision/detection/contrib/yolov5_pybind.cc @@ -17,7 +17,8 @@ namespace fastdeploy { void BindYOLOv5(pybind11::module& m) { pybind11::class_(m, "YOLOv5") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::detection::YOLOv5& self, pybind11::array& data, float conf_threshold, float nms_iou_threshold) { diff --git a/fastdeploy/vision/detection/contrib/yolov5lite.cc b/fastdeploy/vision/detection/contrib/yolov5lite.cc index 26ca15f1e..87c1aff3d 100644 --- a/fastdeploy/vision/detection/contrib/yolov5lite.cc +++ b/fastdeploy/vision/detection/contrib/yolov5lite.cc @@ -84,8 +84,8 @@ void YOLOv5Lite::GenerateAnchors(const std::vector& 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 { diff --git a/fastdeploy/vision/detection/contrib/yolov5lite.h b/fastdeploy/vision/detection/contrib/yolov5lite.h index 2add202f4..fb717c9c8 100644 --- a/fastdeploy/vision/detection/contrib/yolov5lite.h +++ b/fastdeploy/vision/detection/contrib/yolov5lite.h @@ -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"; } diff --git a/fastdeploy/vision/detection/contrib/yolov5lite_pybind.cc b/fastdeploy/vision/detection/contrib/yolov5lite_pybind.cc index dd064e3be..f74308abc 100644 --- a/fastdeploy/vision/detection/contrib/yolov5lite_pybind.cc +++ b/fastdeploy/vision/detection/contrib/yolov5lite_pybind.cc @@ -18,7 +18,8 @@ namespace fastdeploy { void BindYOLOv5Lite(pybind11::module& m) { pybind11::class_(m, "YOLOv5Lite") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::detection::YOLOv5Lite& self, pybind11::array& data, float conf_threshold, float nms_iou_threshold) { diff --git a/fastdeploy/vision/detection/contrib/yolov6.cc b/fastdeploy/vision/detection/contrib/yolov6.cc index 08279c482..5f0182839 100644 --- a/fastdeploy/vision/detection/contrib/yolov6.cc +++ b/fastdeploy/vision/detection/contrib/yolov6.cc @@ -61,8 +61,8 @@ void YOLOv6::LetterBox(Mat* mat, std::vector 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 { diff --git a/fastdeploy/vision/detection/contrib/yolov6.h b/fastdeploy/vision/detection/contrib/yolov6.h index 64af6e2eb..51419e205 100644 --- a/fastdeploy/vision/detection/contrib/yolov6.h +++ b/fastdeploy/vision/detection/contrib/yolov6.h @@ -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"; } diff --git a/fastdeploy/vision/detection/contrib/yolov6_pybind.cc b/fastdeploy/vision/detection/contrib/yolov6_pybind.cc index a1d0131df..4414d6dcc 100644 --- a/fastdeploy/vision/detection/contrib/yolov6_pybind.cc +++ b/fastdeploy/vision/detection/contrib/yolov6_pybind.cc @@ -17,7 +17,8 @@ namespace fastdeploy { void BindYOLOv6(pybind11::module& m) { pybind11::class_(m, "YOLOv6") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::detection::YOLOv6& self, pybind11::array& data, float conf_threshold, float nms_iou_threshold) { diff --git a/fastdeploy/vision/detection/contrib/yolov7.cc b/fastdeploy/vision/detection/contrib/yolov7.cc index 759b7b187..1684f2fc4 100644 --- a/fastdeploy/vision/detection/contrib/yolov7.cc +++ b/fastdeploy/vision/detection/contrib/yolov7.cc @@ -59,8 +59,8 @@ void YOLOv7::LetterBox(Mat* mat, const std::vector& 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 { diff --git a/fastdeploy/vision/detection/contrib/yolov7.h b/fastdeploy/vision/detection/contrib/yolov7.h index 02b874b2c..ffbab559b 100644 --- a/fastdeploy/vision/detection/contrib/yolov7.h +++ b/fastdeploy/vision/detection/contrib/yolov7.h @@ -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"; } diff --git a/fastdeploy/vision/detection/contrib/yolov7_pybind.cc b/fastdeploy/vision/detection/contrib/yolov7_pybind.cc index bf196fa9f..37f375e5f 100644 --- a/fastdeploy/vision/detection/contrib/yolov7_pybind.cc +++ b/fastdeploy/vision/detection/contrib/yolov7_pybind.cc @@ -17,7 +17,8 @@ namespace fastdeploy { void BindYOLOv7(pybind11::module& m) { pybind11::class_(m, "YOLOv7") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::detection::YOLOv7& self, pybind11::array& data, float conf_threshold, float nms_iou_threshold) { diff --git a/fastdeploy/vision/detection/contrib/yolov7end2end_ort.cc b/fastdeploy/vision/detection/contrib/yolov7end2end_ort.cc index fea86df23..fd168520c 100644 --- a/fastdeploy/vision/detection/contrib/yolov7end2end_ort.cc +++ b/fastdeploy/vision/detection/contrib/yolov7end2end_ort.cc @@ -60,8 +60,8 @@ void YOLOv7End2EndORT::LetterBox(Mat* mat, const std::vector& 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 { diff --git a/fastdeploy/vision/detection/contrib/yolov7end2end_ort.h b/fastdeploy/vision/detection/contrib/yolov7end2end_ort.h index ac2ba6aa6..16f7e0bec 100644 --- a/fastdeploy/vision/detection/contrib/yolov7end2end_ort.h +++ b/fastdeploy/vision/detection/contrib/yolov7end2end_ort.h @@ -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"; } diff --git a/fastdeploy/vision/detection/contrib/yolov7end2end_ort_pybind.cc b/fastdeploy/vision/detection/contrib/yolov7end2end_ort_pybind.cc index 79794aaf2..7ae2db685 100644 --- a/fastdeploy/vision/detection/contrib/yolov7end2end_ort_pybind.cc +++ b/fastdeploy/vision/detection/contrib/yolov7end2end_ort_pybind.cc @@ -18,7 +18,8 @@ namespace fastdeploy { void BindYOLOv7End2EndORT(pybind11::module& m) { pybind11::class_( m, "YOLOv7End2EndORT") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::detection::YOLOv7End2EndORT& self, pybind11::array& data, float conf_threshold) { diff --git a/fastdeploy/vision/detection/contrib/yolov7end2end_trt.cc b/fastdeploy/vision/detection/contrib/yolov7end2end_trt.cc index 0a205bca6..a47e7e203 100644 --- a/fastdeploy/vision/detection/contrib/yolov7end2end_trt.cc +++ b/fastdeploy/vision/detection/contrib/yolov7end2end_trt.cc @@ -60,8 +60,8 @@ void YOLOv7End2EndTRT::LetterBox(Mat* mat, const std::vector& 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 { diff --git a/fastdeploy/vision/detection/contrib/yolov7end2end_trt.h b/fastdeploy/vision/detection/contrib/yolov7end2end_trt.h index 21eaf11eb..61d11dceb 100644 --- a/fastdeploy/vision/detection/contrib/yolov7end2end_trt.h +++ b/fastdeploy/vision/detection/contrib/yolov7end2end_trt.h @@ -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"; } diff --git a/fastdeploy/vision/detection/contrib/yolov7end2end_trt_pybind.cc b/fastdeploy/vision/detection/contrib/yolov7end2end_trt_pybind.cc index 121968e5d..9a7aeb8dd 100644 --- a/fastdeploy/vision/detection/contrib/yolov7end2end_trt_pybind.cc +++ b/fastdeploy/vision/detection/contrib/yolov7end2end_trt_pybind.cc @@ -18,7 +18,8 @@ namespace fastdeploy { void BindYOLOv7End2EndTRT(pybind11::module& m) { pybind11::class_( m, "YOLOv7End2EndTRT") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::detection::YOLOv7End2EndTRT& self, pybind11::array& data, float conf_threshold) { diff --git a/fastdeploy/vision/detection/contrib/yolox.cc b/fastdeploy/vision/detection/contrib/yolox.cc index 99542d332..4380d5e3c 100644 --- a/fastdeploy/vision/detection/contrib/yolox.cc +++ b/fastdeploy/vision/detection/contrib/yolox.cc @@ -73,8 +73,9 @@ void LetterBoxWithRightBottomPad(Mat* mat, std::vector 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 { diff --git a/fastdeploy/vision/detection/contrib/yolox.h b/fastdeploy/vision/detection/contrib/yolox.h index fc27ca1ed..d9e88bf30 100644 --- a/fastdeploy/vision/detection/contrib/yolox.h +++ b/fastdeploy/vision/detection/contrib/yolox.h @@ -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"; } diff --git a/fastdeploy/vision/detection/contrib/yolox_pybind.cc b/fastdeploy/vision/detection/contrib/yolox_pybind.cc index 68cb6a426..0c033126a 100644 --- a/fastdeploy/vision/detection/contrib/yolox_pybind.cc +++ b/fastdeploy/vision/detection/contrib/yolox_pybind.cc @@ -17,7 +17,8 @@ namespace fastdeploy { void BindYOLOX(pybind11::module& m) { pybind11::class_(m, "YOLOX") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::detection::YOLOX& self, pybind11::array& data, float conf_threshold, float nms_iou_threshold) { diff --git a/fastdeploy/vision/detection/ppdet/mask_rcnn.cc b/fastdeploy/vision/detection/ppdet/mask_rcnn.cc index e4db56bfd..60b92d688 100644 --- a/fastdeploy/vision/detection/ppdet/mask_rcnn.cc +++ b/fastdeploy/vision/detection/ppdet/mask_rcnn.cc @@ -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}; diff --git a/fastdeploy/vision/detection/ppdet/mask_rcnn.h b/fastdeploy/vision/detection/ppdet/mask_rcnn.h index a3c4bc962..a24d1f42c 100644 --- a/fastdeploy/vision/detection/ppdet/mask_rcnn.h +++ b/fastdeploy/vision/detection/ppdet/mask_rcnn.h @@ -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"; } diff --git a/fastdeploy/vision/detection/ppdet/picodet.cc b/fastdeploy/vision/detection/ppdet/picodet.cc index 3b651ccf5..abde7eca4 100644 --- a/fastdeploy/vision/detection/ppdet/picodet.cc +++ b/fastdeploy/vision/detection/ppdet/picodet.cc @@ -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}; diff --git a/fastdeploy/vision/detection/ppdet/picodet.h b/fastdeploy/vision/detection/ppdet/picodet.h index 984e56222..5f85d2dd9 100644 --- a/fastdeploy/vision/detection/ppdet/picodet.h +++ b/fastdeploy/vision/detection/ppdet/picodet.h @@ -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(); diff --git a/fastdeploy/vision/detection/ppdet/ppdet_pybind.cc b/fastdeploy/vision/detection/ppdet/ppdet_pybind.cc index fc41d6203..01a6a8ce1 100644 --- a/fastdeploy/vision/detection/ppdet/ppdet_pybind.cc +++ b/fastdeploy/vision/detection/ppdet/ppdet_pybind.cc @@ -17,7 +17,7 @@ namespace fastdeploy { void BindPPDet(pybind11::module& m) { pybind11::class_(m, "PPYOLOE") .def(pybind11::init()) + 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_(m, "PPYOLO") .def(pybind11::init()) + 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_(m, "PPYOLOv2") .def(pybind11::init()) + 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_(m, "PicoDet") .def(pybind11::init()) + 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_( m, "PaddleYOLOX") .def(pybind11::init()) + 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_(m, "FasterRCNN") .def(pybind11::init()) + 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_(m, "YOLOv3") .def(pybind11::init()) + 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_(m, "MaskRCNN") .def(pybind11::init()) + ModelFormat>()) .def("predict", [](vision::detection::MaskRCNN& self, pybind11::array& data) { auto mat = PyArrayToCvMat(data); diff --git a/fastdeploy/vision/detection/ppdet/ppyolo.cc b/fastdeploy/vision/detection/ppdet/ppyolo.cc index 06b701dfb..befa16e18 100644 --- a/fastdeploy/vision/detection/ppdet/ppyolo.cc +++ b/fastdeploy/vision/detection/ppdet/ppyolo.cc @@ -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}; diff --git a/fastdeploy/vision/detection/ppdet/ppyolo.h b/fastdeploy/vision/detection/ppdet/ppyolo.h index 1b3b48780..6f288a9db 100644 --- a/fastdeploy/vision/detection/ppdet/ppyolo.h +++ b/fastdeploy/vision/detection/ppdet/ppyolo.h @@ -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"; } @@ -36,12 +36,13 @@ class FASTDEPLOY_DECL PPYOLO : public PPYOLOE { }; class FASTDEPLOY_DECL PPYOLOv2 : public PPYOLO { - public: + public: 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 std::string& config_file, + const RuntimeOption& custom_option = RuntimeOption(), + 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"; } }; diff --git a/fastdeploy/vision/detection/ppdet/ppyoloe.cc b/fastdeploy/vision/detection/ppdet/ppyoloe.cc index 8f95a1acd..0c0207404 100644 --- a/fastdeploy/vision/detection/ppdet/ppyoloe.cc +++ b/fastdeploy/vision/detection/ppdet/ppyoloe.cc @@ -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; @@ -159,7 +159,7 @@ bool PPYOLOE::Preprocess(Mat* mat, std::vector* outputs) { return false; } } - + Cast::Run(mat, "float"); outputs->resize(2); diff --git a/fastdeploy/vision/detection/ppdet/ppyoloe.h b/fastdeploy/vision/detection/ppdet/ppyoloe.h index ecbce2190..0d2e97d86 100644 --- a/fastdeploy/vision/detection/ppdet/ppyoloe.h +++ b/fastdeploy/vision/detection/ppdet/ppyoloe.h @@ -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"; } diff --git a/fastdeploy/vision/detection/ppdet/rcnn.cc b/fastdeploy/vision/detection/ppdet/rcnn.cc index 38ecc3d1c..709c8b643 100644 --- a/fastdeploy/vision/detection/ppdet/rcnn.cc +++ b/fastdeploy/vision/detection/ppdet/rcnn.cc @@ -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}; diff --git a/fastdeploy/vision/detection/ppdet/rcnn.h b/fastdeploy/vision/detection/ppdet/rcnn.h index d44ca852e..df42b8efc 100644 --- a/fastdeploy/vision/detection/ppdet/rcnn.h +++ b/fastdeploy/vision/detection/ppdet/rcnn.h @@ -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"; } diff --git a/fastdeploy/vision/detection/ppdet/yolov3.cc b/fastdeploy/vision/detection/ppdet/yolov3.cc index 35f8463ac..3ebcfe49f 100644 --- a/fastdeploy/vision/detection/ppdet/yolov3.cc +++ b/fastdeploy/vision/detection/ppdet/yolov3.cc @@ -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}; diff --git a/fastdeploy/vision/detection/ppdet/yolov3.h b/fastdeploy/vision/detection/ppdet/yolov3.h index 1b65bfca1..ebafa6edd 100644 --- a/fastdeploy/vision/detection/ppdet/yolov3.h +++ b/fastdeploy/vision/detection/ppdet/yolov3.h @@ -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"; } diff --git a/fastdeploy/vision/detection/ppdet/yolox.cc b/fastdeploy/vision/detection/ppdet/yolox.cc index dbf0824ba..9401a30d8 100644 --- a/fastdeploy/vision/detection/ppdet/yolox.cc +++ b/fastdeploy/vision/detection/ppdet/yolox.cc @@ -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}; diff --git a/fastdeploy/vision/detection/ppdet/yolox.h b/fastdeploy/vision/detection/ppdet/yolox.h index 4ffe2f39c..dd0a11b57 100644 --- a/fastdeploy/vision/detection/ppdet/yolox.h +++ b/fastdeploy/vision/detection/ppdet/yolox.h @@ -22,9 +22,9 @@ namespace detection { class FASTDEPLOY_DECL PaddleYOLOX : public PPYOLOE { public: 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 std::string& config_file, + const RuntimeOption& custom_option = RuntimeOption(), + const ModelFormat& model_format = ModelFormat::PADDLE); virtual bool Preprocess(Mat* mat, std::vector* outputs); diff --git a/fastdeploy/vision/facedet/contrib/retinaface.cc b/fastdeploy/vision/facedet/contrib/retinaface.cc index ebb52010e..dda6b9715 100644 --- a/fastdeploy/vision/facedet/contrib/retinaface.cc +++ b/fastdeploy/vision/facedet/contrib/retinaface.cc @@ -79,8 +79,8 @@ void GenerateRetinaAnchors(const std::vector& 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 { diff --git a/fastdeploy/vision/facedet/contrib/retinaface.h b/fastdeploy/vision/facedet/contrib/retinaface.h index e1ef50e2e..d14396c6b 100644 --- a/fastdeploy/vision/facedet/contrib/retinaface.h +++ b/fastdeploy/vision/facedet/contrib/retinaface.h @@ -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"; } diff --git a/fastdeploy/vision/facedet/contrib/retinaface_pybind.cc b/fastdeploy/vision/facedet/contrib/retinaface_pybind.cc index 9419327c4..19b0d608c 100644 --- a/fastdeploy/vision/facedet/contrib/retinaface_pybind.cc +++ b/fastdeploy/vision/facedet/contrib/retinaface_pybind.cc @@ -18,7 +18,8 @@ namespace fastdeploy { void BindRetinaFace(pybind11::module& m) { pybind11::class_(m, "RetinaFace") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::facedet::RetinaFace& self, pybind11::array& data, float conf_threshold, float nms_iou_threshold) { diff --git a/fastdeploy/vision/facedet/contrib/scrfd.cc b/fastdeploy/vision/facedet/contrib/scrfd.cc index ffcff65c9..b0bfd7a54 100644 --- a/fastdeploy/vision/facedet/contrib/scrfd.cc +++ b/fastdeploy/vision/facedet/contrib/scrfd.cc @@ -60,8 +60,9 @@ void SCRFD::LetterBox(Mat* mat, const std::vector& 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 { diff --git a/fastdeploy/vision/facedet/contrib/scrfd.h b/fastdeploy/vision/facedet/contrib/scrfd.h index 398301363..b409cbc4f 100644 --- a/fastdeploy/vision/facedet/contrib/scrfd.h +++ b/fastdeploy/vision/facedet/contrib/scrfd.h @@ -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"; } diff --git a/fastdeploy/vision/facedet/contrib/scrfd_pybind.cc b/fastdeploy/vision/facedet/contrib/scrfd_pybind.cc index 7cfa4d025..4f70126d9 100644 --- a/fastdeploy/vision/facedet/contrib/scrfd_pybind.cc +++ b/fastdeploy/vision/facedet/contrib/scrfd_pybind.cc @@ -18,7 +18,8 @@ namespace fastdeploy { void BindSCRFD(pybind11::module& m) { // Bind SCRFD pybind11::class_(m, "SCRFD") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::facedet::SCRFD& self, pybind11::array& data, float conf_threshold, float nms_iou_threshold) { diff --git a/fastdeploy/vision/facedet/contrib/ultraface.cc b/fastdeploy/vision/facedet/contrib/ultraface.cc index ed4962306..907a397f7 100644 --- a/fastdeploy/vision/facedet/contrib/ultraface.cc +++ b/fastdeploy/vision/facedet/contrib/ultraface.cc @@ -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 { diff --git a/fastdeploy/vision/facedet/contrib/ultraface.h b/fastdeploy/vision/facedet/contrib/ultraface.h index 387bc1f9a..c26d9dd7a 100644 --- a/fastdeploy/vision/facedet/contrib/ultraface.h +++ b/fastdeploy/vision/facedet/contrib/ultraface.h @@ -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 { diff --git a/fastdeploy/vision/facedet/contrib/ultraface_pybind.cc b/fastdeploy/vision/facedet/contrib/ultraface_pybind.cc index 855c26908..059dafa8f 100644 --- a/fastdeploy/vision/facedet/contrib/ultraface_pybind.cc +++ b/fastdeploy/vision/facedet/contrib/ultraface_pybind.cc @@ -17,7 +17,8 @@ namespace fastdeploy { void BindUltraFace(pybind11::module& m) { pybind11::class_(m, "UltraFace") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::facedet::UltraFace& self, pybind11::array& data, float conf_threshold, float nms_iou_threshold) { diff --git a/fastdeploy/vision/facedet/contrib/yolov5face.cc b/fastdeploy/vision/facedet/contrib/yolov5face.cc index 96af230b0..1a02b0919 100644 --- a/fastdeploy/vision/facedet/contrib/yolov5face.cc +++ b/fastdeploy/vision/facedet/contrib/yolov5face.cc @@ -62,8 +62,8 @@ void LetterBox(Mat* mat, std::vector size, std::vector 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 { diff --git a/fastdeploy/vision/facedet/contrib/yolov5face.h b/fastdeploy/vision/facedet/contrib/yolov5face.h index 017c9681a..bc12876c0 100644 --- a/fastdeploy/vision/facedet/contrib/yolov5face.h +++ b/fastdeploy/vision/facedet/contrib/yolov5face.h @@ -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"; } diff --git a/fastdeploy/vision/facedet/contrib/yolov5face_pybind.cc b/fastdeploy/vision/facedet/contrib/yolov5face_pybind.cc index b843d4a9f..b3706c514 100644 --- a/fastdeploy/vision/facedet/contrib/yolov5face_pybind.cc +++ b/fastdeploy/vision/facedet/contrib/yolov5face_pybind.cc @@ -18,7 +18,8 @@ namespace fastdeploy { void BindYOLOv5Face(pybind11::module& m) { pybind11::class_(m, "YOLOv5Face") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::facedet::YOLOv5Face& self, pybind11::array& data, float conf_threshold, float nms_iou_threshold) { diff --git a/fastdeploy/vision/faceid/contrib/arcface.cc b/fastdeploy/vision/faceid/contrib/arcface.cc index 9c2b64763..1583c7883 100644 --- a/fastdeploy/vision/faceid/contrib/arcface.cc +++ b/fastdeploy/vision/faceid/contrib/arcface.cc @@ -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(); diff --git a/fastdeploy/vision/faceid/contrib/arcface.h b/fastdeploy/vision/faceid/contrib/arcface.h index 698fadceb..247beb5d5 100644 --- a/fastdeploy/vision/faceid/contrib/arcface.h +++ b/fastdeploy/vision/faceid/contrib/arcface.h @@ -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 { diff --git a/fastdeploy/vision/faceid/contrib/arcface_pybind.cc b/fastdeploy/vision/faceid/contrib/arcface_pybind.cc index cd9bf7c57..0d508f444 100644 --- a/fastdeploy/vision/faceid/contrib/arcface_pybind.cc +++ b/fastdeploy/vision/faceid/contrib/arcface_pybind.cc @@ -19,7 +19,8 @@ void BindArcFace(pybind11::module& m) { // Bind ArcFace pybind11::class_(m, "ArcFace") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::faceid::ArcFace& self, pybind11::array& data) { auto mat = PyArrayToCvMat(data); diff --git a/fastdeploy/vision/faceid/contrib/cosface.cc b/fastdeploy/vision/faceid/contrib/cosface.cc index 4a4d6dc55..c0b5144f6 100644 --- a/fastdeploy/vision/faceid/contrib/cosface.cc +++ b/fastdeploy/vision/faceid/contrib/cosface.cc @@ -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(); diff --git a/fastdeploy/vision/faceid/contrib/cosface.h b/fastdeploy/vision/faceid/contrib/cosface.h index 92704536c..493326750 100644 --- a/fastdeploy/vision/faceid/contrib/cosface.h +++ b/fastdeploy/vision/faceid/contrib/cosface.h @@ -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 diff --git a/fastdeploy/vision/faceid/contrib/cosface_pybind.cc b/fastdeploy/vision/faceid/contrib/cosface_pybind.cc index c09f9e723..fe27a95b7 100644 --- a/fastdeploy/vision/faceid/contrib/cosface_pybind.cc +++ b/fastdeploy/vision/faceid/contrib/cosface_pybind.cc @@ -19,7 +19,8 @@ void BindCosFace(pybind11::module& m) { // Bind CosFace pybind11::class_(m, "CosFace") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::faceid::CosFace& self, pybind11::array& data) { auto mat = PyArrayToCvMat(data); diff --git a/fastdeploy/vision/faceid/contrib/insightface_rec.cc b/fastdeploy/vision/faceid/contrib/insightface_rec.cc index ddd7520d4..89ff6a004 100644 --- a/fastdeploy/vision/faceid/contrib/insightface_rec.cc +++ b/fastdeploy/vision/faceid/contrib/insightface_rec.cc @@ -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 { diff --git a/fastdeploy/vision/faceid/contrib/insightface_rec.h b/fastdeploy/vision/faceid/contrib/insightface_rec.h index b8eb27262..9ed3fb39f 100644 --- a/fastdeploy/vision/faceid/contrib/insightface_rec.h +++ b/fastdeploy/vision/faceid/contrib/insightface_rec.h @@ -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"; } diff --git a/fastdeploy/vision/faceid/contrib/insightface_rec_pybind.cc b/fastdeploy/vision/faceid/contrib/insightface_rec_pybind.cc index 78df369bb..bbbe60d3a 100644 --- a/fastdeploy/vision/faceid/contrib/insightface_rec_pybind.cc +++ b/fastdeploy/vision/faceid/contrib/insightface_rec_pybind.cc @@ -19,7 +19,8 @@ void BindInsightFaceRecognitionModel(pybind11::module& m) { // Bind InsightFaceRecognitionModel pybind11::class_(m, "InsightFaceRecognitionModel") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::faceid::InsightFaceRecognitionModel& self, pybind11::array& data) { diff --git a/fastdeploy/vision/faceid/contrib/partial_fc.cc b/fastdeploy/vision/faceid/contrib/partial_fc.cc index 8f13226cb..2ad3d3a52 100644 --- a/fastdeploy/vision/faceid/contrib/partial_fc.cc +++ b/fastdeploy/vision/faceid/contrib/partial_fc.cc @@ -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(); diff --git a/fastdeploy/vision/faceid/contrib/partial_fc.h b/fastdeploy/vision/faceid/contrib/partial_fc.h index 88a1f2a2a..cbbda4364 100644 --- a/fastdeploy/vision/faceid/contrib/partial_fc.h +++ b/fastdeploy/vision/faceid/contrib/partial_fc.h @@ -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 { diff --git a/fastdeploy/vision/faceid/contrib/partial_fc_pybind.cc b/fastdeploy/vision/faceid/contrib/partial_fc_pybind.cc index b8cb31358..4b1761ca1 100644 --- a/fastdeploy/vision/faceid/contrib/partial_fc_pybind.cc +++ b/fastdeploy/vision/faceid/contrib/partial_fc_pybind.cc @@ -19,7 +19,8 @@ void BindPartialFC(pybind11::module& m) { // Bind Partial FC pybind11::class_(m, "PartialFC") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::faceid::PartialFC& self, pybind11::array& data) { auto mat = PyArrayToCvMat(data); diff --git a/fastdeploy/vision/faceid/contrib/vpl.cc b/fastdeploy/vision/faceid/contrib/vpl.cc index bb34d3993..b423c3348 100644 --- a/fastdeploy/vision/faceid/contrib/vpl.cc +++ b/fastdeploy/vision/faceid/contrib/vpl.cc @@ -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(); diff --git a/fastdeploy/vision/faceid/contrib/vpl.h b/fastdeploy/vision/faceid/contrib/vpl.h index 696d13ac3..dd5476ba8 100644 --- a/fastdeploy/vision/faceid/contrib/vpl.h +++ b/fastdeploy/vision/faceid/contrib/vpl.h @@ -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 { diff --git a/fastdeploy/vision/faceid/contrib/vpl_pybind.cc b/fastdeploy/vision/faceid/contrib/vpl_pybind.cc index 448cf3d3b..8d3369b95 100644 --- a/fastdeploy/vision/faceid/contrib/vpl_pybind.cc +++ b/fastdeploy/vision/faceid/contrib/vpl_pybind.cc @@ -19,7 +19,8 @@ void BindVPL(pybind11::module& m) { // Bind VPL pybind11::class_(m, "VPL") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::faceid::VPL& self, pybind11::array& data) { auto mat = PyArrayToCvMat(data); diff --git a/fastdeploy/vision/matting/contrib/modnet.cc b/fastdeploy/vision/matting/contrib/modnet.cc index b98d055e3..4343abd7a 100644 --- a/fastdeploy/vision/matting/contrib/modnet.cc +++ b/fastdeploy/vision/matting/contrib/modnet.cc @@ -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 { diff --git a/fastdeploy/vision/matting/contrib/modnet.h b/fastdeploy/vision/matting/contrib/modnet.h index 047fd3aea..228af1e89 100644 --- a/fastdeploy/vision/matting/contrib/modnet.h +++ b/fastdeploy/vision/matting/contrib/modnet.h @@ -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"; } diff --git a/fastdeploy/vision/matting/contrib/modnet_pybind.cc b/fastdeploy/vision/matting/contrib/modnet_pybind.cc index bfb8b1f88..47a4976a9 100644 --- a/fastdeploy/vision/matting/contrib/modnet_pybind.cc +++ b/fastdeploy/vision/matting/contrib/modnet_pybind.cc @@ -18,7 +18,8 @@ namespace fastdeploy { void BindMODNet(pybind11::module& m) { // Bind MODNet pybind11::class_(m, "MODNet") - .def(pybind11::init()) + .def(pybind11::init()) .def("predict", [](vision::matting::MODNet& self, pybind11::array& data) { auto mat = PyArrayToCvMat(data); diff --git a/fastdeploy/vision/matting/ppmatting/ppmatting.cc b/fastdeploy/vision/matting/ppmatting/ppmatting.cc index b5a4fe0ae..3f2b8d4f8 100644 --- a/fastdeploy/vision/matting/ppmatting/ppmatting.cc +++ b/fastdeploy/vision/matting/ppmatting/ppmatting.cc @@ -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}; diff --git a/fastdeploy/vision/matting/ppmatting/ppmatting.h b/fastdeploy/vision/matting/ppmatting/ppmatting.h index 763d43077..8cb382595 100644 --- a/fastdeploy/vision/matting/ppmatting/ppmatting.h +++ b/fastdeploy/vision/matting/ppmatting/ppmatting.h @@ -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"; } diff --git a/fastdeploy/vision/matting/ppmatting/ppmatting_pybind.cc b/fastdeploy/vision/matting/ppmatting/ppmatting_pybind.cc index 16e524b56..97837fa6f 100644 --- a/fastdeploy/vision/matting/ppmatting/ppmatting_pybind.cc +++ b/fastdeploy/vision/matting/ppmatting/ppmatting_pybind.cc @@ -17,7 +17,7 @@ namespace fastdeploy { void BindPPMatting(pybind11::module& m) { pybind11::class_(m, "PPMatting") .def(pybind11::init()) + ModelFormat>()) .def("predict", [](vision::matting::PPMatting& self, pybind11::array& data) { auto mat = PyArrayToCvMat(data); diff --git a/fastdeploy/vision/ocr/ppocr/classifier.cc b/fastdeploy/vision/ocr/ppocr/classifier.cc index c8ce1ccc1..d0d9d9016 100644 --- a/fastdeploy/vision/ocr/ppocr/classifier.cc +++ b/fastdeploy/vision/ocr/ppocr/classifier.cc @@ -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}; diff --git a/fastdeploy/vision/ocr/ppocr/classifier.h b/fastdeploy/vision/ocr/ppocr/classifier.h index 39fc102c3..397775de6 100644 --- a/fastdeploy/vision/ocr/ppocr/classifier.h +++ b/fastdeploy/vision/ocr/ppocr/classifier.h @@ -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"; } diff --git a/fastdeploy/vision/ocr/ppocr/dbdetector.cc b/fastdeploy/vision/ocr/ppocr/dbdetector.cc index c43b0b8fc..5ed3bae2c 100644 --- a/fastdeploy/vision/ocr/ppocr/dbdetector.cc +++ b/fastdeploy/vision/ocr/ppocr/dbdetector.cc @@ -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}; diff --git a/fastdeploy/vision/ocr/ppocr/dbdetector.h b/fastdeploy/vision/ocr/ppocr/dbdetector.h index 38350f7b7..316035aa6 100644 --- a/fastdeploy/vision/ocr/ppocr/dbdetector.h +++ b/fastdeploy/vision/ocr/ppocr/dbdetector.h @@ -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"; } diff --git a/fastdeploy/vision/ocr/ppocr/ocrmodel_pybind.cc b/fastdeploy/vision/ocr/ppocr/ocrmodel_pybind.cc index e70a21d09..2e4e3e85b 100644 --- a/fastdeploy/vision/ocr/ppocr/ocrmodel_pybind.cc +++ b/fastdeploy/vision/ocr/ppocr/ocrmodel_pybind.cc @@ -18,7 +18,8 @@ namespace fastdeploy { void BindPPOCRModel(pybind11::module& m) { // DBDetector pybind11::class_(m, "DBDetector") - .def(pybind11::init()) + .def(pybind11::init()) .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_(m, "Classifier") - .def(pybind11::init()) + .def(pybind11::init()) .def(pybind11::init<>()) .def_readwrite("cls_thresh", &vision::ocr::Classifier::cls_thresh) @@ -48,7 +50,7 @@ void BindPPOCRModel(pybind11::module& m) { pybind11::class_(m, "Recognizer") .def(pybind11::init()) + ModelFormat>()) .def(pybind11::init<>()) .def_readwrite("rec_img_h", &vision::ocr::Recognizer::rec_img_h) diff --git a/fastdeploy/vision/ocr/ppocr/recognizer.cc b/fastdeploy/vision/ocr/ppocr/recognizer.cc index 3e74f5a8c..84b90afee 100644 --- a/fastdeploy/vision/ocr/ppocr/recognizer.cc +++ b/fastdeploy/vision/ocr/ppocr/recognizer.cc @@ -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推理 diff --git a/fastdeploy/vision/ocr/ppocr/recognizer.h b/fastdeploy/vision/ocr/ppocr/recognizer.h index 2c6343f7f..a6fea9117 100644 --- a/fastdeploy/vision/ocr/ppocr/recognizer.h +++ b/fastdeploy/vision/ocr/ppocr/recognizer.h @@ -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"; } diff --git a/fastdeploy/vision/segmentation/ppseg/model.cc b/fastdeploy/vision/segmentation/ppseg/model.cc index 752dacc96..918bd75d2 100644 --- a/fastdeploy/vision/segmentation/ppseg/model.cc +++ b/fastdeploy/vision/segmentation/ppseg/model.cc @@ -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}; diff --git a/fastdeploy/vision/segmentation/ppseg/model.h b/fastdeploy/vision/segmentation/ppseg/model.h index c1491cb0b..06704d81a 100644 --- a/fastdeploy/vision/segmentation/ppseg/model.h +++ b/fastdeploy/vision/segmentation/ppseg/model.h @@ -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"; } diff --git a/fastdeploy/vision/segmentation/ppseg/ppseg_pybind.cc b/fastdeploy/vision/segmentation/ppseg/ppseg_pybind.cc index 3258e52b2..c94b7fd19 100644 --- a/fastdeploy/vision/segmentation/ppseg/ppseg_pybind.cc +++ b/fastdeploy/vision/segmentation/ppseg/ppseg_pybind.cc @@ -18,7 +18,7 @@ void BindPPSeg(pybind11::module& m) { pybind11::class_( m, "PaddleSegModel") .def(pybind11::init()) + ModelFormat>()) .def("predict", [](vision::segmentation::PaddleSegModel& self, pybind11::array& data) { diff --git a/python/fastdeploy/__init__.py b/python/fastdeploy/__init__.py index 0f45f5778..657a6cf40 100644 --- a/python/fastdeploy/__init__.py +++ b/python/fastdeploy/__init__.py @@ -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) diff --git a/python/fastdeploy/text/uie/__init__.py b/python/fastdeploy/text/uie/__init__.py index 37a025601..b6676159a 100644 --- a/python/fastdeploy/text/uie/__init__.py +++ b/python/fastdeploy/text/uie/__init__.py @@ -15,7 +15,7 @@ from __future__ import absolute_import import logging -from ... import Frontend +from ... import ModelFormat from ... import RuntimeOption from ... import c_lib_wrap as C @@ -47,7 +47,7 @@ class UIEModel(object): max_length=128, schema=[], runtime_option=RuntimeOption(), - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): if isinstance(schema, list): schema = SchemaNode("", schema)._schema_node_children elif isinstance(schema, dict): diff --git a/python/fastdeploy/vision/classification/ppcls/__init__.py b/python/fastdeploy/vision/classification/ppcls/__init__.py index ade0f7a99..256fa3936 100644 --- a/python/fastdeploy/vision/classification/ppcls/__init__.py +++ b/python/fastdeploy/vision/classification/ppcls/__init__.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -24,10 +24,10 @@ class PaddleClasModel(FastDeployModel): params_file, config_file, runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): super(PaddleClasModel, self).__init__(runtime_option) - assert model_format == Frontend.PADDLE, "PaddleClasModel only support model format of Frontend.Paddle now." + assert model_format == ModelFormat.PADDLE, "PaddleClasModel only support model format of ModelFormat.Paddle now." self._model = C.vision.classification.PaddleClasModel( model_file, params_file, config_file, self._runtime_option, model_format) diff --git a/python/fastdeploy/vision/detection/contrib/nanodet_plus.py b/python/fastdeploy/vision/detection/contrib/nanodet_plus.py index d7d28b794..a46dd7a9e 100644 --- a/python/fastdeploy/vision/detection/contrib/nanodet_plus.py +++ b/python/fastdeploy/vision/detection/contrib/nanodet_plus.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class NanoDetPlus(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(NanoDetPlus, self).__init__(runtime_option) diff --git a/python/fastdeploy/vision/detection/contrib/scaled_yolov4.py b/python/fastdeploy/vision/detection/contrib/scaled_yolov4.py index 29ce6b404..aebb60fb0 100644 --- a/python/fastdeploy/vision/detection/contrib/scaled_yolov4.py +++ b/python/fastdeploy/vision/detection/contrib/scaled_yolov4.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class ScaledYOLOv4(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(ScaledYOLOv4, self).__init__(runtime_option) @@ -92,21 +92,19 @@ class ScaledYOLOv4(FastDeployModel): @is_mini_pad.setter def is_mini_pad(self, value): assert isinstance( - value, - bool), "The value to set `is_mini_pad` must be type of bool." + value, bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, - bool), "The value to set `is_scale_up` must be type of bool." + value, bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance( - value, int), "The value to set `stride` must be type of int." + assert isinstance(value, + int), "The value to set `stride` must be type of int." self._model.stride = value @max_wh.setter diff --git a/python/fastdeploy/vision/detection/contrib/yolor.py b/python/fastdeploy/vision/detection/contrib/yolor.py index 44f5128c0..054507612 100644 --- a/python/fastdeploy/vision/detection/contrib/yolor.py +++ b/python/fastdeploy/vision/detection/contrib/yolor.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class YOLOR(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOR, self).__init__(runtime_option) @@ -92,21 +92,19 @@ class YOLOR(FastDeployModel): @is_mini_pad.setter def is_mini_pad(self, value): assert isinstance( - value, - bool), "The value to set `is_mini_pad` must be type of bool." + value, bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, - bool), "The value to set `is_scale_up` must be type of bool." + value, bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance( - value, int), "The value to set `stride` must be type of int." + assert isinstance(value, + int), "The value to set `stride` must be type of int." self._model.stride = value @max_wh.setter diff --git a/python/fastdeploy/vision/detection/contrib/yolov5.py b/python/fastdeploy/vision/detection/contrib/yolov5.py index 51d505988..2f4d00b82 100644 --- a/python/fastdeploy/vision/detection/contrib/yolov5.py +++ b/python/fastdeploy/vision/detection/contrib/yolov5.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class YOLOv5(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv5, self).__init__(runtime_option) @@ -121,21 +121,19 @@ class YOLOv5(FastDeployModel): @is_mini_pad.setter def is_mini_pad(self, value): assert isinstance( - value, - bool), "The value to set `is_mini_pad` must be type of bool." + value, bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, - bool), "The value to set `is_scale_up` must be type of bool." + value, bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance( - value, int), "The value to set `stride` must be type of int." + assert isinstance(value, + int), "The value to set `stride` must be type of int." self._model.stride = value @max_wh.setter @@ -147,6 +145,5 @@ class YOLOv5(FastDeployModel): @multi_label.setter def multi_label(self, value): assert isinstance( - value, - bool), "The value to set `multi_label` must be type of bool." + value, bool), "The value to set `multi_label` must be type of bool." self._model.multi_label = value diff --git a/python/fastdeploy/vision/detection/contrib/yolov5lite.py b/python/fastdeploy/vision/detection/contrib/yolov5lite.py index 2168f0cc5..b113e565f 100644 --- a/python/fastdeploy/vision/detection/contrib/yolov5lite.py +++ b/python/fastdeploy/vision/detection/contrib/yolov5lite.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class YOLOv5Lite(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv5Lite, self).__init__(runtime_option) @@ -100,21 +100,19 @@ class YOLOv5Lite(FastDeployModel): @is_mini_pad.setter def is_mini_pad(self, value): assert isinstance( - value, - bool), "The value to set `is_mini_pad` must be type of bool." + value, bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, - bool), "The value to set `is_scale_up` must be type of bool." + value, bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance( - value, int), "The value to set `stride` must be type of int." + assert isinstance(value, + int), "The value to set `stride` must be type of int." self._model.stride = value @max_wh.setter diff --git a/python/fastdeploy/vision/detection/contrib/yolov6.py b/python/fastdeploy/vision/detection/contrib/yolov6.py index 0ab7ca033..73ab26d94 100644 --- a/python/fastdeploy/vision/detection/contrib/yolov6.py +++ b/python/fastdeploy/vision/detection/contrib/yolov6.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class YOLOv6(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv6, self).__init__(runtime_option) @@ -92,21 +92,19 @@ class YOLOv6(FastDeployModel): @is_mini_pad.setter def is_mini_pad(self, value): assert isinstance( - value, - bool), "The value to set `is_mini_pad` must be type of bool." + value, bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, - bool), "The value to set `is_scale_up` must be type of bool." + value, bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance( - value, int), "The value to set `stride` must be type of int." + assert isinstance(value, + int), "The value to set `stride` must be type of int." self._model.stride = value @max_wh.setter diff --git a/python/fastdeploy/vision/detection/contrib/yolov7.py b/python/fastdeploy/vision/detection/contrib/yolov7.py index a9deb38d3..f255548d9 100644 --- a/python/fastdeploy/vision/detection/contrib/yolov7.py +++ b/python/fastdeploy/vision/detection/contrib/yolov7.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class YOLOv7(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv7, self).__init__(runtime_option) @@ -92,21 +92,19 @@ class YOLOv7(FastDeployModel): @is_mini_pad.setter def is_mini_pad(self, value): assert isinstance( - value, - bool), "The value to set `is_mini_pad` must be type of bool." + value, bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, - bool), "The value to set `is_scale_up` must be type of bool." + value, bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance( - value, int), "The value to set `stride` must be type of int." + assert isinstance(value, + int), "The value to set `stride` must be type of int." self._model.stride = value @max_wh.setter diff --git a/python/fastdeploy/vision/detection/contrib/yolov7end2end_ort.py b/python/fastdeploy/vision/detection/contrib/yolov7end2end_ort.py index e937d368d..41b79f786 100644 --- a/python/fastdeploy/vision/detection/contrib/yolov7end2end_ort.py +++ b/python/fastdeploy/vision/detection/contrib/yolov7end2end_ort.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class YOLOv7End2EndORT(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv7End2EndORT, self).__init__(runtime_option) @@ -87,19 +87,17 @@ class YOLOv7End2EndORT(FastDeployModel): @is_mini_pad.setter def is_mini_pad(self, value): assert isinstance( - value, - bool), "The value to set `is_mini_pad` must be type of bool." + value, bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, - bool), "The value to set `is_scale_up` must be type of bool." + value, bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance( - value, int), "The value to set `stride` must be type of int." + assert isinstance(value, + int), "The value to set `stride` must be type of int." self._model.stride = value diff --git a/python/fastdeploy/vision/detection/contrib/yolov7end2end_trt.py b/python/fastdeploy/vision/detection/contrib/yolov7end2end_trt.py index 7bfa5f9b3..ea596020b 100644 --- a/python/fastdeploy/vision/detection/contrib/yolov7end2end_trt.py +++ b/python/fastdeploy/vision/detection/contrib/yolov7end2end_trt.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class YOLOv7End2EndTRT(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv7End2EndTRT, self).__init__(runtime_option) @@ -87,19 +87,17 @@ class YOLOv7End2EndTRT(FastDeployModel): @is_mini_pad.setter def is_mini_pad(self, value): assert isinstance( - value, - bool), "The value to set `is_mini_pad` must be type of bool." + value, bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, - bool), "The value to set `is_scale_up` must be type of bool." + value, bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance( - value, int), "The value to set `stride` must be type of int." + assert isinstance(value, + int), "The value to set `stride` must be type of int." self._model.stride = value diff --git a/python/fastdeploy/vision/detection/contrib/yolox.py b/python/fastdeploy/vision/detection/contrib/yolox.py index edd07d517..e7f0da1aa 100644 --- a/python/fastdeploy/vision/detection/contrib/yolox.py +++ b/python/fastdeploy/vision/detection/contrib/yolox.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class YOLOX(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOX, self).__init__(runtime_option) diff --git a/python/fastdeploy/vision/detection/ppdet/__init__.py b/python/fastdeploy/vision/detection/ppdet/__init__.py index bc06f56a9..cbade4336 100644 --- a/python/fastdeploy/vision/detection/ppdet/__init__.py +++ b/python/fastdeploy/vision/detection/ppdet/__init__.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -24,10 +24,10 @@ class PPYOLOE(FastDeployModel): params_file, config_file, runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): super(PPYOLOE, self).__init__(runtime_option) - assert model_format == Frontend.PADDLE, "PPYOLOE model only support model format of Frontend.Paddle now." + assert model_format == ModelFormat.PADDLE, "PPYOLOE model only support model format of ModelFormat.Paddle now." self._model = C.vision.detection.PPYOLOE( model_file, params_file, config_file, self._runtime_option, model_format) @@ -44,10 +44,10 @@ class PPYOLO(PPYOLOE): params_file, config_file, runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): super(PPYOLOE, self).__init__(runtime_option) - assert model_format == Frontend.PADDLE, "PPYOLO model only support model format of Frontend.Paddle now." + assert model_format == ModelFormat.PADDLE, "PPYOLO model only support model format of ModelFormat.Paddle now." self._model = C.vision.detection.PPYOLO( model_file, params_file, config_file, self._runtime_option, model_format) @@ -60,10 +60,10 @@ class PPYOLOv2(PPYOLOE): params_file, config_file, runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): super(PPYOLOE, self).__init__(runtime_option) - assert model_format == Frontend.PADDLE, "PPYOLOv2 model only support model format of Frontend.Paddle now." + assert model_format == ModelFormat.PADDLE, "PPYOLOv2 model only support model format of ModelFormat.Paddle now." self._model = C.vision.detection.PPYOLOv2( model_file, params_file, config_file, self._runtime_option, model_format) @@ -76,10 +76,10 @@ class PaddleYOLOX(PPYOLOE): params_file, config_file, runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): super(PPYOLOE, self).__init__(runtime_option) - assert model_format == Frontend.PADDLE, "PaddleYOLOX model only support model format of Frontend.Paddle now." + assert model_format == ModelFormat.PADDLE, "PaddleYOLOX model only support model format of ModelFormat.Paddle now." self._model = C.vision.detection.PaddleYOLOX( model_file, params_file, config_file, self._runtime_option, model_format) @@ -92,10 +92,10 @@ class PicoDet(PPYOLOE): params_file, config_file, runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): super(PPYOLOE, self).__init__(runtime_option) - assert model_format == Frontend.PADDLE, "PicoDet model only support model format of Frontend.Paddle now." + assert model_format == ModelFormat.PADDLE, "PicoDet model only support model format of ModelFormat.Paddle now." self._model = C.vision.detection.PicoDet( model_file, params_file, config_file, self._runtime_option, model_format) @@ -108,10 +108,10 @@ class FasterRCNN(PPYOLOE): params_file, config_file, runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): super(PPYOLOE, self).__init__(runtime_option) - assert model_format == Frontend.PADDLE, "FasterRCNN model only support model format of Frontend.Paddle now." + assert model_format == ModelFormat.PADDLE, "FasterRCNN model only support model format of ModelFormat.Paddle now." self._model = C.vision.detection.FasterRCNN( model_file, params_file, config_file, self._runtime_option, model_format) @@ -124,10 +124,10 @@ class YOLOv3(PPYOLOE): params_file, config_file, runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): super(PPYOLOE, self).__init__(runtime_option) - assert model_format == Frontend.PADDLE, "YOLOv3 model only support model format of Frontend.Paddle now." + assert model_format == ModelFormat.PADDLE, "YOLOv3 model only support model format of ModelFormat.Paddle now." self._model = C.vision.detection.YOLOv3( model_file, params_file, config_file, self._runtime_option, model_format) @@ -140,10 +140,10 @@ class MaskRCNN(FastDeployModel): params_file, config_file, runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): super(MaskRCNN, self).__init__(runtime_option) - assert model_format == Frontend.PADDLE, "MaskRCNN model only support model format of Frontend.Paddle now." + assert model_format == ModelFormat.PADDLE, "MaskRCNN model only support model format of ModelFormat.Paddle now." self._model = C.vision.detection.MaskRCNN( model_file, params_file, config_file, self._runtime_option, model_format) diff --git a/python/fastdeploy/vision/facedet/contrib/retinaface.py b/python/fastdeploy/vision/facedet/contrib/retinaface.py index 6f7c7e3ad..88eb3ccb3 100644 --- a/python/fastdeploy/vision/facedet/contrib/retinaface.py +++ b/python/fastdeploy/vision/facedet/contrib/retinaface.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class RetinaFace(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(RetinaFace, self).__init__(runtime_option) diff --git a/python/fastdeploy/vision/facedet/contrib/scrfd.py b/python/fastdeploy/vision/facedet/contrib/scrfd.py index 0cad0c42b..bdf4ea08e 100644 --- a/python/fastdeploy/vision/facedet/contrib/scrfd.py +++ b/python/fastdeploy/vision/facedet/contrib/scrfd.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,13 +23,13 @@ class SCRFD(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(SCRFD, self).__init__(runtime_option) - self._model = C.vision.facedet.SCRFD( - model_file, params_file, self._runtime_option, model_format) + self._model = C.vision.facedet.SCRFD(model_file, params_file, + self._runtime_option, model_format) # 通过self.initialized判断整个模型的初始化是否成功 assert self.initialized, "SCRFD initialize failed." @@ -108,21 +108,19 @@ class SCRFD(FastDeployModel): @is_mini_pad.setter def is_mini_pad(self, value): assert isinstance( - value, - bool), "The value to set `is_mini_pad` must be type of bool." + value, bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, - bool), "The value to set `is_scale_up` must be type of bool." + value, bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance( - value, int), "The value to set `stride` must be type of int." + assert isinstance(value, + int), "The value to set `stride` must be type of int." self._model.stride = value @downsample_strides.setter diff --git a/python/fastdeploy/vision/facedet/contrib/ultraface.py b/python/fastdeploy/vision/facedet/contrib/ultraface.py index 9b19af574..3228833db 100644 --- a/python/fastdeploy/vision/facedet/contrib/ultraface.py +++ b/python/fastdeploy/vision/facedet/contrib/ultraface.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class UltraFace(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(UltraFace, self).__init__(runtime_option) diff --git a/python/fastdeploy/vision/facedet/contrib/yolov5face.py b/python/fastdeploy/vision/facedet/contrib/yolov5face.py index 0a8d2511b..7fd294b3a 100644 --- a/python/fastdeploy/vision/facedet/contrib/yolov5face.py +++ b/python/fastdeploy/vision/facedet/contrib/yolov5face.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class YOLOv5Face(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv5Face, self).__init__(runtime_option) @@ -92,21 +92,19 @@ class YOLOv5Face(FastDeployModel): @is_mini_pad.setter def is_mini_pad(self, value): assert isinstance( - value, - bool), "The value to set `is_mini_pad` must be type of bool." + value, bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, - bool), "The value to set `is_scale_up` must be type of bool." + value, bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance( - value, int), "The value to set `stride` must be type of int." + assert isinstance(value, + int), "The value to set `stride` must be type of int." self._model.stride = value @landmarks_per_face.setter diff --git a/python/fastdeploy/vision/faceid/contrib/arcface.py b/python/fastdeploy/vision/faceid/contrib/arcface.py index 7b1160ede..2e4785fa9 100644 --- a/python/fastdeploy/vision/faceid/contrib/arcface.py +++ b/python/fastdeploy/vision/faceid/contrib/arcface.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C from ..contrib.insightface_rec import InsightFaceRecognitionModel @@ -24,7 +24,7 @@ class ArcFace(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(ArcFace, self).__init__(runtime_option) diff --git a/python/fastdeploy/vision/faceid/contrib/cosface.py b/python/fastdeploy/vision/faceid/contrib/cosface.py index a6029b38b..f7b620227 100644 --- a/python/fastdeploy/vision/faceid/contrib/cosface.py +++ b/python/fastdeploy/vision/faceid/contrib/cosface.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class CosFace(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(CosFace, self).__init__(runtime_option) diff --git a/python/fastdeploy/vision/faceid/contrib/insightface_rec.py b/python/fastdeploy/vision/faceid/contrib/insightface_rec.py index dcbe7341e..df23fd6cd 100644 --- a/python/fastdeploy/vision/faceid/contrib/insightface_rec.py +++ b/python/fastdeploy/vision/faceid/contrib/insightface_rec.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class InsightFaceRecognitionModel(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(InsightFaceRecognitionModel, self).__init__(runtime_option) diff --git a/python/fastdeploy/vision/faceid/contrib/partial_fc.py b/python/fastdeploy/vision/faceid/contrib/partial_fc.py index f19457b94..dcc57d2e8 100644 --- a/python/fastdeploy/vision/faceid/contrib/partial_fc.py +++ b/python/fastdeploy/vision/faceid/contrib/partial_fc.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class PartialFC(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(PartialFC, self).__init__(runtime_option) diff --git a/python/fastdeploy/vision/faceid/contrib/vpl.py b/python/fastdeploy/vision/faceid/contrib/vpl.py index 67fff74ba..3d77abbce 100644 --- a/python/fastdeploy/vision/faceid/contrib/vpl.py +++ b/python/fastdeploy/vision/faceid/contrib/vpl.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class VPL(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(VPL, self).__init__(runtime_option) diff --git a/python/fastdeploy/vision/matting/contrib/modnet.py b/python/fastdeploy/vision/matting/contrib/modnet.py index 82ee542a1..17bfb76f8 100644 --- a/python/fastdeploy/vision/matting/contrib/modnet.py +++ b/python/fastdeploy/vision/matting/contrib/modnet.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class MODNet(FastDeployModel): model_file, params_file="", runtime_option=None, - model_format=Frontend.ONNX): + model_format=ModelFormat.ONNX): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(MODNet, self).__init__(runtime_option) diff --git a/python/fastdeploy/vision/matting/ppmatting/__init__.py b/python/fastdeploy/vision/matting/ppmatting/__init__.py index 50e221589..450ac4aa7 100644 --- a/python/fastdeploy/vision/matting/ppmatting/__init__.py +++ b/python/fastdeploy/vision/matting/ppmatting/__init__.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -24,10 +24,10 @@ class PPMatting(FastDeployModel): params_file, config_file, runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): super(PPMatting, self).__init__(runtime_option) - assert model_format == Frontend.PADDLE, "PPMatting model only support model format of Frontend.Paddle now." + assert model_format == ModelFormat.PADDLE, "PPMatting model only support model format of ModelFormat.Paddle now." self._model = C.vision.matting.PPMatting( model_file, params_file, config_file, self._runtime_option, model_format) diff --git a/python/fastdeploy/vision/ocr/ppocr/__init__.py b/python/fastdeploy/vision/ocr/ppocr/__init__.py index 0e9de7e73..53888ba04 100644 --- a/python/fastdeploy/vision/ocr/ppocr/__init__.py +++ b/python/fastdeploy/vision/ocr/ppocr/__init__.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -23,7 +23,7 @@ class DBDetector(FastDeployModel): model_file="", params_file="", runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(DBDetector, self).__init__(runtime_option) @@ -81,8 +81,8 @@ class DBDetector(FastDeployModel): @det_db_box_thresh.setter def det_db_box_thresh(self, value): assert isinstance( - value, float - ), "The value to set `det_db_box_thresh` must be type of float." + value, + float), "The value to set `det_db_box_thresh` must be type of float." self._model.det_db_box_thresh = value @det_db_unclip_ratio.setter @@ -118,7 +118,7 @@ class Classifier(FastDeployModel): model_file="", params_file="", runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(Classifier, self).__init__(runtime_option) @@ -159,8 +159,7 @@ class Classifier(FastDeployModel): @cls_batch_num.setter def cls_batch_num(self, value): assert isinstance( - value, - int), "The value to set `cls_batch_num` must be type of int." + value, int), "The value to set `cls_batch_num` must be type of int." self._model.cls_batch_num = value @@ -170,7 +169,7 @@ class Recognizer(FastDeployModel): params_file="", label_path="", runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(Recognizer, self).__init__(runtime_option) @@ -211,18 +210,19 @@ class Recognizer(FastDeployModel): @rec_batch_num.setter def rec_batch_num(self, value): assert isinstance( - value, - int), "The value to set `rec_batch_num` must be type of int." + value, int), "The value to set `rec_batch_num` must be type of int." self._model.rec_batch_num = value class PPOCRSystemv3(FastDeployModel): def __init__(self, det_model=None, cls_model=None, rec_model=None): - assert det_model is not None and rec_model is not None, "The det_model and rec_model cannot be None." + assert det_model is not None and rec_model is not None, "The det_model and rec_model cannot be None." if cls_model is None: - self.system = C.vision.ocr.PPOCRSystemv3(det_model._model, rec_model._model) + self.system = C.vision.ocr.PPOCRSystemv3(det_model._model, + rec_model._model) else: - self.system = C.vision.ocr.PPOCRSystemv3(det_model._model, cls_model._model, rec_model._model) + self.system = C.vision.ocr.PPOCRSystemv3( + det_model._model, cls_model._model, rec_model._model) def predict(self, input_image): return self.system.predict(input_image) @@ -230,11 +230,13 @@ class PPOCRSystemv3(FastDeployModel): class PPOCRSystemv2(FastDeployModel): def __init__(self, det_model=None, cls_model=None, rec_model=None): - assert det_model is not None and rec_model is not None, "The det_model and rec_model cannot be None." + assert det_model is not None and rec_model is not None, "The det_model and rec_model cannot be None." if cls_model is None: - self.system = C.vision.ocr.PPOCRSystemv2(det_model._model, rec_model._model) + self.system = C.vision.ocr.PPOCRSystemv2(det_model._model, + rec_model._model) else: - self.system = C.vision.ocr.PPOCRSystemv2(det_model._model, cls_model._model, rec_model._model) + self.system = C.vision.ocr.PPOCRSystemv2( + det_model._model, cls_model._model, rec_model._model) def predict(self, input_image): return self.system.predict(input_image) diff --git a/python/fastdeploy/vision/segmentation/ppseg/__init__.py b/python/fastdeploy/vision/segmentation/ppseg/__init__.py index bc516351d..a7c15f50b 100644 --- a/python/fastdeploy/vision/segmentation/ppseg/__init__.py +++ b/python/fastdeploy/vision/segmentation/ppseg/__init__.py @@ -14,7 +14,7 @@ from __future__ import absolute_import import logging -from .... import FastDeployModel, Frontend +from .... import FastDeployModel, ModelFormat from .... import c_lib_wrap as C @@ -24,10 +24,10 @@ class PaddleSegModel(FastDeployModel): params_file, config_file, runtime_option=None, - model_format=Frontend.PADDLE): + model_format=ModelFormat.PADDLE): super(PaddleSegModel, self).__init__(runtime_option) - assert model_format == Frontend.PADDLE, "PaddleSeg only support model format of Frontend.Paddle now." + assert model_format == ModelFormat.PADDLE, "PaddleSeg only support model format of ModelFormat.Paddle now." self._model = C.vision.segmentation.PaddleSegModel( model_file, params_file, config_file, self._runtime_option, model_format)