mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 09:07:10 +08:00
[Other] Add detection, segmentation and OCR examples for Ascend deploy. (#983)
* Add Huawei Ascend NPU deploy through PaddleLite CANN * Add NNAdapter interface for paddlelite * Modify Huawei Ascend Cmake * Update way for compiling Huawei Ascend NPU deployment * remove UseLiteBackend in UseCANN * Support compile python whlee * Change names of nnadapter API * Add nnadapter pybind and remove useless API * Support Python deployment on Huawei Ascend NPU * Add models suppor for ascend * Add PPOCR rec reszie for ascend * fix conflict for ascend * Rename CANN to Ascend * Rename CANN to Ascend * Improve ascend * fix ascend bug * improve ascend docs * improve ascend docs * improve ascend docs * Improve Ascend * Improve Ascend * Move ascend python demo * Imporve ascend * Improve ascend * Improve ascend * Improve ascend * Improve ascend * Imporve ascend * Imporve ascend * Improve ascend * acc eval script * acc eval * remove acc_eval from branch huawei * Add detection and segmentation examples for Ascend deployment * Add detection and segmentation examples for Ascend deployment * Add PPOCR example for ascend deploy * Imporve paddle lite compiliation * Add FlyCV doc * Add FlyCV doc * Add FlyCV doc * Imporve Ascend docs * Imporve Ascend docs
This commit is contained in:
@@ -24,10 +24,10 @@ void BindPPOCRModel(pybind11::module& m) {
|
||||
// DBDetector
|
||||
pybind11::class_<vision::ocr::DBDetectorPreprocessor>(m, "DBDetectorPreprocessor")
|
||||
.def(pybind11::init<>())
|
||||
.def_readwrite("max_side_len", &vision::ocr::DBDetectorPreprocessor::max_side_len_)
|
||||
.def_readwrite("mean", &vision::ocr::DBDetectorPreprocessor::mean_)
|
||||
.def_readwrite("scale", &vision::ocr::DBDetectorPreprocessor::scale_)
|
||||
.def_readwrite("is_scale", &vision::ocr::DBDetectorPreprocessor::is_scale_)
|
||||
.def_property("max_side_len", &vision::ocr::DBDetectorPreprocessor::GetMaxSideLen, &vision::ocr::DBDetectorPreprocessor::SetMaxSideLen)
|
||||
.def_property("mean", &vision::ocr::DBDetectorPreprocessor::GetMean, &vision::ocr::DBDetectorPreprocessor::SetMean)
|
||||
.def_property("scale", &vision::ocr::DBDetectorPreprocessor::GetScale, &vision::ocr::DBDetectorPreprocessor::SetScale)
|
||||
.def_property("is_scale", &vision::ocr::DBDetectorPreprocessor::GetIsScale, &vision::ocr::DBDetectorPreprocessor::SetIsScale)
|
||||
.def("run", [](vision::ocr::DBDetectorPreprocessor& self, std::vector<pybind11::array>& im_list) {
|
||||
std::vector<vision::FDMat> images;
|
||||
for (size_t i = 0; i < im_list.size(); ++i) {
|
||||
@@ -44,11 +44,12 @@ void BindPPOCRModel(pybind11::module& m) {
|
||||
|
||||
pybind11::class_<vision::ocr::DBDetectorPostprocessor>(m, "DBDetectorPostprocessor")
|
||||
.def(pybind11::init<>())
|
||||
.def_readwrite("det_db_thresh", &vision::ocr::DBDetectorPostprocessor::det_db_thresh_)
|
||||
.def_readwrite("det_db_box_thresh", &vision::ocr::DBDetectorPostprocessor::det_db_box_thresh_)
|
||||
.def_readwrite("det_db_unclip_ratio", &vision::ocr::DBDetectorPostprocessor::det_db_unclip_ratio_)
|
||||
.def_readwrite("det_db_score_mode", &vision::ocr::DBDetectorPostprocessor::det_db_score_mode_)
|
||||
.def_readwrite("use_dilation", &vision::ocr::DBDetectorPostprocessor::use_dilation_)
|
||||
.def_property("det_db_thresh", &vision::ocr::DBDetectorPostprocessor::GetDetDBThresh, &vision::ocr::DBDetectorPostprocessor::SetDetDBThresh)
|
||||
.def_property("det_db_box_thresh", &vision::ocr::DBDetectorPostprocessor::GetDetDBBoxThresh, &vision::ocr::DBDetectorPostprocessor::SetDetDBBoxThresh)
|
||||
.def_property("det_db_unclip_ratio", &vision::ocr::DBDetectorPostprocessor::GetDetDBUnclipRatio, &vision::ocr::DBDetectorPostprocessor::SetDetDBUnclipRatio)
|
||||
.def_property("det_db_score_mode", &vision::ocr::DBDetectorPostprocessor::GetDetDBScoreMode, &vision::ocr::DBDetectorPostprocessor::SetDetDBScoreMode)
|
||||
.def_property("use_dilation", &vision::ocr::DBDetectorPostprocessor::GetUseDilation, &vision::ocr::DBDetectorPostprocessor::SetUseDilation)
|
||||
|
||||
.def("run", [](vision::ocr::DBDetectorPostprocessor& self,
|
||||
std::vector<FDTensor>& inputs,
|
||||
const std::vector<std::array<int, 4>>& batch_det_img_info) {
|
||||
@@ -75,8 +76,8 @@ void BindPPOCRModel(pybind11::module& m) {
|
||||
.def(pybind11::init<std::string, std::string, RuntimeOption,
|
||||
ModelFormat>())
|
||||
.def(pybind11::init<>())
|
||||
.def_readwrite("preprocessor", &vision::ocr::DBDetector::preprocessor_)
|
||||
.def_readwrite("postprocessor", &vision::ocr::DBDetector::postprocessor_)
|
||||
.def_property_readonly("preprocessor", &vision::ocr::DBDetector::GetPreprocessor)
|
||||
.def_property_readonly("postprocessor", &vision::ocr::DBDetector::GetPostprocessor)
|
||||
.def("predict", [](vision::ocr::DBDetector& self,
|
||||
pybind11::array& data) {
|
||||
auto mat = PyArrayToCvMat(data);
|
||||
@@ -97,10 +98,10 @@ void BindPPOCRModel(pybind11::module& m) {
|
||||
// Classifier
|
||||
pybind11::class_<vision::ocr::ClassifierPreprocessor>(m, "ClassifierPreprocessor")
|
||||
.def(pybind11::init<>())
|
||||
.def_readwrite("cls_image_shape", &vision::ocr::ClassifierPreprocessor::cls_image_shape_)
|
||||
.def_readwrite("mean", &vision::ocr::ClassifierPreprocessor::mean_)
|
||||
.def_readwrite("scale", &vision::ocr::ClassifierPreprocessor::scale_)
|
||||
.def_readwrite("is_scale", &vision::ocr::ClassifierPreprocessor::is_scale_)
|
||||
.def_property("cls_image_shape", &vision::ocr::ClassifierPreprocessor::GetClsImageShape, &vision::ocr::ClassifierPreprocessor::SetClsImageShape)
|
||||
.def_property("mean", &vision::ocr::ClassifierPreprocessor::GetMean, &vision::ocr::ClassifierPreprocessor::SetMean)
|
||||
.def_property("scale", &vision::ocr::ClassifierPreprocessor::GetScale, &vision::ocr::ClassifierPreprocessor::SetScale)
|
||||
.def_property("is_scale", &vision::ocr::ClassifierPreprocessor::GetIsScale, &vision::ocr::ClassifierPreprocessor::SetIsScale)
|
||||
.def("run", [](vision::ocr::ClassifierPreprocessor& self, std::vector<pybind11::array>& im_list) {
|
||||
std::vector<vision::FDMat> images;
|
||||
for (size_t i = 0; i < im_list.size(); ++i) {
|
||||
@@ -118,7 +119,7 @@ void BindPPOCRModel(pybind11::module& m) {
|
||||
|
||||
pybind11::class_<vision::ocr::ClassifierPostprocessor>(m, "ClassifierPostprocessor")
|
||||
.def(pybind11::init<>())
|
||||
.def_readwrite("cls_thresh", &vision::ocr::ClassifierPostprocessor::cls_thresh_)
|
||||
.def_property("cls_thresh", &vision::ocr::ClassifierPostprocessor::GetClsThresh, &vision::ocr::ClassifierPostprocessor::SetClsThresh)
|
||||
.def("run", [](vision::ocr::ClassifierPostprocessor& self,
|
||||
std::vector<FDTensor>& inputs) {
|
||||
std::vector<int> cls_labels;
|
||||
@@ -144,8 +145,8 @@ void BindPPOCRModel(pybind11::module& m) {
|
||||
.def(pybind11::init<std::string, std::string, RuntimeOption,
|
||||
ModelFormat>())
|
||||
.def(pybind11::init<>())
|
||||
.def_readwrite("preprocessor", &vision::ocr::Classifier::preprocessor_)
|
||||
.def_readwrite("postprocessor", &vision::ocr::Classifier::postprocessor_)
|
||||
.def_property_readonly("preprocessor", &vision::ocr::Classifier::GetPreprocessor)
|
||||
.def_property_readonly("postprocessor", &vision::ocr::Classifier::GetPostprocessor)
|
||||
.def("predict", [](vision::ocr::Classifier& self,
|
||||
pybind11::array& data) {
|
||||
auto mat = PyArrayToCvMat(data);
|
||||
@@ -168,11 +169,11 @@ void BindPPOCRModel(pybind11::module& m) {
|
||||
// Recognizer
|
||||
pybind11::class_<vision::ocr::RecognizerPreprocessor>(m, "RecognizerPreprocessor")
|
||||
.def(pybind11::init<>())
|
||||
.def_readwrite("rec_image_shape", &vision::ocr::RecognizerPreprocessor::rec_image_shape_)
|
||||
.def_readwrite("mean", &vision::ocr::RecognizerPreprocessor::mean_)
|
||||
.def_readwrite("scale", &vision::ocr::RecognizerPreprocessor::scale_)
|
||||
.def_readwrite("is_scale", &vision::ocr::RecognizerPreprocessor::is_scale_)
|
||||
.def_readwrite("static_shape", &vision::ocr::RecognizerPreprocessor::static_shape_)
|
||||
.def_property("static_shape_infer", &vision::ocr::RecognizerPreprocessor::GetStaticShapeInfer, &vision::ocr::RecognizerPreprocessor::SetStaticShapeInfer)
|
||||
.def_property("rec_image_shape", &vision::ocr::RecognizerPreprocessor::GetRecImageShape, &vision::ocr::RecognizerPreprocessor::SetRecImageShape)
|
||||
.def_property("mean", &vision::ocr::RecognizerPreprocessor::GetMean, &vision::ocr::RecognizerPreprocessor::SetMean)
|
||||
.def_property("scale", &vision::ocr::RecognizerPreprocessor::GetScale, &vision::ocr::RecognizerPreprocessor::SetScale)
|
||||
.def_property("is_scale", &vision::ocr::RecognizerPreprocessor::GetIsScale, &vision::ocr::RecognizerPreprocessor::SetIsScale)
|
||||
.def("run", [](vision::ocr::RecognizerPreprocessor& self, std::vector<pybind11::array>& im_list) {
|
||||
std::vector<vision::FDMat> images;
|
||||
for (size_t i = 0; i < im_list.size(); ++i) {
|
||||
@@ -215,8 +216,8 @@ void BindPPOCRModel(pybind11::module& m) {
|
||||
.def(pybind11::init<std::string, std::string, std::string, RuntimeOption,
|
||||
ModelFormat>())
|
||||
.def(pybind11::init<>())
|
||||
.def_readwrite("preprocessor", &vision::ocr::Recognizer::preprocessor_)
|
||||
.def_readwrite("postprocessor", &vision::ocr::Recognizer::postprocessor_)
|
||||
.def_property_readonly("preprocessor", &vision::ocr::Recognizer::GetPreprocessor)
|
||||
.def_property_readonly("postprocessor", &vision::ocr::Recognizer::GetPostprocessor)
|
||||
.def("predict", [](vision::ocr::Recognizer& self,
|
||||
pybind11::array& data) {
|
||||
auto mat = PyArrayToCvMat(data);
|
||||
|
Reference in New Issue
Block a user