mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 17:17:14 +08:00
Modify YOLOv7 Infer file and the external model namespace (#87)
* first commit for yolov7 * pybind for yolov7 * CPP README.md * CPP README.md * modified yolov7.cc * README.md * python file modify * delete license in fastdeploy/ * repush the conflict part * README.md modified * README.md modified * file path modified * file path modified * file path modified * file path modified * file path modified * README modified * README modified * move some helpers to private * add examples for yolov7 * api.md modified * api.md modified * api.md modified * YOLOv7 * yolov7 release link * yolov7 release link * yolov7 release link * copyright * change some helpers to private * change variables to const and fix documents. * gitignore * Transfer some funtions to private member of class * Transfer some funtions to private member of class * Merge from develop (#9) * Fix compile problem in different python version (#26) * fix some usage problem in linux * Fix compile problem Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> * Add PaddleDetetion/PPYOLOE model support (#22) * add ppdet/ppyoloe * Add demo code and documents * add convert processor to vision (#27) * update .gitignore * Added checking for cmake include dir * fixed missing trt_backend option bug when init from trt * remove un-need data layout and add pre-check for dtype * changed RGB2BRG to BGR2RGB in ppcls model * add model_zoo yolov6 c++/python demo * fixed CMakeLists.txt typos * update yolov6 cpp/README.md * add yolox c++/pybind and model_zoo demo * move some helpers to private * fixed CMakeLists.txt typos * add normalize with alpha and beta * add version notes for yolov5/yolov6/yolox * add copyright to yolov5.cc * revert normalize * fixed some bugs in yolox * fixed examples/CMakeLists.txt to avoid conflicts * add convert processor to vision * format examples/CMakeLists summary * Fix bug while the inference result is empty with YOLOv5 (#29) * Add multi-label function for yolov5 * Update README.md Update doc * Update fastdeploy_runtime.cc fix variable option.trt_max_shape wrong name * Update runtime_option.md Update resnet model dynamic shape setting name from images to x * Fix bug when inference result boxes are empty * Delete detection.py Co-authored-by: Jason <jiangjiajun@baidu.com> Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com> Co-authored-by: huangjianhui <852142024@qq.com> * first commit for yolor * for merge * Develop (#11) * Fix compile problem in different python version (#26) * fix some usage problem in linux * Fix compile problem Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> * Add PaddleDetetion/PPYOLOE model support (#22) * add ppdet/ppyoloe * Add demo code and documents * add convert processor to vision (#27) * update .gitignore * Added checking for cmake include dir * fixed missing trt_backend option bug when init from trt * remove un-need data layout and add pre-check for dtype * changed RGB2BRG to BGR2RGB in ppcls model * add model_zoo yolov6 c++/python demo * fixed CMakeLists.txt typos * update yolov6 cpp/README.md * add yolox c++/pybind and model_zoo demo * move some helpers to private * fixed CMakeLists.txt typos * add normalize with alpha and beta * add version notes for yolov5/yolov6/yolox * add copyright to yolov5.cc * revert normalize * fixed some bugs in yolox * fixed examples/CMakeLists.txt to avoid conflicts * add convert processor to vision * format examples/CMakeLists summary * Fix bug while the inference result is empty with YOLOv5 (#29) * Add multi-label function for yolov5 * Update README.md Update doc * Update fastdeploy_runtime.cc fix variable option.trt_max_shape wrong name * Update runtime_option.md Update resnet model dynamic shape setting name from images to x * Fix bug when inference result boxes are empty * Delete detection.py Co-authored-by: Jason <jiangjiajun@baidu.com> Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com> Co-authored-by: huangjianhui <852142024@qq.com> * Yolor (#16) * Develop (#11) (#12) * Fix compile problem in different python version (#26) * fix some usage problem in linux * Fix compile problem Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> * Add PaddleDetetion/PPYOLOE model support (#22) * add ppdet/ppyoloe * Add demo code and documents * add convert processor to vision (#27) * update .gitignore * Added checking for cmake include dir * fixed missing trt_backend option bug when init from trt * remove un-need data layout and add pre-check for dtype * changed RGB2BRG to BGR2RGB in ppcls model * add model_zoo yolov6 c++/python demo * fixed CMakeLists.txt typos * update yolov6 cpp/README.md * add yolox c++/pybind and model_zoo demo * move some helpers to private * fixed CMakeLists.txt typos * add normalize with alpha and beta * add version notes for yolov5/yolov6/yolox * add copyright to yolov5.cc * revert normalize * fixed some bugs in yolox * fixed examples/CMakeLists.txt to avoid conflicts * add convert processor to vision * format examples/CMakeLists summary * Fix bug while the inference result is empty with YOLOv5 (#29) * Add multi-label function for yolov5 * Update README.md Update doc * Update fastdeploy_runtime.cc fix variable option.trt_max_shape wrong name * Update runtime_option.md Update resnet model dynamic shape setting name from images to x * Fix bug when inference result boxes are empty * Delete detection.py Co-authored-by: Jason <jiangjiajun@baidu.com> Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com> Co-authored-by: huangjianhui <852142024@qq.com> Co-authored-by: Jason <jiangjiajun@baidu.com> Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com> Co-authored-by: huangjianhui <852142024@qq.com> * Develop (#13) * Fix compile problem in different python version (#26) * fix some usage problem in linux * Fix compile problem Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> * Add PaddleDetetion/PPYOLOE model support (#22) * add ppdet/ppyoloe * Add demo code and documents * add convert processor to vision (#27) * update .gitignore * Added checking for cmake include dir * fixed missing trt_backend option bug when init from trt * remove un-need data layout and add pre-check for dtype * changed RGB2BRG to BGR2RGB in ppcls model * add model_zoo yolov6 c++/python demo * fixed CMakeLists.txt typos * update yolov6 cpp/README.md * add yolox c++/pybind and model_zoo demo * move some helpers to private * fixed CMakeLists.txt typos * add normalize with alpha and beta * add version notes for yolov5/yolov6/yolox * add copyright to yolov5.cc * revert normalize * fixed some bugs in yolox * fixed examples/CMakeLists.txt to avoid conflicts * add convert processor to vision * format examples/CMakeLists summary * Fix bug while the inference result is empty with YOLOv5 (#29) * Add multi-label function for yolov5 * Update README.md Update doc * Update fastdeploy_runtime.cc fix variable option.trt_max_shape wrong name * Update runtime_option.md Update resnet model dynamic shape setting name from images to x * Fix bug when inference result boxes are empty * Delete detection.py Co-authored-by: Jason <jiangjiajun@baidu.com> Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com> Co-authored-by: huangjianhui <852142024@qq.com> * documents * documents * documents * documents * documents * documents * documents * documents * documents * documents * documents * documents * Develop (#14) * Fix compile problem in different python version (#26) * fix some usage problem in linux * Fix compile problem Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> * Add PaddleDetetion/PPYOLOE model support (#22) * add ppdet/ppyoloe * Add demo code and documents * add convert processor to vision (#27) * update .gitignore * Added checking for cmake include dir * fixed missing trt_backend option bug when init from trt * remove un-need data layout and add pre-check for dtype * changed RGB2BRG to BGR2RGB in ppcls model * add model_zoo yolov6 c++/python demo * fixed CMakeLists.txt typos * update yolov6 cpp/README.md * add yolox c++/pybind and model_zoo demo * move some helpers to private * fixed CMakeLists.txt typos * add normalize with alpha and beta * add version notes for yolov5/yolov6/yolox * add copyright to yolov5.cc * revert normalize * fixed some bugs in yolox * fixed examples/CMakeLists.txt to avoid conflicts * add convert processor to vision * format examples/CMakeLists summary * Fix bug while the inference result is empty with YOLOv5 (#29) * Add multi-label function for yolov5 * Update README.md Update doc * Update fastdeploy_runtime.cc fix variable option.trt_max_shape wrong name * Update runtime_option.md Update resnet model dynamic shape setting name from images to x * Fix bug when inference result boxes are empty * Delete detection.py Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com> Co-authored-by: huangjianhui <852142024@qq.com> Co-authored-by: Jason <jiangjiajun@baidu.com> Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com> Co-authored-by: huangjianhui <852142024@qq.com> Co-authored-by: Jason <928090362@qq.com> * add is_dynamic for YOLO series (#22) * modify namespace for yolov5lite * modify namespace for external detection models * modify namespace for yolov5lite * modify namespace for face models * py namespace for external model * fix compile error and infer file * change paddleyolox to yolox * delete space in cmakelist * check code specification Co-authored-by: Jason <jiangjiajun@baidu.com> Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com> Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com> Co-authored-by: huangjianhui <852142024@qq.com> Co-authored-by: Jason <928090362@qq.com>
This commit is contained in:
@@ -15,29 +15,27 @@
|
|||||||
|
|
||||||
#include "fastdeploy/core/config.h"
|
#include "fastdeploy/core/config.h"
|
||||||
#ifdef ENABLE_VISION
|
#ifdef ENABLE_VISION
|
||||||
#include "fastdeploy/vision/biubug6/retinaface.h"
|
#include "fastdeploy/vision/detection/contrib/nanodet_plus.h"
|
||||||
#include "fastdeploy/vision/deepcam/yolov5face.h"
|
|
||||||
#include "fastdeploy/vision/deepinsight/arcface.h"
|
|
||||||
#include "fastdeploy/vision/deepinsight/cosface.h"
|
|
||||||
#include "fastdeploy/vision/deepinsight/insightface_rec.h"
|
|
||||||
#include "fastdeploy/vision/deepinsight/partial_fc.h"
|
|
||||||
#include "fastdeploy/vision/deepinsight/scrfd.h"
|
|
||||||
#include "fastdeploy/vision/deepinsight/vpl.h"
|
|
||||||
|
|
||||||
#include "fastdeploy/vision/detection/contrib/scaledyolov4.h"
|
#include "fastdeploy/vision/detection/contrib/scaledyolov4.h"
|
||||||
#include "fastdeploy/vision/detection/contrib/yolor.h"
|
#include "fastdeploy/vision/detection/contrib/yolor.h"
|
||||||
|
#include "fastdeploy/vision/detection/contrib/yolov5.h"
|
||||||
|
#include "fastdeploy/vision/detection/contrib/yolov5lite.h"
|
||||||
|
#include "fastdeploy/vision/detection/contrib/yolov6.h"
|
||||||
#include "fastdeploy/vision/detection/contrib/yolov7.h"
|
#include "fastdeploy/vision/detection/contrib/yolov7.h"
|
||||||
#include "fastdeploy/vision/detection/ppdet/model.h"
|
#include "fastdeploy/vision/detection/contrib/yolox.h"
|
||||||
|
#include "fastdeploy/vision/facedet/contrib/retinaface.h"
|
||||||
#include "fastdeploy/vision/linzaer/ultraface.h"
|
#include "fastdeploy/vision/facedet/contrib/scrfd.h"
|
||||||
#include "fastdeploy/vision/megvii/yolox.h"
|
#include "fastdeploy/vision/facedet/contrib/ultraface.h"
|
||||||
#include "fastdeploy/vision/meituan/yolov6.h"
|
#include "fastdeploy/vision/facedet/contrib/yolov5face.h"
|
||||||
|
#include "fastdeploy/vision/faceid/contrib/arcface.h"
|
||||||
|
#include "fastdeploy/vision/faceid/contrib/cosface.h"
|
||||||
|
#include "fastdeploy/vision/faceid/contrib/insightface_rec.h"
|
||||||
|
#include "fastdeploy/vision/faceid/contrib/partial_fc.h"
|
||||||
|
#include "fastdeploy/vision/faceid/contrib/vpl.h"
|
||||||
|
#include "fastdeploy/vision/matting/contrib/modnet.h"
|
||||||
#include "fastdeploy/vision/ppcls/model.h"
|
#include "fastdeploy/vision/ppcls/model.h"
|
||||||
#include "fastdeploy/vision/ppogg/yolov5lite.h"
|
#include "fastdeploy/vision/detection/ppdet/model.h"
|
||||||
#include "fastdeploy/vision/ppseg/model.h"
|
#include "fastdeploy/vision/ppseg/model.h"
|
||||||
#include "fastdeploy/vision/rangilyu/nanodet_plus.h"
|
|
||||||
#include "fastdeploy/vision/ultralytics/yolov5.h"
|
|
||||||
#include "fastdeploy/vision/zhkkke/modnet.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "fastdeploy/vision/visualize/visualize.h"
|
#include "fastdeploy/vision/visualize/visualize.h"
|
||||||
|
@@ -1,144 +0,0 @@
|
|||||||
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include "fastdeploy/pybind/main.h"
|
|
||||||
|
|
||||||
namespace fastdeploy {
|
|
||||||
void BindDeepInsight(pybind11::module& m) {
|
|
||||||
auto deepinsight_module =
|
|
||||||
m.def_submodule("deepinsight", "https://github.com/deepinsight");
|
|
||||||
// Bind SCRFD
|
|
||||||
pybind11::class_<vision::deepinsight::SCRFD, FastDeployModel>(
|
|
||||||
deepinsight_module, "SCRFD")
|
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
|
||||||
.def("predict",
|
|
||||||
[](vision::deepinsight::SCRFD& self, pybind11::array& data,
|
|
||||||
float conf_threshold, float nms_iou_threshold) {
|
|
||||||
auto mat = PyArrayToCvMat(data);
|
|
||||||
vision::FaceDetectionResult res;
|
|
||||||
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.def_readwrite("size", &vision::deepinsight::SCRFD::size)
|
|
||||||
.def_readwrite("padding_value",
|
|
||||||
&vision::deepinsight::SCRFD::padding_value)
|
|
||||||
.def_readwrite("is_mini_pad", &vision::deepinsight::SCRFD::is_mini_pad)
|
|
||||||
.def_readwrite("is_no_pad", &vision::deepinsight::SCRFD::is_no_pad)
|
|
||||||
.def_readwrite("is_scale_up", &vision::deepinsight::SCRFD::is_scale_up)
|
|
||||||
.def_readwrite("stride", &vision::deepinsight::SCRFD::stride)
|
|
||||||
.def_readwrite("use_kps", &vision::deepinsight::SCRFD::use_kps)
|
|
||||||
.def_readwrite("max_nms", &vision::deepinsight::SCRFD::max_nms)
|
|
||||||
.def_readwrite("downsample_strides",
|
|
||||||
&vision::deepinsight::SCRFD::downsample_strides)
|
|
||||||
.def_readwrite("num_anchors", &vision::deepinsight::SCRFD::num_anchors)
|
|
||||||
.def_readwrite("landmarks_per_face",
|
|
||||||
&vision::deepinsight::SCRFD::landmarks_per_face);
|
|
||||||
// Bind InsightFaceRecognitionModel
|
|
||||||
pybind11::class_<vision::deepinsight::InsightFaceRecognitionModel,
|
|
||||||
FastDeployModel>(deepinsight_module,
|
|
||||||
"InsightFaceRecognitionModel")
|
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
|
||||||
.def("predict",
|
|
||||||
[](vision::deepinsight::InsightFaceRecognitionModel& self,
|
|
||||||
pybind11::array& data) {
|
|
||||||
auto mat = PyArrayToCvMat(data);
|
|
||||||
vision::FaceRecognitionResult res;
|
|
||||||
self.Predict(&mat, &res);
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.def_readwrite("size",
|
|
||||||
&vision::deepinsight::InsightFaceRecognitionModel::size)
|
|
||||||
.def_readwrite("alpha",
|
|
||||||
&vision::deepinsight::InsightFaceRecognitionModel::alpha)
|
|
||||||
.def_readwrite("beta",
|
|
||||||
&vision::deepinsight::InsightFaceRecognitionModel::beta)
|
|
||||||
.def_readwrite("swap_rb",
|
|
||||||
&vision::deepinsight::InsightFaceRecognitionModel::swap_rb)
|
|
||||||
.def_readwrite(
|
|
||||||
"l2_normalize",
|
|
||||||
&vision::deepinsight::InsightFaceRecognitionModel::l2_normalize);
|
|
||||||
// Bind ArcFace
|
|
||||||
pybind11::class_<vision::deepinsight::ArcFace,
|
|
||||||
vision::deepinsight::InsightFaceRecognitionModel>(
|
|
||||||
deepinsight_module, "ArcFace")
|
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
|
||||||
.def("predict",
|
|
||||||
[](vision::deepinsight::ArcFace& self, pybind11::array& data) {
|
|
||||||
auto mat = PyArrayToCvMat(data);
|
|
||||||
vision::FaceRecognitionResult res;
|
|
||||||
self.Predict(&mat, &res);
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.def_readwrite("size", &vision::deepinsight::ArcFace::size)
|
|
||||||
.def_readwrite("alpha", &vision::deepinsight::ArcFace::alpha)
|
|
||||||
.def_readwrite("beta", &vision::deepinsight::ArcFace::beta)
|
|
||||||
.def_readwrite("swap_rb", &vision::deepinsight::ArcFace::swap_rb)
|
|
||||||
.def_readwrite("l2_normalize",
|
|
||||||
&vision::deepinsight::ArcFace::l2_normalize);
|
|
||||||
// Bind CosFace
|
|
||||||
pybind11::class_<vision::deepinsight::CosFace,
|
|
||||||
vision::deepinsight::InsightFaceRecognitionModel>(
|
|
||||||
deepinsight_module, "CosFace")
|
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
|
||||||
.def("predict",
|
|
||||||
[](vision::deepinsight::CosFace& self, pybind11::array& data) {
|
|
||||||
auto mat = PyArrayToCvMat(data);
|
|
||||||
vision::FaceRecognitionResult res;
|
|
||||||
self.Predict(&mat, &res);
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.def_readwrite("size", &vision::deepinsight::CosFace::size)
|
|
||||||
.def_readwrite("alpha", &vision::deepinsight::CosFace::alpha)
|
|
||||||
.def_readwrite("beta", &vision::deepinsight::CosFace::beta)
|
|
||||||
.def_readwrite("swap_rb", &vision::deepinsight::CosFace::swap_rb)
|
|
||||||
.def_readwrite("l2_normalize",
|
|
||||||
&vision::deepinsight::CosFace::l2_normalize);
|
|
||||||
// Bind Partial FC
|
|
||||||
pybind11::class_<vision::deepinsight::PartialFC,
|
|
||||||
vision::deepinsight::InsightFaceRecognitionModel>(
|
|
||||||
deepinsight_module, "PartialFC")
|
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
|
||||||
.def("predict",
|
|
||||||
[](vision::deepinsight::PartialFC& self, pybind11::array& data) {
|
|
||||||
auto mat = PyArrayToCvMat(data);
|
|
||||||
vision::FaceRecognitionResult res;
|
|
||||||
self.Predict(&mat, &res);
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.def_readwrite("size", &vision::deepinsight::PartialFC::size)
|
|
||||||
.def_readwrite("alpha", &vision::deepinsight::PartialFC::alpha)
|
|
||||||
.def_readwrite("beta", &vision::deepinsight::PartialFC::beta)
|
|
||||||
.def_readwrite("swap_rb", &vision::deepinsight::PartialFC::swap_rb)
|
|
||||||
.def_readwrite("l2_normalize",
|
|
||||||
&vision::deepinsight::PartialFC::l2_normalize);
|
|
||||||
// Bind VPL
|
|
||||||
pybind11::class_<vision::deepinsight::VPL,
|
|
||||||
vision::deepinsight::InsightFaceRecognitionModel>(
|
|
||||||
deepinsight_module, "VPL")
|
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
|
||||||
.def("predict",
|
|
||||||
[](vision::deepinsight::VPL& self, pybind11::array& data) {
|
|
||||||
auto mat = PyArrayToCvMat(data);
|
|
||||||
vision::FaceRecognitionResult res;
|
|
||||||
self.Predict(&mat, &res);
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.def_readwrite("size", &vision::deepinsight::VPL::size)
|
|
||||||
.def_readwrite("alpha", &vision::deepinsight::VPL::alpha)
|
|
||||||
.def_readwrite("beta", &vision::deepinsight::VPL::beta)
|
|
||||||
.def_readwrite("swap_rb", &vision::deepinsight::VPL::swap_rb)
|
|
||||||
.def_readwrite("l2_normalize", &vision::deepinsight::VPL::l2_normalize);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace fastdeploy
|
|
@@ -10,7 +10,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/rangilyu/nanodet_plus.h"
|
#include "fastdeploy/vision/detection/contrib/nanodet_plus.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace rangilyu {
|
namespace detection {
|
||||||
|
|
||||||
struct NanoDetPlusCenterPoint {
|
struct NanoDetPlusCenterPoint {
|
||||||
int grid0;
|
int grid0;
|
||||||
@@ -350,6 +350,6 @@ bool NanoDetPlus::Predict(cv::Mat* im, DetectionResult* result,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace rangilyu
|
} // namespace detection
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -22,7 +22,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace rangilyu {
|
namespace detection {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL NanoDetPlus : public FastDeployModel {
|
class FASTDEPLOY_DECL NanoDetPlus : public FastDeployModel {
|
||||||
public:
|
public:
|
||||||
@@ -34,7 +34,7 @@ class FASTDEPLOY_DECL NanoDetPlus : public FastDeployModel {
|
|||||||
const Frontend& model_format = Frontend::ONNX);
|
const Frontend& model_format = Frontend::ONNX);
|
||||||
|
|
||||||
// 定义模型的名称
|
// 定义模型的名称
|
||||||
std::string ModelName() const { return "RangiLyu/nanodet"; }
|
std::string ModelName() const { return "nanodet"; }
|
||||||
|
|
||||||
// 模型预测接口,即用户调用的接口
|
// 模型预测接口,即用户调用的接口
|
||||||
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
||||||
@@ -96,6 +96,6 @@ class FASTDEPLOY_DECL NanoDetPlus : public FastDeployModel {
|
|||||||
bool is_dynamic_input_;
|
bool is_dynamic_input_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace rangilyu
|
} // namespace detection
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -15,27 +15,25 @@
|
|||||||
#include "fastdeploy/pybind/main.h"
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
void BindMegvii(pybind11::module& m) {
|
void BindNanoDetPlus(pybind11::module& m) {
|
||||||
auto megvii_module =
|
pybind11::class_<vision::detection::NanoDetPlus, FastDeployModel>(
|
||||||
m.def_submodule("megvii", "https://github.com/megvii/YOLOX");
|
m, "NanoDetPlus")
|
||||||
pybind11::class_<vision::megvii::YOLOX, FastDeployModel>(
|
|
||||||
megvii_module, "YOLOX")
|
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
.def("predict",
|
.def("predict",
|
||||||
[](vision::megvii::YOLOX& self, pybind11::array& data,
|
[](vision::detection::NanoDetPlus& self, pybind11::array& data,
|
||||||
float conf_threshold, float nms_iou_threshold) {
|
float conf_threshold, float nms_iou_threshold) {
|
||||||
auto mat = PyArrayToCvMat(data);
|
auto mat = PyArrayToCvMat(data);
|
||||||
vision::DetectionResult res;
|
vision::DetectionResult res;
|
||||||
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
.def_readwrite("size", &vision::megvii::YOLOX::size)
|
.def_readwrite("size", &vision::detection::NanoDetPlus::size)
|
||||||
.def_readwrite("padding_value",
|
.def_readwrite("padding_value",
|
||||||
&vision::megvii::YOLOX::padding_value)
|
&vision::detection::NanoDetPlus::padding_value)
|
||||||
.def_readwrite("is_decode_exported",
|
.def_readwrite("keep_ratio", &vision::detection::NanoDetPlus::keep_ratio)
|
||||||
&vision::megvii::YOLOX::is_decode_exported)
|
|
||||||
.def_readwrite("downsample_strides",
|
.def_readwrite("downsample_strides",
|
||||||
&vision::megvii::YOLOX::downsample_strides)
|
&vision::detection::NanoDetPlus::downsample_strides)
|
||||||
.def_readwrite("max_wh", &vision::megvii::YOLOX::max_wh);
|
.def_readwrite("max_wh", &vision::detection::NanoDetPlus::max_wh)
|
||||||
|
.def_readwrite("reg_max", &vision::detection::NanoDetPlus::reg_max);
|
||||||
}
|
}
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -12,17 +12,17 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/ultralytics/yolov5.h"
|
#include "fastdeploy/vision/detection/contrib/yolov5.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
namespace vision {
|
namespace vision {
|
||||||
namespace ultralytics {
|
namespace detection {
|
||||||
|
|
||||||
void LetterBox(Mat* mat, std::vector<int> size, std::vector<float> color,
|
void YOLOv5::LetterBox(Mat* mat, std::vector<int> size,
|
||||||
bool _auto, bool scale_fill = false, bool scale_up = true,
|
std::vector<float> color, bool _auto, bool scale_fill,
|
||||||
int stride = 32) {
|
bool scale_up, int stride) {
|
||||||
float scale =
|
float scale =
|
||||||
std::min(size[1] * 1.0 / mat->Height(), size[0] * 1.0 / mat->Width());
|
std::min(size[1] * 1.0 / mat->Height(), size[0] * 1.0 / mat->Width());
|
||||||
if (!scale_up) {
|
if (!scale_up) {
|
||||||
@@ -290,6 +290,6 @@ bool YOLOv5::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ultralytics
|
} // namespace detection
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
namespace vision {
|
namespace vision {
|
||||||
namespace ultralytics {
|
namespace detection {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel {
|
class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel {
|
||||||
public:
|
public:
|
||||||
@@ -30,7 +30,7 @@ class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel {
|
|||||||
const Frontend& model_format = Frontend::ONNX);
|
const Frontend& model_format = Frontend::ONNX);
|
||||||
|
|
||||||
// 定义模型的名称
|
// 定义模型的名称
|
||||||
std::string ModelName() const { return "ultralytics/yolov5"; }
|
std::string ModelName() const { return "yolov5"; }
|
||||||
|
|
||||||
// 模型预测接口,即用户调用的接口
|
// 模型预测接口,即用户调用的接口
|
||||||
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
||||||
@@ -81,21 +81,28 @@ class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel {
|
|||||||
// conf_threshold 后处理时过滤box的置信度阈值
|
// conf_threshold 后处理时过滤box的置信度阈值
|
||||||
// nms_iou_threshold 后处理时NMS设定的iou阈值
|
// nms_iou_threshold 后处理时NMS设定的iou阈值
|
||||||
// multi_label 后处理时box选取是否采用多标签方式
|
// multi_label 后处理时box选取是否采用多标签方式
|
||||||
bool Postprocess(
|
bool Postprocess(FDTensor& infer_result, DetectionResult* result,
|
||||||
FDTensor& infer_result, DetectionResult* result,
|
|
||||||
const std::map<std::string, std::array<float, 2>>& im_info,
|
const std::map<std::string, std::array<float, 2>>& im_info,
|
||||||
float conf_threshold, float nms_iou_threshold, bool multi_label);
|
float conf_threshold, float nms_iou_threshold,
|
||||||
|
bool multi_label);
|
||||||
|
|
||||||
// 查看输入是否为动态维度的 不建议直接使用 不同模型的逻辑可能不一致
|
// 查看输入是否为动态维度的 不建议直接使用 不同模型的逻辑可能不一致
|
||||||
bool IsDynamicInput() const { return is_dynamic_input_; }
|
bool IsDynamicInput() const { return is_dynamic_input_; }
|
||||||
|
|
||||||
// whether to inference with dynamic shape (e.g ONNX export with dynamic shape or not.)
|
void LetterBox(Mat* mat, std::vector<int> size, std::vector<float> color,
|
||||||
// YOLOv5 official 'export_onnx.py' script will export dynamic ONNX by default.
|
bool _auto, bool scale_fill = false, bool scale_up = true,
|
||||||
// while is_dynamic_shape if 'false', is_mini_pad will force 'false'. This value will
|
int stride = 32);
|
||||||
|
|
||||||
|
// whether to inference with dynamic shape (e.g ONNX export with dynamic shape
|
||||||
|
// or not.)
|
||||||
|
// YOLOv5 official 'export_onnx.py' script will export dynamic ONNX by
|
||||||
|
// default.
|
||||||
|
// while is_dynamic_shape if 'false', is_mini_pad will force 'false'. This
|
||||||
|
// value will
|
||||||
// auto check by fastdeploy after the internal Runtime already initialized.
|
// auto check by fastdeploy after the internal Runtime already initialized.
|
||||||
bool is_dynamic_input_;
|
bool is_dynamic_input_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ultralytics
|
} // namespace detection
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -15,27 +15,24 @@
|
|||||||
#include "fastdeploy/pybind/main.h"
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
void BindMeituan(pybind11::module& m) {
|
void BindYOLOv5(pybind11::module& m) {
|
||||||
auto meituan_module =
|
pybind11::class_<vision::detection::YOLOv5, FastDeployModel>(m, "YOLOv5")
|
||||||
m.def_submodule("meituan", "https://github.com/meituan/YOLOv6");
|
|
||||||
pybind11::class_<vision::meituan::YOLOv6, FastDeployModel>(
|
|
||||||
meituan_module, "YOLOv6")
|
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
.def("predict",
|
.def("predict",
|
||||||
[](vision::meituan::YOLOv6& self, pybind11::array& data,
|
[](vision::detection::YOLOv5& self, pybind11::array& data,
|
||||||
float conf_threshold, float nms_iou_threshold) {
|
float conf_threshold, float nms_iou_threshold) {
|
||||||
auto mat = PyArrayToCvMat(data);
|
auto mat = PyArrayToCvMat(data);
|
||||||
vision::DetectionResult res;
|
vision::DetectionResult res;
|
||||||
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
.def_readwrite("size", &vision::meituan::YOLOv6::size)
|
.def_readwrite("size", &vision::detection::YOLOv5::size)
|
||||||
.def_readwrite("padding_value",
|
.def_readwrite("padding_value", &vision::detection::YOLOv5::padding_value)
|
||||||
&vision::meituan::YOLOv6::padding_value)
|
.def_readwrite("is_mini_pad", &vision::detection::YOLOv5::is_mini_pad)
|
||||||
.def_readwrite("is_mini_pad", &vision::meituan::YOLOv6::is_mini_pad)
|
.def_readwrite("is_no_pad", &vision::detection::YOLOv5::is_no_pad)
|
||||||
.def_readwrite("is_no_pad", &vision::meituan::YOLOv6::is_no_pad)
|
.def_readwrite("is_scale_up", &vision::detection::YOLOv5::is_scale_up)
|
||||||
.def_readwrite("is_scale_up", &vision::meituan::YOLOv6::is_scale_up)
|
.def_readwrite("stride", &vision::detection::YOLOv5::stride)
|
||||||
.def_readwrite("stride", &vision::meituan::YOLOv6::stride)
|
.def_readwrite("max_wh", &vision::detection::YOLOv5::max_wh)
|
||||||
.def_readwrite("max_wh", &vision::meituan::YOLOv6::max_wh);
|
.def_readwrite("multi_label", &vision::detection::YOLOv5::multi_label);
|
||||||
}
|
}
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -12,13 +12,13 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/ppogg/yolov5lite.h"
|
#include "fastdeploy/vision/detection/contrib/yolov5lite.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
namespace vision {
|
namespace vision {
|
||||||
namespace ppogg {
|
namespace detection {
|
||||||
|
|
||||||
void YOLOv5Lite::LetterBox(Mat* mat, const std::vector<int>& size,
|
void YOLOv5Lite::LetterBox(Mat* mat, const std::vector<int>& size,
|
||||||
const std::vector<float>& color, bool _auto,
|
const std::vector<float>& color, bool _auto,
|
||||||
@@ -191,7 +191,6 @@ bool YOLOv5Lite::PostprocessWithDecode(
|
|||||||
std::vector<YOLOv5Lite::Anchor> anchors;
|
std::vector<YOLOv5Lite::Anchor> anchors;
|
||||||
int num_anchors = anchor_config[0].size() / 2;
|
int num_anchors = anchor_config[0].size() / 2;
|
||||||
GenerateAnchors(size, downsample_strides, &anchors, num_anchors);
|
GenerateAnchors(size, downsample_strides, &anchors, num_anchors);
|
||||||
|
|
||||||
// infer_result shape might look like (1,n,85=5+80)
|
// infer_result shape might look like (1,n,85=5+80)
|
||||||
float* data = static_cast<float*>(infer_result.Data());
|
float* data = static_cast<float*>(infer_result.Data());
|
||||||
for (size_t i = 0; i < infer_result.shape[1]; ++i) {
|
for (size_t i = 0; i < infer_result.shape[1]; ++i) {
|
||||||
@@ -395,6 +394,6 @@ bool YOLOv5Lite::Predict(cv::Mat* im, DetectionResult* result,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ppogg
|
} // namespace detection
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
namespace vision {
|
namespace vision {
|
||||||
namespace ppogg {
|
namespace detection {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL YOLOv5Lite : public FastDeployModel {
|
class FASTDEPLOY_DECL YOLOv5Lite : public FastDeployModel {
|
||||||
public:
|
public:
|
||||||
@@ -30,8 +30,7 @@ class FASTDEPLOY_DECL YOLOv5Lite : public FastDeployModel {
|
|||||||
const Frontend& model_format = Frontend::ONNX);
|
const Frontend& model_format = Frontend::ONNX);
|
||||||
|
|
||||||
// 定义模型的名称
|
// 定义模型的名称
|
||||||
virtual std::string ModelName() const { return "ppogg/YOLOv5-Lite"; }
|
virtual std::string ModelName() const { return "YOLOv5-Lite"; }
|
||||||
|
|
||||||
// 模型预测接口,即用户调用的接口
|
// 模型预测接口,即用户调用的接口
|
||||||
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
||||||
// result 为模型预测的输出结构体
|
// result 为模型预测的输出结构体
|
||||||
@@ -134,6 +133,6 @@ class FASTDEPLOY_DECL YOLOv5Lite : public FastDeployModel {
|
|||||||
// auto check by fastdeploy after the internal Runtime already initialized.
|
// auto check by fastdeploy after the internal Runtime already initialized.
|
||||||
bool is_dynamic_input_;
|
bool is_dynamic_input_;
|
||||||
};
|
};
|
||||||
} // namespace ppogg
|
} // namespace detection
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -15,29 +15,29 @@
|
|||||||
#include "fastdeploy/pybind/main.h"
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
void BindPpogg(pybind11::module& m) {
|
void BindYOLOv5Lite(pybind11::module& m) {
|
||||||
auto ppogg_module =
|
pybind11::class_<vision::detection::YOLOv5Lite, FastDeployModel>(m,
|
||||||
m.def_submodule("ppogg", "https://github.com/ppogg/YOLOv5-Lite");
|
|
||||||
pybind11::class_<vision::ppogg::YOLOv5Lite, FastDeployModel>(ppogg_module,
|
|
||||||
"YOLOv5Lite")
|
"YOLOv5Lite")
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
.def("predict",
|
.def("predict",
|
||||||
[](vision::ppogg::YOLOv5Lite& self, pybind11::array& data,
|
[](vision::detection::YOLOv5Lite& self, pybind11::array& data,
|
||||||
float conf_threshold, float nms_iou_threshold) {
|
float conf_threshold, float nms_iou_threshold) {
|
||||||
auto mat = PyArrayToCvMat(data);
|
auto mat = PyArrayToCvMat(data);
|
||||||
vision::DetectionResult res;
|
vision::DetectionResult res;
|
||||||
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
.def_readwrite("size", &vision::ppogg::YOLOv5Lite::size)
|
.def_readwrite("size", &vision::detection::YOLOv5Lite::size)
|
||||||
.def_readwrite("padding_value", &vision::ppogg::YOLOv5Lite::padding_value)
|
.def_readwrite("padding_value",
|
||||||
.def_readwrite("is_mini_pad", &vision::ppogg::YOLOv5Lite::is_mini_pad)
|
&vision::detection::YOLOv5Lite::padding_value)
|
||||||
.def_readwrite("is_no_pad", &vision::ppogg::YOLOv5Lite::is_no_pad)
|
.def_readwrite("is_mini_pad", &vision::detection::YOLOv5Lite::is_mini_pad)
|
||||||
.def_readwrite("is_scale_up", &vision::ppogg::YOLOv5Lite::is_scale_up)
|
.def_readwrite("is_no_pad", &vision::detection::YOLOv5Lite::is_no_pad)
|
||||||
.def_readwrite("stride", &vision::ppogg::YOLOv5Lite::stride)
|
.def_readwrite("is_scale_up", &vision::detection::YOLOv5Lite::is_scale_up)
|
||||||
.def_readwrite("max_wh", &vision::ppogg::YOLOv5Lite::max_wh)
|
.def_readwrite("stride", &vision::detection::YOLOv5Lite::stride)
|
||||||
.def_readwrite("anchor_config", &vision::ppogg::YOLOv5Lite::anchor_config)
|
.def_readwrite("max_wh", &vision::detection::YOLOv5Lite::max_wh)
|
||||||
|
.def_readwrite("anchor_config",
|
||||||
|
&vision::detection::YOLOv5Lite::anchor_config)
|
||||||
.def_readwrite("is_decode_exported",
|
.def_readwrite("is_decode_exported",
|
||||||
&vision::ppogg::YOLOv5Lite::is_decode_exported);
|
&vision::detection::YOLOv5Lite::is_decode_exported);
|
||||||
}
|
}
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/meituan/yolov6.h"
|
#include "fastdeploy/vision/detection/contrib/yolov6.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -20,11 +20,11 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace meituan {
|
namespace detection {
|
||||||
|
|
||||||
void LetterBox(Mat* mat, std::vector<int> size, std::vector<float> color,
|
void YOLOv6::LetterBox(Mat* mat, std::vector<int> size,
|
||||||
bool _auto, bool scale_fill = false, bool scale_up = true,
|
std::vector<float> color, bool _auto, bool scale_fill,
|
||||||
int stride = 32) {
|
bool scale_up, int stride) {
|
||||||
float scale = std::min(size[1] * 1.0f / static_cast<float>(mat->Height()),
|
float scale = std::min(size[1] * 1.0f / static_cast<float>(mat->Height()),
|
||||||
size[0] * 1.0f / static_cast<float>(mat->Width()));
|
size[0] * 1.0f / static_cast<float>(mat->Width()));
|
||||||
if (!scale_up) {
|
if (!scale_up) {
|
||||||
@@ -262,6 +262,6 @@ bool YOLOv6::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace meituan
|
} // namespace detection
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -22,7 +22,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace meituan {
|
namespace detection {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL YOLOv6 : public FastDeployModel {
|
class FASTDEPLOY_DECL YOLOv6 : public FastDeployModel {
|
||||||
public:
|
public:
|
||||||
@@ -33,7 +33,7 @@ class FASTDEPLOY_DECL YOLOv6 : public FastDeployModel {
|
|||||||
const Frontend& model_format = Frontend::ONNX);
|
const Frontend& model_format = Frontend::ONNX);
|
||||||
|
|
||||||
// 定义模型的名称
|
// 定义模型的名称
|
||||||
std::string ModelName() const { return "meituan/YOLOv6"; }
|
std::string ModelName() const { return "YOLOv6"; }
|
||||||
|
|
||||||
// 模型预测接口,即用户调用的接口
|
// 模型预测接口,即用户调用的接口
|
||||||
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
||||||
@@ -61,7 +61,8 @@ class FASTDEPLOY_DECL YOLOv6 : public FastDeployModel {
|
|||||||
bool is_scale_up;
|
bool is_scale_up;
|
||||||
// padding stride, for is_mini_pad
|
// padding stride, for is_mini_pad
|
||||||
int stride;
|
int stride;
|
||||||
// for offseting the boxes by classes when using NMS, default 4096 in meituan/YOLOv6
|
// for offseting the boxes by classes when using NMS, default 4096 in
|
||||||
|
// meituan/YOLOv6
|
||||||
float max_wh;
|
float max_wh;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -81,21 +82,27 @@ class FASTDEPLOY_DECL YOLOv6 : public FastDeployModel {
|
|||||||
// im_info 为预处理记录的信息,后处理用于还原box
|
// im_info 为预处理记录的信息,后处理用于还原box
|
||||||
// conf_threshold 后处理时过滤box的置信度阈值
|
// conf_threshold 后处理时过滤box的置信度阈值
|
||||||
// nms_iou_threshold 后处理时NMS设定的iou阈值
|
// nms_iou_threshold 后处理时NMS设定的iou阈值
|
||||||
bool Postprocess(
|
bool Postprocess(FDTensor& infer_result, DetectionResult* result,
|
||||||
FDTensor& infer_result, DetectionResult* result,
|
|
||||||
const std::map<std::string, std::array<float, 2>>& im_info,
|
const std::map<std::string, std::array<float, 2>>& im_info,
|
||||||
float conf_threshold, float nms_iou_threshold);
|
float conf_threshold, float nms_iou_threshold);
|
||||||
|
|
||||||
// 查看输入是否为动态维度的 不建议直接使用 不同模型的逻辑可能不一致
|
// 查看输入是否为动态维度的 不建议直接使用 不同模型的逻辑可能不一致
|
||||||
bool IsDynamicInput() const { return is_dynamic_input_; }
|
bool IsDynamicInput() const { return is_dynamic_input_; }
|
||||||
|
|
||||||
// whether to inference with dynamic shape (e.g ONNX export with dynamic shape or not.)
|
void LetterBox(Mat* mat, std::vector<int> size, std::vector<float> color,
|
||||||
// meituan/YOLOv6 official 'export_onnx.py' script will export static ONNX by default.
|
bool _auto, bool scale_fill = false, bool scale_up = true,
|
||||||
// while is_dynamic_input if 'false', is_mini_pad will force 'false'. This value will
|
int stride = 32);
|
||||||
|
|
||||||
|
// whether to inference with dynamic shape (e.g ONNX export with dynamic shape
|
||||||
|
// or not.)
|
||||||
|
// meituan/YOLOv6 official 'export_onnx.py' script will export static ONNX by
|
||||||
|
// default.
|
||||||
|
// while is_dynamic_input if 'false', is_mini_pad will force 'false'. This
|
||||||
|
// value will
|
||||||
// auto check by fastdeploy after the internal Runtime already initialized.
|
// auto check by fastdeploy after the internal Runtime already initialized.
|
||||||
bool is_dynamic_input_;
|
bool is_dynamic_input_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace meituan
|
} // namespace detection
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
37
csrcs/fastdeploy/vision/detection/contrib/yolov6_pybind.cc
Normal file
37
csrcs/fastdeploy/vision/detection/contrib/yolov6_pybind.cc
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
|
namespace fastdeploy {
|
||||||
|
void BindYOLOv6(pybind11::module& m) {
|
||||||
|
pybind11::class_<vision::detection::YOLOv6, FastDeployModel>(m, "YOLOv6")
|
||||||
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
|
.def("predict",
|
||||||
|
[](vision::detection::YOLOv6& self, pybind11::array& data,
|
||||||
|
float conf_threshold, float nms_iou_threshold) {
|
||||||
|
auto mat = PyArrayToCvMat(data);
|
||||||
|
vision::DetectionResult res;
|
||||||
|
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.def_readwrite("size", &vision::detection::YOLOv6::size)
|
||||||
|
.def_readwrite("padding_value", &vision::detection::YOLOv6::padding_value)
|
||||||
|
.def_readwrite("is_mini_pad", &vision::detection::YOLOv6::is_mini_pad)
|
||||||
|
.def_readwrite("is_no_pad", &vision::detection::YOLOv6::is_no_pad)
|
||||||
|
.def_readwrite("is_scale_up", &vision::detection::YOLOv6::is_scale_up)
|
||||||
|
.def_readwrite("stride", &vision::detection::YOLOv6::stride)
|
||||||
|
.def_readwrite("max_wh", &vision::detection::YOLOv6::max_wh);
|
||||||
|
}
|
||||||
|
} // namespace fastdeploy
|
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/megvii/yolox.h"
|
#include "fastdeploy/vision/detection/contrib/yolox.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace megvii {
|
namespace detection {
|
||||||
|
|
||||||
struct YOLOXAnchor {
|
struct YOLOXAnchor {
|
||||||
int grid0;
|
int grid0;
|
||||||
@@ -334,6 +334,6 @@ bool YOLOX::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace megvii
|
} // namespace detection
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -22,7 +22,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace megvii {
|
namespace detection {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL YOLOX : public FastDeployModel {
|
class FASTDEPLOY_DECL YOLOX : public FastDeployModel {
|
||||||
public:
|
public:
|
||||||
@@ -33,7 +33,7 @@ class FASTDEPLOY_DECL YOLOX : public FastDeployModel {
|
|||||||
const Frontend& model_format = Frontend::ONNX);
|
const Frontend& model_format = Frontend::ONNX);
|
||||||
|
|
||||||
// 定义模型的名称
|
// 定义模型的名称
|
||||||
std::string ModelName() const { return "megvii/YOLOX"; }
|
std::string ModelName() const { return "YOLOX"; }
|
||||||
|
|
||||||
// 模型预测接口,即用户调用的接口
|
// 模型预测接口,即用户调用的接口
|
||||||
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
||||||
@@ -79,8 +79,7 @@ class FASTDEPLOY_DECL YOLOX : public FastDeployModel {
|
|||||||
// im_info 为预处理记录的信息,后处理用于还原box
|
// im_info 为预处理记录的信息,后处理用于还原box
|
||||||
// conf_threshold 后处理时过滤box的置信度阈值
|
// conf_threshold 后处理时过滤box的置信度阈值
|
||||||
// nms_iou_threshold 后处理时NMS设定的iou阈值
|
// nms_iou_threshold 后处理时NMS设定的iou阈值
|
||||||
bool Postprocess(
|
bool Postprocess(FDTensor& infer_result, DetectionResult* result,
|
||||||
FDTensor& infer_result, DetectionResult* result,
|
|
||||||
const std::map<std::string, std::array<float, 2>>& im_info,
|
const std::map<std::string, std::array<float, 2>>& im_info,
|
||||||
float conf_threshold, float nms_iou_threshold);
|
float conf_threshold, float nms_iou_threshold);
|
||||||
|
|
||||||
@@ -93,13 +92,16 @@ class FASTDEPLOY_DECL YOLOX : public FastDeployModel {
|
|||||||
// 查看输入是否为动态维度的 不建议直接使用 不同模型的逻辑可能不一致
|
// 查看输入是否为动态维度的 不建议直接使用 不同模型的逻辑可能不一致
|
||||||
bool IsDynamicInput() const { return is_dynamic_input_; }
|
bool IsDynamicInput() const { return is_dynamic_input_; }
|
||||||
|
|
||||||
// whether to inference with dynamic shape (e.g ONNX export with dynamic shape or not.)
|
// whether to inference with dynamic shape (e.g ONNX export with dynamic shape
|
||||||
// megvii/YOLOX official 'export_onnx.py' script will export static ONNX by default.
|
// or not.)
|
||||||
// while is_dynamic_shape if 'false', is_mini_pad will force 'false'. This value will
|
// megvii/YOLOX official 'export_onnx.py' script will export static ONNX by
|
||||||
|
// default.
|
||||||
|
// while is_dynamic_shape if 'false', is_mini_pad will force 'false'. This
|
||||||
|
// value will
|
||||||
// auto check by fastdeploy after the internal Runtime already initialized.
|
// auto check by fastdeploy after the internal Runtime already initialized.
|
||||||
bool is_dynamic_input_;
|
bool is_dynamic_input_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace megvii
|
} // namespace detection
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -15,27 +15,23 @@
|
|||||||
#include "fastdeploy/pybind/main.h"
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
void BindRangiLyu(pybind11::module& m) {
|
void BindYOLOX(pybind11::module& m) {
|
||||||
auto rangilyu_module =
|
pybind11::class_<vision::detection::YOLOX, FastDeployModel>(m, "YOLOX")
|
||||||
m.def_submodule("rangilyu", "https://github.com/RangiLyu/nanodet");
|
|
||||||
pybind11::class_<vision::rangilyu::NanoDetPlus, FastDeployModel>(
|
|
||||||
rangilyu_module, "NanoDetPlus")
|
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
.def("predict",
|
.def("predict",
|
||||||
[](vision::rangilyu::NanoDetPlus& self, pybind11::array& data,
|
[](vision::detection::YOLOX& self, pybind11::array& data,
|
||||||
float conf_threshold, float nms_iou_threshold) {
|
float conf_threshold, float nms_iou_threshold) {
|
||||||
auto mat = PyArrayToCvMat(data);
|
auto mat = PyArrayToCvMat(data);
|
||||||
vision::DetectionResult res;
|
vision::DetectionResult res;
|
||||||
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
.def_readwrite("size", &vision::rangilyu::NanoDetPlus::size)
|
.def_readwrite("size", &vision::detection::YOLOX::size)
|
||||||
.def_readwrite("padding_value",
|
.def_readwrite("padding_value", &vision::detection::YOLOX::padding_value)
|
||||||
&vision::rangilyu::NanoDetPlus::padding_value)
|
.def_readwrite("is_decode_exported",
|
||||||
.def_readwrite("keep_ratio", &vision::rangilyu::NanoDetPlus::keep_ratio)
|
&vision::detection::YOLOX::is_decode_exported)
|
||||||
.def_readwrite("downsample_strides",
|
.def_readwrite("downsample_strides",
|
||||||
&vision::rangilyu::NanoDetPlus::downsample_strides)
|
&vision::detection::YOLOX::downsample_strides)
|
||||||
.def_readwrite("max_wh", &vision::rangilyu::NanoDetPlus::max_wh)
|
.def_readwrite("max_wh", &vision::detection::YOLOX::max_wh);
|
||||||
.def_readwrite("reg_max", &vision::rangilyu::NanoDetPlus::reg_max);
|
|
||||||
}
|
}
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -19,6 +19,11 @@ namespace fastdeploy {
|
|||||||
void BindYOLOv7(pybind11::module& m);
|
void BindYOLOv7(pybind11::module& m);
|
||||||
void BindScaledYOLOv4(pybind11::module& m);
|
void BindScaledYOLOv4(pybind11::module& m);
|
||||||
void BindYOLOR(pybind11::module& m);
|
void BindYOLOR(pybind11::module& m);
|
||||||
|
void BindYOLOv6(pybind11::module& m);
|
||||||
|
void BindYOLOv5Lite(pybind11::module& m);
|
||||||
|
void BindYOLOv5(pybind11::module& m);
|
||||||
|
void BindYOLOX(pybind11::module& m);
|
||||||
|
void BindNanoDetPlus(pybind11::module& m);
|
||||||
void BindPPDet(pybind11::module& m);
|
void BindPPDet(pybind11::module& m);
|
||||||
|
|
||||||
void BindDetection(pybind11::module& m) {
|
void BindDetection(pybind11::module& m) {
|
||||||
@@ -28,5 +33,10 @@ void BindDetection(pybind11::module& m) {
|
|||||||
BindYOLOv7(detection_module);
|
BindYOLOv7(detection_module);
|
||||||
BindScaledYOLOv4(detection_module);
|
BindScaledYOLOv4(detection_module);
|
||||||
BindYOLOR(detection_module);
|
BindYOLOR(detection_module);
|
||||||
|
BindYOLOv6(detection_module);
|
||||||
|
BindYOLOv5Lite(detection_module);
|
||||||
|
BindYOLOv5(detection_module);
|
||||||
|
BindYOLOX(detection_module);
|
||||||
|
BindNanoDetPlus(detection_module);
|
||||||
}
|
}
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/biubug6/retinaface.h"
|
#include "fastdeploy/vision/facedet/contrib/retinaface.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace biubug6 {
|
namespace facedet {
|
||||||
|
|
||||||
struct RetinaAnchor {
|
struct RetinaAnchor {
|
||||||
float cx;
|
float cx;
|
||||||
@@ -305,6 +305,6 @@ bool RetinaFace::Predict(cv::Mat* im, FaceDetectionResult* result,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace biubug6
|
} // namespace facedet
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -21,7 +21,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace biubug6 {
|
namespace facedet {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL RetinaFace : public FastDeployModel {
|
class FASTDEPLOY_DECL RetinaFace : public FastDeployModel {
|
||||||
public:
|
public:
|
||||||
@@ -32,7 +32,7 @@ class FASTDEPLOY_DECL RetinaFace : public FastDeployModel {
|
|||||||
const Frontend& model_format = Frontend::ONNX);
|
const Frontend& model_format = Frontend::ONNX);
|
||||||
|
|
||||||
// 定义模型的名称
|
// 定义模型的名称
|
||||||
std::string ModelName() const { return "biubug6/Pytorch_Retinaface"; }
|
std::string ModelName() const { return "Pytorch_Retinaface"; }
|
||||||
|
|
||||||
// 模型预测接口,即用户调用的接口
|
// 模型预测接口,即用户调用的接口
|
||||||
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
||||||
@@ -87,6 +87,6 @@ class FASTDEPLOY_DECL RetinaFace : public FastDeployModel {
|
|||||||
bool is_dynamic_input_;
|
bool is_dynamic_input_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace biubug6
|
} // namespace facedet
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -15,26 +15,24 @@
|
|||||||
#include "fastdeploy/pybind/main.h"
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
void BindBiubug6(pybind11::module& m) {
|
void BindRetinaFace(pybind11::module& m) {
|
||||||
auto biubug6_module = m.def_submodule(
|
pybind11::class_<vision::facedet::RetinaFace, FastDeployModel>(m,
|
||||||
"biubug6", "https://github.com/biubug6/Pytorch_Retinaface");
|
|
||||||
pybind11::class_<vision::biubug6::RetinaFace, FastDeployModel>(biubug6_module,
|
|
||||||
"RetinaFace")
|
"RetinaFace")
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
.def("predict",
|
.def("predict",
|
||||||
[](vision::biubug6::RetinaFace& self, pybind11::array& data,
|
[](vision::facedet::RetinaFace& self, pybind11::array& data,
|
||||||
float conf_threshold, float nms_iou_threshold) {
|
float conf_threshold, float nms_iou_threshold) {
|
||||||
auto mat = PyArrayToCvMat(data);
|
auto mat = PyArrayToCvMat(data);
|
||||||
vision::FaceDetectionResult res;
|
vision::FaceDetectionResult res;
|
||||||
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
.def_readwrite("size", &vision::biubug6::RetinaFace::size)
|
.def_readwrite("size", &vision::facedet::RetinaFace::size)
|
||||||
.def_readwrite("variance", &vision::biubug6::RetinaFace::variance)
|
.def_readwrite("variance", &vision::facedet::RetinaFace::variance)
|
||||||
.def_readwrite("downsample_strides",
|
.def_readwrite("downsample_strides",
|
||||||
&vision::biubug6::RetinaFace::downsample_strides)
|
&vision::facedet::RetinaFace::downsample_strides)
|
||||||
.def_readwrite("min_sizes", &vision::biubug6::RetinaFace::min_sizes)
|
.def_readwrite("min_sizes", &vision::facedet::RetinaFace::min_sizes)
|
||||||
.def_readwrite("landmarks_per_face",
|
.def_readwrite("landmarks_per_face",
|
||||||
&vision::biubug6::RetinaFace::landmarks_per_face);
|
&vision::facedet::RetinaFace::landmarks_per_face);
|
||||||
}
|
}
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/deepinsight/scrfd.h"
|
#include "fastdeploy/vision/facedet/contrib/scrfd.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepinsight {
|
namespace facedet {
|
||||||
|
|
||||||
void SCRFD::LetterBox(Mat* mat, const std::vector<int>& size,
|
void SCRFD::LetterBox(Mat* mat, const std::vector<int>& size,
|
||||||
const std::vector<float>& color, bool _auto,
|
const std::vector<float>& color, bool _auto,
|
||||||
@@ -246,14 +246,18 @@ bool SCRFD::Postprocess(
|
|||||||
float r = offsets[2]; // right
|
float r = offsets[2]; // right
|
||||||
float b = offsets[3]; // bottom
|
float b = offsets[3]; // bottom
|
||||||
|
|
||||||
float x1 =
|
float x1 = ((cx - l) * static_cast<float>(current_stride) -
|
||||||
((cx - l) * static_cast<float>(current_stride) - static_cast<float>(pad_w)) / scale; // cx - l x1
|
static_cast<float>(pad_w)) /
|
||||||
float y1 =
|
scale; // cx - l x1
|
||||||
((cy - t) * static_cast<float>(current_stride) - static_cast<float>(pad_h)) / scale; // cy - t y1
|
float y1 = ((cy - t) * static_cast<float>(current_stride) -
|
||||||
float x2 =
|
static_cast<float>(pad_h)) /
|
||||||
((cx + r) * static_cast<float>(current_stride) - static_cast<float>(pad_w)) / scale; // cx + r x2
|
scale; // cy - t y1
|
||||||
float y2 =
|
float x2 = ((cx + r) * static_cast<float>(current_stride) -
|
||||||
((cy + b) * static_cast<float>(current_stride) - static_cast<float>(pad_h)) / scale; // cy + b y2
|
static_cast<float>(pad_w)) /
|
||||||
|
scale; // cx + r x2
|
||||||
|
float y2 = ((cy + b) * static_cast<float>(current_stride) -
|
||||||
|
static_cast<float>(pad_h)) /
|
||||||
|
scale; // cy + b y2
|
||||||
result->boxes.emplace_back(std::array<float, 4>{x1, y1, x2, y2});
|
result->boxes.emplace_back(std::array<float, 4>{x1, y1, x2, y2});
|
||||||
result->scores.push_back(cls_conf);
|
result->scores.push_back(cls_conf);
|
||||||
if (use_kps) {
|
if (use_kps) {
|
||||||
@@ -264,9 +268,11 @@ bool SCRFD::Postprocess(
|
|||||||
for (unsigned int j = 0; j < landmarks_per_face * 2; j += 2) {
|
for (unsigned int j = 0; j < landmarks_per_face * 2; j += 2) {
|
||||||
float kps_l = kps_offsets[j];
|
float kps_l = kps_offsets[j];
|
||||||
float kps_t = kps_offsets[j + 1];
|
float kps_t = kps_offsets[j + 1];
|
||||||
float kps_x = ((cx + kps_l) * static_cast<float>(current_stride) - static_cast<float>(pad_w)) /
|
float kps_x = ((cx + kps_l) * static_cast<float>(current_stride) -
|
||||||
|
static_cast<float>(pad_w)) /
|
||||||
scale; // cx + l x
|
scale; // cx + l x
|
||||||
float kps_y = ((cy + kps_t) * static_cast<float>(current_stride) - static_cast<float>(pad_h)) /
|
float kps_y = ((cy + kps_t) * static_cast<float>(current_stride) -
|
||||||
|
static_cast<float>(pad_h)) /
|
||||||
scale; // cy + t y
|
scale; // cy + t y
|
||||||
result->landmarks.emplace_back(std::array<float, 2>{kps_x, kps_y});
|
result->landmarks.emplace_back(std::array<float, 2>{kps_x, kps_y});
|
||||||
}
|
}
|
||||||
@@ -358,6 +364,6 @@ bool SCRFD::Predict(cv::Mat* im, FaceDetectionResult* result,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace deepinsight
|
} // namespace facedet
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -22,7 +22,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepinsight {
|
namespace facedet {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL SCRFD : public FastDeployModel {
|
class FASTDEPLOY_DECL SCRFD : public FastDeployModel {
|
||||||
public:
|
public:
|
||||||
@@ -33,7 +33,7 @@ class FASTDEPLOY_DECL SCRFD : public FastDeployModel {
|
|||||||
const Frontend& model_format = Frontend::ONNX);
|
const Frontend& model_format = Frontend::ONNX);
|
||||||
|
|
||||||
// 定义模型的名称
|
// 定义模型的名称
|
||||||
std::string ModelName() const { return "deepinsight/scrfd"; }
|
std::string ModelName() const { return "scrfd"; }
|
||||||
|
|
||||||
// 模型预测接口,即用户调用的接口
|
// 模型预测接口,即用户调用的接口
|
||||||
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
||||||
@@ -117,6 +117,6 @@ class FASTDEPLOY_DECL SCRFD : public FastDeployModel {
|
|||||||
|
|
||||||
std::unordered_map<int, std::vector<SCRFDPoint>> center_points_;
|
std::unordered_map<int, std::vector<SCRFDPoint>> center_points_;
|
||||||
};
|
};
|
||||||
} // namespace deepinsight
|
} // namespace facedet
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
45
csrcs/fastdeploy/vision/facedet/contrib/scrfd_pybind.cc
Normal file
45
csrcs/fastdeploy/vision/facedet/contrib/scrfd_pybind.cc
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
|
namespace fastdeploy {
|
||||||
|
void BindSCRFD(pybind11::module& m) {
|
||||||
|
// Bind SCRFD
|
||||||
|
pybind11::class_<vision::facedet::SCRFD, FastDeployModel>(m, "SCRFD")
|
||||||
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
|
.def("predict",
|
||||||
|
[](vision::facedet::SCRFD& self, pybind11::array& data,
|
||||||
|
float conf_threshold, float nms_iou_threshold) {
|
||||||
|
auto mat = PyArrayToCvMat(data);
|
||||||
|
vision::FaceDetectionResult res;
|
||||||
|
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.def_readwrite("size", &vision::facedet::SCRFD::size)
|
||||||
|
.def_readwrite("padding_value", &vision::facedet::SCRFD::padding_value)
|
||||||
|
.def_readwrite("is_mini_pad", &vision::facedet::SCRFD::is_mini_pad)
|
||||||
|
.def_readwrite("is_no_pad", &vision::facedet::SCRFD::is_no_pad)
|
||||||
|
.def_readwrite("is_scale_up", &vision::facedet::SCRFD::is_scale_up)
|
||||||
|
.def_readwrite("stride", &vision::facedet::SCRFD::stride)
|
||||||
|
.def_readwrite("use_kps", &vision::facedet::SCRFD::use_kps)
|
||||||
|
.def_readwrite("max_nms", &vision::facedet::SCRFD::max_nms)
|
||||||
|
.def_readwrite("downsample_strides",
|
||||||
|
&vision::facedet::SCRFD::downsample_strides)
|
||||||
|
.def_readwrite("num_anchors", &vision::facedet::SCRFD::num_anchors)
|
||||||
|
.def_readwrite("landmarks_per_face",
|
||||||
|
&vision::facedet::SCRFD::landmarks_per_face);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace fastdeploy
|
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/linzaer/ultraface.h"
|
#include "fastdeploy/vision/facedet/contrib/ultraface.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace linzaer {
|
namespace facedet {
|
||||||
|
|
||||||
UltraFace::UltraFace(const std::string& model_file,
|
UltraFace::UltraFace(const std::string& model_file,
|
||||||
const std::string& params_file,
|
const std::string& params_file,
|
||||||
@@ -216,6 +216,6 @@ bool UltraFace::Predict(cv::Mat* im, FaceDetectionResult* result,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace linzaer
|
} // namespace facedet
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -21,7 +21,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace linzaer {
|
namespace facedet {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL UltraFace : public FastDeployModel {
|
class FASTDEPLOY_DECL UltraFace : public FastDeployModel {
|
||||||
public:
|
public:
|
||||||
@@ -79,6 +79,6 @@ class FASTDEPLOY_DECL UltraFace : public FastDeployModel {
|
|||||||
bool is_dynamic_input_;
|
bool is_dynamic_input_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace linzaer
|
} // namespace facedet
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -15,21 +15,17 @@
|
|||||||
#include "fastdeploy/pybind/main.h"
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
void BindLinzaer(pybind11::module& m) {
|
void BindUltraFace(pybind11::module& m) {
|
||||||
auto linzaer_module = m.def_submodule(
|
pybind11::class_<vision::facedet::UltraFace, FastDeployModel>(m, "UltraFace")
|
||||||
"linzaer",
|
|
||||||
"https://github.com/Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB");
|
|
||||||
pybind11::class_<vision::linzaer::UltraFace, FastDeployModel>(linzaer_module,
|
|
||||||
"UltraFace")
|
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
.def("predict",
|
.def("predict",
|
||||||
[](vision::linzaer::UltraFace& self, pybind11::array& data,
|
[](vision::facedet::UltraFace& self, pybind11::array& data,
|
||||||
float conf_threshold, float nms_iou_threshold) {
|
float conf_threshold, float nms_iou_threshold) {
|
||||||
auto mat = PyArrayToCvMat(data);
|
auto mat = PyArrayToCvMat(data);
|
||||||
vision::FaceDetectionResult res;
|
vision::FaceDetectionResult res;
|
||||||
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
.def_readwrite("size", &vision::linzaer::UltraFace::size);
|
.def_readwrite("size", &vision::facedet::UltraFace::size);
|
||||||
}
|
}
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/deepcam/yolov5face.h"
|
#include "fastdeploy/vision/facedet/contrib/yolov5face.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepcam {
|
namespace facedet {
|
||||||
|
|
||||||
void LetterBox(Mat* mat, std::vector<int> size, std::vector<float> color,
|
void LetterBox(Mat* mat, std::vector<int> size, std::vector<float> color,
|
||||||
bool _auto, bool scale_fill = false, bool scale_up = true,
|
bool _auto, bool scale_fill = false, bool scale_up = true,
|
||||||
@@ -289,6 +289,6 @@ bool YOLOv5Face::Predict(cv::Mat* im, FaceDetectionResult* result,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace deepcam
|
} // namespace facedet
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -21,7 +21,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepcam {
|
namespace facedet {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL YOLOv5Face : public FastDeployModel {
|
class FASTDEPLOY_DECL YOLOv5Face : public FastDeployModel {
|
||||||
public:
|
public:
|
||||||
@@ -32,7 +32,7 @@ class FASTDEPLOY_DECL YOLOv5Face : public FastDeployModel {
|
|||||||
const Frontend& model_format = Frontend::ONNX);
|
const Frontend& model_format = Frontend::ONNX);
|
||||||
|
|
||||||
// 定义模型的名称
|
// 定义模型的名称
|
||||||
std::string ModelName() const { return "deepcam-cn/yolov5-face"; }
|
std::string ModelName() const { return "yolov5-face"; }
|
||||||
|
|
||||||
// 模型预测接口,即用户调用的接口
|
// 模型预测接口,即用户调用的接口
|
||||||
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
|
||||||
@@ -92,6 +92,6 @@ class FASTDEPLOY_DECL YOLOv5Face : public FastDeployModel {
|
|||||||
bool is_dynamic_input_;
|
bool is_dynamic_input_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace deepcam
|
} // namespace facedet
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -15,29 +15,27 @@
|
|||||||
#include "fastdeploy/pybind/main.h"
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
void BindDeepCam(pybind11::module& m) {
|
void BindYOLOv5Face(pybind11::module& m) {
|
||||||
auto deepcam_module =
|
pybind11::class_<vision::facedet::YOLOv5Face, FastDeployModel>(m,
|
||||||
m.def_submodule("deepcam", "https://github.com/deepcam-cn/yolov5-face");
|
|
||||||
pybind11::class_<vision::deepcam::YOLOv5Face, FastDeployModel>(deepcam_module,
|
|
||||||
"YOLOv5Face")
|
"YOLOv5Face")
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
.def("predict",
|
.def("predict",
|
||||||
[](vision::deepcam::YOLOv5Face& self, pybind11::array& data,
|
[](vision::facedet::YOLOv5Face& self, pybind11::array& data,
|
||||||
float conf_threshold, float nms_iou_threshold) {
|
float conf_threshold, float nms_iou_threshold) {
|
||||||
auto mat = PyArrayToCvMat(data);
|
auto mat = PyArrayToCvMat(data);
|
||||||
vision::FaceDetectionResult res;
|
vision::FaceDetectionResult res;
|
||||||
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
.def_readwrite("size", &vision::deepcam::YOLOv5Face::size)
|
.def_readwrite("size", &vision::facedet::YOLOv5Face::size)
|
||||||
.def_readwrite("padding_value",
|
.def_readwrite("padding_value",
|
||||||
&vision::deepcam::YOLOv5Face::padding_value)
|
&vision::facedet::YOLOv5Face::padding_value)
|
||||||
.def_readwrite("is_mini_pad", &vision::deepcam::YOLOv5Face::is_mini_pad)
|
.def_readwrite("is_mini_pad", &vision::facedet::YOLOv5Face::is_mini_pad)
|
||||||
.def_readwrite("is_no_pad", &vision::deepcam::YOLOv5Face::is_no_pad)
|
.def_readwrite("is_no_pad", &vision::facedet::YOLOv5Face::is_no_pad)
|
||||||
.def_readwrite("is_scale_up", &vision::deepcam::YOLOv5Face::is_scale_up)
|
.def_readwrite("is_scale_up", &vision::facedet::YOLOv5Face::is_scale_up)
|
||||||
.def_readwrite("stride", &vision::deepcam::YOLOv5Face::stride)
|
.def_readwrite("stride", &vision::facedet::YOLOv5Face::stride)
|
||||||
.def_readwrite("landmarks_per_face",
|
.def_readwrite("landmarks_per_face",
|
||||||
&vision::deepcam::YOLOv5Face::landmarks_per_face);
|
&vision::facedet::YOLOv5Face::landmarks_per_face);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
31
csrcs/fastdeploy/vision/facedet/facedet_pybind.cc
Normal file
31
csrcs/fastdeploy/vision/facedet/facedet_pybind.cc
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
|
namespace fastdeploy {
|
||||||
|
|
||||||
|
void BindRetinaFace(pybind11::module& m);
|
||||||
|
void BindUltraFace(pybind11::module& m);
|
||||||
|
void BindYOLOv5Face(pybind11::module& m);
|
||||||
|
void BindSCRFD(pybind11::module& m);
|
||||||
|
|
||||||
|
void BindFaceDet(pybind11::module& m) {
|
||||||
|
auto facedet_module = m.def_submodule("facedet", "Face detection models.");
|
||||||
|
BindRetinaFace(facedet_module);
|
||||||
|
BindUltraFace(facedet_module);
|
||||||
|
BindYOLOv5Face(facedet_module);
|
||||||
|
BindSCRFD(facedet_module);
|
||||||
|
}
|
||||||
|
} // namespace fastdeploy
|
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/deepinsight/arcface.h"
|
#include "fastdeploy/vision/faceid/contrib/arcface.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepinsight {
|
namespace faceid {
|
||||||
|
|
||||||
ArcFace::ArcFace(const std::string& model_file, const std::string& params_file,
|
ArcFace::ArcFace(const std::string& model_file, const std::string& params_file,
|
||||||
const RuntimeOption& custom_option,
|
const RuntimeOption& custom_option,
|
||||||
@@ -78,6 +78,6 @@ bool ArcFace::Predict(cv::Mat* im, FaceRecognitionResult* result) {
|
|||||||
return InsightFaceRecognitionModel::Predict(im, result);
|
return InsightFaceRecognitionModel::Predict(im, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace deepinsight
|
} // namespace faceid
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -16,13 +16,13 @@
|
|||||||
#include "fastdeploy/fastdeploy_model.h"
|
#include "fastdeploy/fastdeploy_model.h"
|
||||||
#include "fastdeploy/vision/common/processors/transform.h"
|
#include "fastdeploy/vision/common/processors/transform.h"
|
||||||
#include "fastdeploy/vision/common/result.h"
|
#include "fastdeploy/vision/common/result.h"
|
||||||
#include "fastdeploy/vision/deepinsight/insightface_rec.h"
|
#include "fastdeploy/vision/faceid/contrib/insightface_rec.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepinsight {
|
namespace faceid {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL ArcFace : public InsightFaceRecognitionModel {
|
class FASTDEPLOY_DECL ArcFace : public InsightFaceRecognitionModel {
|
||||||
public:
|
public:
|
||||||
@@ -60,6 +60,6 @@ class FASTDEPLOY_DECL ArcFace : public InsightFaceRecognitionModel {
|
|||||||
FaceRecognitionResult* result) override;
|
FaceRecognitionResult* result) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace deepinsight
|
} // namespace faceid
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
37
csrcs/fastdeploy/vision/faceid/contrib/arcface_pybind.cc
Normal file
37
csrcs/fastdeploy/vision/faceid/contrib/arcface_pybind.cc
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
|
namespace fastdeploy {
|
||||||
|
void BindArcFace(pybind11::module& m) {
|
||||||
|
// Bind ArcFace
|
||||||
|
pybind11::class_<vision::faceid::ArcFace,
|
||||||
|
vision::faceid::InsightFaceRecognitionModel>(m, "ArcFace")
|
||||||
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
|
.def("predict",
|
||||||
|
[](vision::faceid::ArcFace& self, pybind11::array& data) {
|
||||||
|
auto mat = PyArrayToCvMat(data);
|
||||||
|
vision::FaceRecognitionResult res;
|
||||||
|
self.Predict(&mat, &res);
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.def_readwrite("size", &vision::faceid::ArcFace::size)
|
||||||
|
.def_readwrite("alpha", &vision::faceid::ArcFace::alpha)
|
||||||
|
.def_readwrite("beta", &vision::faceid::ArcFace::beta)
|
||||||
|
.def_readwrite("swap_rb", &vision::faceid::ArcFace::swap_rb)
|
||||||
|
.def_readwrite("l2_normalize", &vision::faceid::ArcFace::l2_normalize);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace fastdeploy
|
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/deepinsight/cosface.h"
|
#include "fastdeploy/vision/faceid/contrib/cosface.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepinsight {
|
namespace faceid {
|
||||||
|
|
||||||
CosFace::CosFace(const std::string& model_file, const std::string& params_file,
|
CosFace::CosFace(const std::string& model_file, const std::string& params_file,
|
||||||
const RuntimeOption& custom_option,
|
const RuntimeOption& custom_option,
|
||||||
@@ -78,6 +78,6 @@ bool CosFace::Predict(cv::Mat* im, FaceRecognitionResult* result) {
|
|||||||
return InsightFaceRecognitionModel::Predict(im, result);
|
return InsightFaceRecognitionModel::Predict(im, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace deepinsight
|
} // namespace faceid
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -16,13 +16,13 @@
|
|||||||
#include "fastdeploy/fastdeploy_model.h"
|
#include "fastdeploy/fastdeploy_model.h"
|
||||||
#include "fastdeploy/vision/common/processors/transform.h"
|
#include "fastdeploy/vision/common/processors/transform.h"
|
||||||
#include "fastdeploy/vision/common/result.h"
|
#include "fastdeploy/vision/common/result.h"
|
||||||
#include "fastdeploy/vision/deepinsight/insightface_rec.h"
|
#include "fastdeploy/vision/faceid/contrib/insightface_rec.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepinsight {
|
namespace faceid {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL CosFace : public InsightFaceRecognitionModel {
|
class FASTDEPLOY_DECL CosFace : public InsightFaceRecognitionModel {
|
||||||
public:
|
public:
|
||||||
@@ -61,6 +61,6 @@ class FASTDEPLOY_DECL CosFace : public InsightFaceRecognitionModel {
|
|||||||
FaceRecognitionResult* result) override;
|
FaceRecognitionResult* result) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace deepinsight
|
} // namespace faceid
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
37
csrcs/fastdeploy/vision/faceid/contrib/cosface_pybind.cc
Normal file
37
csrcs/fastdeploy/vision/faceid/contrib/cosface_pybind.cc
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
|
namespace fastdeploy {
|
||||||
|
void BindCosFace(pybind11::module& m) {
|
||||||
|
// Bind CosFace
|
||||||
|
pybind11::class_<vision::faceid::CosFace,
|
||||||
|
vision::faceid::InsightFaceRecognitionModel>(m, "CosFace")
|
||||||
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
|
.def("predict",
|
||||||
|
[](vision::faceid::CosFace& self, pybind11::array& data) {
|
||||||
|
auto mat = PyArrayToCvMat(data);
|
||||||
|
vision::FaceRecognitionResult res;
|
||||||
|
self.Predict(&mat, &res);
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.def_readwrite("size", &vision::faceid::CosFace::size)
|
||||||
|
.def_readwrite("alpha", &vision::faceid::CosFace::alpha)
|
||||||
|
.def_readwrite("beta", &vision::faceid::CosFace::beta)
|
||||||
|
.def_readwrite("swap_rb", &vision::faceid::CosFace::swap_rb)
|
||||||
|
.def_readwrite("l2_normalize", &vision::faceid::CosFace::l2_normalize);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace fastdeploy
|
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/deepinsight/insightface_rec.h"
|
#include "fastdeploy/vision/faceid/contrib/insightface_rec.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepinsight {
|
namespace faceid {
|
||||||
|
|
||||||
InsightFaceRecognitionModel::InsightFaceRecognitionModel(
|
InsightFaceRecognitionModel::InsightFaceRecognitionModel(
|
||||||
const std::string& model_file, const std::string& params_file,
|
const std::string& model_file, const std::string& params_file,
|
||||||
@@ -148,6 +148,6 @@ bool InsightFaceRecognitionModel::Predict(cv::Mat* im,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace deepinsight
|
} // namespace faceid
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -21,7 +21,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepinsight {
|
namespace faceid {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL InsightFaceRecognitionModel : public FastDeployModel {
|
class FASTDEPLOY_DECL InsightFaceRecognitionModel : public FastDeployModel {
|
||||||
public:
|
public:
|
||||||
@@ -67,6 +67,6 @@ class FASTDEPLOY_DECL InsightFaceRecognitionModel : public FastDeployModel {
|
|||||||
FaceRecognitionResult* result);
|
FaceRecognitionResult* result);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace deepinsight
|
} // namespace faceid
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
|
namespace fastdeploy {
|
||||||
|
void BindInsightFaceRecognitionModel(pybind11::module& m) {
|
||||||
|
// Bind InsightFaceRecognitionModel
|
||||||
|
pybind11::class_<vision::faceid::InsightFaceRecognitionModel,
|
||||||
|
FastDeployModel>(m, "InsightFaceRecognitionModel")
|
||||||
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
|
.def("predict",
|
||||||
|
[](vision::faceid::InsightFaceRecognitionModel& self,
|
||||||
|
pybind11::array& data) {
|
||||||
|
auto mat = PyArrayToCvMat(data);
|
||||||
|
vision::FaceRecognitionResult res;
|
||||||
|
self.Predict(&mat, &res);
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.def_readwrite("size", &vision::faceid::InsightFaceRecognitionModel::size)
|
||||||
|
.def_readwrite("alpha",
|
||||||
|
&vision::faceid::InsightFaceRecognitionModel::alpha)
|
||||||
|
.def_readwrite("beta", &vision::faceid::InsightFaceRecognitionModel::beta)
|
||||||
|
.def_readwrite("swap_rb",
|
||||||
|
&vision::faceid::InsightFaceRecognitionModel::swap_rb)
|
||||||
|
.def_readwrite(
|
||||||
|
"l2_normalize",
|
||||||
|
&vision::faceid::InsightFaceRecognitionModel::l2_normalize);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace fastdeploy
|
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/deepinsight/partial_fc.h"
|
#include "fastdeploy/vision/faceid/contrib/partial_fc.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepinsight {
|
namespace faceid {
|
||||||
|
|
||||||
PartialFC::PartialFC(const std::string& model_file,
|
PartialFC::PartialFC(const std::string& model_file,
|
||||||
const std::string& params_file,
|
const std::string& params_file,
|
||||||
@@ -79,6 +79,6 @@ bool PartialFC::Predict(cv::Mat* im, FaceRecognitionResult* result) {
|
|||||||
return InsightFaceRecognitionModel::Predict(im, result);
|
return InsightFaceRecognitionModel::Predict(im, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace deepinsight
|
} // namespace faceid
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -16,13 +16,13 @@
|
|||||||
#include "fastdeploy/fastdeploy_model.h"
|
#include "fastdeploy/fastdeploy_model.h"
|
||||||
#include "fastdeploy/vision/common/processors/transform.h"
|
#include "fastdeploy/vision/common/processors/transform.h"
|
||||||
#include "fastdeploy/vision/common/result.h"
|
#include "fastdeploy/vision/common/result.h"
|
||||||
#include "fastdeploy/vision/deepinsight/insightface_rec.h"
|
#include "fastdeploy/vision/faceid/contrib/insightface_rec.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepinsight {
|
namespace faceid {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL PartialFC : public InsightFaceRecognitionModel {
|
class FASTDEPLOY_DECL PartialFC : public InsightFaceRecognitionModel {
|
||||||
public:
|
public:
|
||||||
@@ -59,6 +59,6 @@ class FASTDEPLOY_DECL PartialFC : public InsightFaceRecognitionModel {
|
|||||||
FaceRecognitionResult* result) override;
|
FaceRecognitionResult* result) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace deepinsight
|
} // namespace faceid
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
37
csrcs/fastdeploy/vision/faceid/contrib/partial_fc_pybind.cc
Normal file
37
csrcs/fastdeploy/vision/faceid/contrib/partial_fc_pybind.cc
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
|
namespace fastdeploy {
|
||||||
|
void BindPartialFC(pybind11::module& m) {
|
||||||
|
// Bind Partial FC
|
||||||
|
pybind11::class_<vision::faceid::PartialFC,
|
||||||
|
vision::faceid::InsightFaceRecognitionModel>(m, "PartialFC")
|
||||||
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
|
.def("predict",
|
||||||
|
[](vision::faceid::PartialFC& self, pybind11::array& data) {
|
||||||
|
auto mat = PyArrayToCvMat(data);
|
||||||
|
vision::FaceRecognitionResult res;
|
||||||
|
self.Predict(&mat, &res);
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.def_readwrite("size", &vision::faceid::PartialFC::size)
|
||||||
|
.def_readwrite("alpha", &vision::faceid::PartialFC::alpha)
|
||||||
|
.def_readwrite("beta", &vision::faceid::PartialFC::beta)
|
||||||
|
.def_readwrite("swap_rb", &vision::faceid::PartialFC::swap_rb)
|
||||||
|
.def_readwrite("l2_normalize", &vision::faceid::PartialFC::l2_normalize);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace fastdeploy
|
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/deepinsight/vpl.h"
|
#include "fastdeploy/vision/faceid/contrib/vpl.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepinsight {
|
namespace faceid {
|
||||||
|
|
||||||
VPL::VPL(const std::string& model_file, const std::string& params_file,
|
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 Frontend& model_format)
|
||||||
@@ -77,6 +77,6 @@ bool VPL::Predict(cv::Mat* im, FaceRecognitionResult* result) {
|
|||||||
return InsightFaceRecognitionModel::Predict(im, result);
|
return InsightFaceRecognitionModel::Predict(im, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace deepinsight
|
} // namespace faceid
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -16,13 +16,13 @@
|
|||||||
#include "fastdeploy/fastdeploy_model.h"
|
#include "fastdeploy/fastdeploy_model.h"
|
||||||
#include "fastdeploy/vision/common/processors/transform.h"
|
#include "fastdeploy/vision/common/processors/transform.h"
|
||||||
#include "fastdeploy/vision/common/result.h"
|
#include "fastdeploy/vision/common/result.h"
|
||||||
#include "fastdeploy/vision/deepinsight/insightface_rec.h"
|
#include "fastdeploy/vision/faceid/contrib/insightface_rec.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace deepinsight {
|
namespace faceid {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL VPL : public InsightFaceRecognitionModel {
|
class FASTDEPLOY_DECL VPL : public InsightFaceRecognitionModel {
|
||||||
public:
|
public:
|
||||||
@@ -60,6 +60,6 @@ class FASTDEPLOY_DECL VPL : public InsightFaceRecognitionModel {
|
|||||||
FaceRecognitionResult* result) override;
|
FaceRecognitionResult* result) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace deepinsight
|
} // namespace faceid
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
37
csrcs/fastdeploy/vision/faceid/contrib/vpl_pybind.cc
Normal file
37
csrcs/fastdeploy/vision/faceid/contrib/vpl_pybind.cc
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
|
namespace fastdeploy {
|
||||||
|
void BindVPL(pybind11::module& m) {
|
||||||
|
// Bind VPL
|
||||||
|
pybind11::class_<vision::faceid::VPL,
|
||||||
|
vision::faceid::InsightFaceRecognitionModel>(m, "VPL")
|
||||||
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
|
.def("predict",
|
||||||
|
[](vision::faceid::VPL& self, pybind11::array& data) {
|
||||||
|
auto mat = PyArrayToCvMat(data);
|
||||||
|
vision::FaceRecognitionResult res;
|
||||||
|
self.Predict(&mat, &res);
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.def_readwrite("size", &vision::faceid::VPL::size)
|
||||||
|
.def_readwrite("alpha", &vision::faceid::VPL::alpha)
|
||||||
|
.def_readwrite("beta", &vision::faceid::VPL::beta)
|
||||||
|
.def_readwrite("swap_rb", &vision::faceid::VPL::swap_rb)
|
||||||
|
.def_readwrite("l2_normalize", &vision::faceid::VPL::l2_normalize);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace fastdeploy
|
33
csrcs/fastdeploy/vision/faceid/faceid_pybind.cc
Normal file
33
csrcs/fastdeploy/vision/faceid/faceid_pybind.cc
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
|
namespace fastdeploy {
|
||||||
|
|
||||||
|
void BindArcFace(pybind11::module& m);
|
||||||
|
void BindInsightFaceRecognitionModel(pybind11::module& m);
|
||||||
|
void BindCosFace(pybind11::module& m);
|
||||||
|
void BindPartialFC(pybind11::module& m);
|
||||||
|
void BindVPL(pybind11::module& m);
|
||||||
|
|
||||||
|
void BindFaceId(pybind11::module& m) {
|
||||||
|
auto faceid_module = m.def_submodule("faceid", "Face recognition models.");
|
||||||
|
BindInsightFaceRecognitionModel(faceid_module);
|
||||||
|
BindArcFace(faceid_module);
|
||||||
|
BindCosFace(faceid_module);
|
||||||
|
BindPartialFC(faceid_module);
|
||||||
|
BindVPL(faceid_module);
|
||||||
|
}
|
||||||
|
} // namespace fastdeploy
|
@@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "fastdeploy/vision/zhkkke/modnet.h"
|
#include "fastdeploy/vision/matting/contrib/modnet.h"
|
||||||
#include "fastdeploy/utils/perf.h"
|
#include "fastdeploy/utils/perf.h"
|
||||||
#include "fastdeploy/vision/utils/utils.h"
|
#include "fastdeploy/vision/utils/utils.h"
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace zhkkke {
|
namespace matting {
|
||||||
|
|
||||||
MODNet::MODNet(const std::string& model_file, const std::string& params_file,
|
MODNet::MODNet(const std::string& model_file, const std::string& params_file,
|
||||||
const RuntimeOption& custom_option,
|
const RuntimeOption& custom_option,
|
||||||
@@ -170,6 +170,6 @@ bool MODNet::Predict(cv::Mat* im, MattingResult* result) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace zhkkke
|
} // namespace matting
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -21,7 +21,7 @@ namespace fastdeploy {
|
|||||||
|
|
||||||
namespace vision {
|
namespace vision {
|
||||||
|
|
||||||
namespace zhkkke {
|
namespace matting {
|
||||||
|
|
||||||
class FASTDEPLOY_DECL MODNet : public FastDeployModel {
|
class FASTDEPLOY_DECL MODNet : public FastDeployModel {
|
||||||
public:
|
public:
|
||||||
@@ -32,7 +32,7 @@ class FASTDEPLOY_DECL MODNet : public FastDeployModel {
|
|||||||
const Frontend& model_format = Frontend::ONNX);
|
const Frontend& model_format = Frontend::ONNX);
|
||||||
|
|
||||||
// 定义模型的名称
|
// 定义模型的名称
|
||||||
std::string ModelName() const { return "ZHKKKe/MODNet"; }
|
std::string ModelName() const { return "matting/MODNet"; }
|
||||||
|
|
||||||
// 以下为一些可供用户修改的属性
|
// 以下为一些可供用户修改的属性
|
||||||
// tuple of (width, height), default (256, 256)
|
// tuple of (width, height), default (256, 256)
|
||||||
@@ -65,6 +65,6 @@ class FASTDEPLOY_DECL MODNet : public FastDeployModel {
|
|||||||
const std::map<std::string, std::array<int, 2>>& im_info);
|
const std::map<std::string, std::array<int, 2>>& im_info);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace zhkkke
|
} // namespace matting
|
||||||
} // namespace vision
|
} // namespace vision
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
@@ -15,23 +15,21 @@
|
|||||||
#include "fastdeploy/pybind/main.h"
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
namespace fastdeploy {
|
namespace fastdeploy {
|
||||||
void BindZHKKKe(pybind11::module& m) {
|
void BindMODNet(pybind11::module& m) {
|
||||||
auto zhkkke_module = m.def_submodule("zhkkke", "https://github.com/ZHKKKe");
|
|
||||||
// Bind MODNet
|
// Bind MODNet
|
||||||
pybind11::class_<vision::zhkkke::MODNet, FastDeployModel>(zhkkke_module,
|
pybind11::class_<vision::matting::MODNet, FastDeployModel>(m, "MODNet")
|
||||||
"MODNet")
|
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
||||||
.def("predict",
|
.def("predict",
|
||||||
[](vision::zhkkke::MODNet& self, pybind11::array& data) {
|
[](vision::matting::MODNet& self, pybind11::array& data) {
|
||||||
auto mat = PyArrayToCvMat(data);
|
auto mat = PyArrayToCvMat(data);
|
||||||
vision::MattingResult res;
|
vision::MattingResult res;
|
||||||
self.Predict(&mat, &res);
|
self.Predict(&mat, &res);
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
.def_readwrite("size", &vision::zhkkke::MODNet::size)
|
.def_readwrite("size", &vision::matting::MODNet::size)
|
||||||
.def_readwrite("alpha", &vision::zhkkke::MODNet::alpha)
|
.def_readwrite("alpha", &vision::matting::MODNet::alpha)
|
||||||
.def_readwrite("beta", &vision::zhkkke::MODNet::beta)
|
.def_readwrite("beta", &vision::matting::MODNet::beta)
|
||||||
.def_readwrite("swap_rb", &vision::zhkkke::MODNet::swap_rb);
|
.def_readwrite("swap_rb", &vision::matting::MODNet::swap_rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace fastdeploy
|
} // namespace fastdeploy
|
26
csrcs/fastdeploy/vision/matting/matting_pybind.cc
Normal file
26
csrcs/fastdeploy/vision/matting/matting_pybind.cc
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "fastdeploy/pybind/main.h"
|
||||||
|
|
||||||
|
namespace fastdeploy {
|
||||||
|
|
||||||
|
void BindMODNet(pybind11::module& m);
|
||||||
|
|
||||||
|
void BindMatting(pybind11::module& m) {
|
||||||
|
auto matting_module =
|
||||||
|
m.def_submodule("matting", "Image object matting models.");
|
||||||
|
BindMODNet(matting_module);
|
||||||
|
}
|
||||||
|
} // namespace fastdeploy
|
@@ -1,42 +0,0 @@
|
|||||||
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include "fastdeploy/pybind/main.h"
|
|
||||||
|
|
||||||
namespace fastdeploy {
|
|
||||||
void BindUltralytics(pybind11::module& m) {
|
|
||||||
auto ultralytics_module =
|
|
||||||
m.def_submodule("ultralytics", "https://github.com/ultralytics/yolov5");
|
|
||||||
pybind11::class_<vision::ultralytics::YOLOv5, FastDeployModel>(
|
|
||||||
ultralytics_module, "YOLOv5")
|
|
||||||
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
|
|
||||||
.def("predict",
|
|
||||||
[](vision::ultralytics::YOLOv5& self, pybind11::array& data,
|
|
||||||
float conf_threshold, float nms_iou_threshold) {
|
|
||||||
auto mat = PyArrayToCvMat(data);
|
|
||||||
vision::DetectionResult res;
|
|
||||||
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
.def_readwrite("size", &vision::ultralytics::YOLOv5::size)
|
|
||||||
.def_readwrite("padding_value",
|
|
||||||
&vision::ultralytics::YOLOv5::padding_value)
|
|
||||||
.def_readwrite("is_mini_pad", &vision::ultralytics::YOLOv5::is_mini_pad)
|
|
||||||
.def_readwrite("is_no_pad", &vision::ultralytics::YOLOv5::is_no_pad)
|
|
||||||
.def_readwrite("is_scale_up", &vision::ultralytics::YOLOv5::is_scale_up)
|
|
||||||
.def_readwrite("stride", &vision::ultralytics::YOLOv5::stride)
|
|
||||||
.def_readwrite("max_wh", &vision::ultralytics::YOLOv5::max_wh)
|
|
||||||
.def_readwrite("multi_label", &vision::ultralytics::YOLOv5::multi_label);
|
|
||||||
}
|
|
||||||
} // namespace fastdeploy
|
|
@@ -19,18 +19,11 @@ namespace fastdeploy {
|
|||||||
void BindPPCls(pybind11::module& m);
|
void BindPPCls(pybind11::module& m);
|
||||||
void BindPPDet(pybind11::module& m);
|
void BindPPDet(pybind11::module& m);
|
||||||
void BindPPSeg(pybind11::module& m);
|
void BindPPSeg(pybind11::module& m);
|
||||||
void BindUltralytics(pybind11::module& m);
|
|
||||||
void BindMeituan(pybind11::module& m);
|
|
||||||
void BindMegvii(pybind11::module& m);
|
|
||||||
void BindDeepCam(pybind11::module& m);
|
|
||||||
void BindRangiLyu(pybind11::module& m);
|
|
||||||
void BindLinzaer(pybind11::module& m);
|
|
||||||
void BindBiubug6(pybind11::module& m);
|
|
||||||
void BindPpogg(pybind11::module& m);
|
|
||||||
void BindDeepInsight(pybind11::module& m);
|
|
||||||
void BindZHKKKe(pybind11::module& m);
|
|
||||||
|
|
||||||
void BindDetection(pybind11::module& m);
|
void BindDetection(pybind11::module& m);
|
||||||
|
void BindMatting(pybind11::module& m);
|
||||||
|
void BindFaceDet(pybind11::module& m);
|
||||||
|
void BindFaceId(pybind11::module& m);
|
||||||
#ifdef ENABLE_VISION_VISUALIZE
|
#ifdef ENABLE_VISION_VISUALIZE
|
||||||
void BindVisualize(pybind11::module& m);
|
void BindVisualize(pybind11::module& m);
|
||||||
#endif
|
#endif
|
||||||
@@ -88,18 +81,11 @@ void BindVision(pybind11::module& m) {
|
|||||||
BindPPCls(m);
|
BindPPCls(m);
|
||||||
BindPPDet(m);
|
BindPPDet(m);
|
||||||
BindPPSeg(m);
|
BindPPSeg(m);
|
||||||
BindUltralytics(m);
|
|
||||||
BindMeituan(m);
|
|
||||||
BindMegvii(m);
|
|
||||||
BindDeepCam(m);
|
|
||||||
BindRangiLyu(m);
|
|
||||||
BindLinzaer(m);
|
|
||||||
BindBiubug6(m);
|
|
||||||
BindPpogg(m);
|
|
||||||
BindDeepInsight(m);
|
|
||||||
BindZHKKKe(m);
|
|
||||||
|
|
||||||
BindDetection(m);
|
BindDetection(m);
|
||||||
|
BindFaceDet(m);
|
||||||
|
BindFaceId(m);
|
||||||
|
BindMatting(m);
|
||||||
#ifdef ENABLE_VISION_VISUALIZE
|
#ifdef ENABLE_VISION_VISUALIZE
|
||||||
BindVisualize(m);
|
BindVisualize(m);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -26,10 +26,10 @@ class FASTDEPLOY_DECL Visualize {
|
|||||||
static std::vector<int> color_map_;
|
static std::vector<int> color_map_;
|
||||||
static const std::vector<int>& GetColorMap(int num_classes = 1000);
|
static const std::vector<int>& GetColorMap(int num_classes = 1000);
|
||||||
static cv::Mat VisDetection(const cv::Mat& im, const DetectionResult& result,
|
static cv::Mat VisDetection(const cv::Mat& im, const DetectionResult& result,
|
||||||
int line_size = 2, float font_size = 0.5f);
|
int line_size = 1, float font_size = 0.5f);
|
||||||
static cv::Mat VisFaceDetection(const cv::Mat& im,
|
static cv::Mat VisFaceDetection(const cv::Mat& im,
|
||||||
const FaceDetectionResult& result,
|
const FaceDetectionResult& result,
|
||||||
int line_size = 2, float font_size = 0.5f);
|
int line_size = 1, float font_size = 0.5f);
|
||||||
static cv::Mat VisSegmentation(const cv::Mat& im,
|
static cv::Mat VisSegmentation(const cv::Mat& im,
|
||||||
const SegmentationResult& result);
|
const SegmentationResult& result);
|
||||||
static cv::Mat VisMattingAlpha(const cv::Mat& im, const MattingResult& result,
|
static cv::Mat VisMattingAlpha(const cv::Mat& im, const MattingResult& result,
|
||||||
|
@@ -13,21 +13,9 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from . import evaluation
|
|
||||||
from . import ppcls
|
|
||||||
from . import ppdet
|
|
||||||
from . import ppseg
|
|
||||||
from . import ultralytics
|
|
||||||
from . import meituan
|
|
||||||
from . import megvii
|
|
||||||
from . import deepcam
|
|
||||||
from . import rangilyu
|
|
||||||
from . import linzaer
|
|
||||||
from . import biubug6
|
|
||||||
from . import ppogg
|
|
||||||
from . import deepinsight
|
|
||||||
from . import zhkkke
|
|
||||||
|
|
||||||
from . import detection
|
from . import detection
|
||||||
|
from . import matting
|
||||||
|
from . import facedet
|
||||||
|
from . import faceid
|
||||||
|
|
||||||
from .visualize import *
|
from .visualize import *
|
||||||
|
@@ -1,563 +0,0 @@
|
|||||||
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
import logging
|
|
||||||
from ... import FastDeployModel, Frontend
|
|
||||||
from ... import c_lib_wrap as C
|
|
||||||
|
|
||||||
|
|
||||||
class SCRFD(FastDeployModel):
|
|
||||||
def __init__(self,
|
|
||||||
model_file,
|
|
||||||
params_file="",
|
|
||||||
runtime_option=None,
|
|
||||||
model_format=Frontend.ONNX):
|
|
||||||
# 调用基函数进行backend_option的初始化
|
|
||||||
# 初始化后的option保存在self._runtime_option
|
|
||||||
super(SCRFD, self).__init__(runtime_option)
|
|
||||||
|
|
||||||
self._model = C.vision.deepinsight.SCRFD(
|
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
|
||||||
assert self.initialized, "SCRFD initialize failed."
|
|
||||||
|
|
||||||
def predict(self, input_image, conf_threshold=0.7, nms_iou_threshold=0.3):
|
|
||||||
return self._model.predict(input_image, conf_threshold,
|
|
||||||
nms_iou_threshold)
|
|
||||||
|
|
||||||
# 一些跟SCRFD模型有关的属性封装
|
|
||||||
# 多数是预处理相关,可通过修改如model.size = [640, 640]改变预处理时resize的大小(前提是模型支持)
|
|
||||||
@property
|
|
||||||
def size(self):
|
|
||||||
return self._model.size
|
|
||||||
|
|
||||||
@property
|
|
||||||
def padding_value(self):
|
|
||||||
return self._model.padding_value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_no_pad(self):
|
|
||||||
return self._model.is_no_pad
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_mini_pad(self):
|
|
||||||
return self._model.is_mini_pad
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_scale_up(self):
|
|
||||||
return self._model.is_scale_up
|
|
||||||
|
|
||||||
@property
|
|
||||||
def stride(self):
|
|
||||||
return self._model.stride
|
|
||||||
|
|
||||||
@property
|
|
||||||
def downsample_strides(self):
|
|
||||||
return self._model.downsample_strides
|
|
||||||
|
|
||||||
@property
|
|
||||||
def landmarks_per_face(self):
|
|
||||||
return self._model.landmarks_per_face
|
|
||||||
|
|
||||||
@property
|
|
||||||
def use_kps(self):
|
|
||||||
return self._model.use_kps
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_nms(self):
|
|
||||||
return self._model.max_nms
|
|
||||||
|
|
||||||
@property
|
|
||||||
def num_anchors(self):
|
|
||||||
return self._model.num_anchors
|
|
||||||
|
|
||||||
@size.setter
|
|
||||||
def size(self, wh):
|
|
||||||
assert isinstance(wh, (list, tuple)),\
|
|
||||||
"The value to set `size` must be type of tuple or list."
|
|
||||||
assert len(wh) == 2,\
|
|
||||||
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
|
||||||
len(wh))
|
|
||||||
self._model.size = wh
|
|
||||||
|
|
||||||
@padding_value.setter
|
|
||||||
def padding_value(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value,
|
|
||||||
list), "The value to set `padding_value` must be type of list."
|
|
||||||
self._model.padding_value = value
|
|
||||||
|
|
||||||
@is_no_pad.setter
|
|
||||||
def is_no_pad(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, bool), "The value to set `is_no_pad` must be type of bool."
|
|
||||||
self._model.is_no_pad = value
|
|
||||||
|
|
||||||
@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."
|
|
||||||
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."
|
|
||||||
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."
|
|
||||||
self._model.stride = value
|
|
||||||
|
|
||||||
@downsample_strides.setter
|
|
||||||
def downsample_strides(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value,
|
|
||||||
list), "The value to set `downsample_strides` must be type of list."
|
|
||||||
self._model.downsample_strides = value
|
|
||||||
|
|
||||||
@landmarks_per_face.setter
|
|
||||||
def landmarks_per_face(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value,
|
|
||||||
int), "The value to set `landmarks_per_face` must be type of int."
|
|
||||||
self._model.landmarks_per_face = value
|
|
||||||
|
|
||||||
@use_kps.setter
|
|
||||||
def use_kps(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, bool), "The value to set `use_kps` must be type of bool."
|
|
||||||
self._model.use_kps = value
|
|
||||||
|
|
||||||
@max_nms.setter
|
|
||||||
def max_nms(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, int), "The value to set `max_nms` must be type of int."
|
|
||||||
self._model.max_nms = value
|
|
||||||
|
|
||||||
@num_anchors.setter
|
|
||||||
def num_anchors(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, int), "The value to set `num_anchors` must be type of int."
|
|
||||||
self._model.num_anchors = value
|
|
||||||
|
|
||||||
|
|
||||||
class InsightFaceRecognitionModel(FastDeployModel):
|
|
||||||
def __init__(self,
|
|
||||||
model_file,
|
|
||||||
params_file="",
|
|
||||||
runtime_option=None,
|
|
||||||
model_format=Frontend.ONNX):
|
|
||||||
# 调用基函数进行backend_option的初始化
|
|
||||||
# 初始化后的option保存在self._runtime_option
|
|
||||||
super(InsightFaceRecognitionModel, self).__init__(runtime_option)
|
|
||||||
|
|
||||||
self._model = C.vision.deepinsight.InsightFaceRecognitionModel(
|
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
|
||||||
assert self.initialized, "InsightFaceRecognitionModel initialize failed."
|
|
||||||
|
|
||||||
def predict(self, input_image):
|
|
||||||
return self._model.predict(input_image)
|
|
||||||
|
|
||||||
# 一些跟InsightFaceRecognitionModel模型有关的属性封装
|
|
||||||
# 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持)
|
|
||||||
@property
|
|
||||||
def size(self):
|
|
||||||
return self._model.size
|
|
||||||
|
|
||||||
@property
|
|
||||||
def alpha(self):
|
|
||||||
return self._model.alpha
|
|
||||||
|
|
||||||
@property
|
|
||||||
def beta(self):
|
|
||||||
return self._model.beta
|
|
||||||
|
|
||||||
@property
|
|
||||||
def swap_rb(self):
|
|
||||||
return self._model.swap_rb
|
|
||||||
|
|
||||||
@property
|
|
||||||
def l2_normalize(self):
|
|
||||||
return self._model.l2_normalize
|
|
||||||
|
|
||||||
@size.setter
|
|
||||||
def size(self, wh):
|
|
||||||
assert isinstance(wh, (list, tuple)),\
|
|
||||||
"The value to set `size` must be type of tuple or list."
|
|
||||||
assert len(wh) == 2,\
|
|
||||||
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
|
||||||
len(wh))
|
|
||||||
self._model.size = wh
|
|
||||||
|
|
||||||
@alpha.setter
|
|
||||||
def alpha(self, value):
|
|
||||||
assert isinstance(value, (list, tuple)),\
|
|
||||||
"The value to set `alpha` must be type of tuple or list."
|
|
||||||
assert len(value) == 3,\
|
|
||||||
"The value to set `alpha` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
|
||||||
len(value))
|
|
||||||
self._model.alpha = value
|
|
||||||
|
|
||||||
@beta.setter
|
|
||||||
def beta(self, value):
|
|
||||||
assert isinstance(value, (list, tuple)),\
|
|
||||||
"The value to set `beta` must be type of tuple or list."
|
|
||||||
assert len(value) == 3,\
|
|
||||||
"The value to set `beta` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
|
||||||
len(value))
|
|
||||||
self._model.beta = value
|
|
||||||
|
|
||||||
@swap_rb.setter
|
|
||||||
def swap_rb(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, bool), "The value to set `swap_rb` must be type of bool."
|
|
||||||
self._model.swap_rb = value
|
|
||||||
|
|
||||||
@l2_normalize.setter
|
|
||||||
def l2_normalize(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value,
|
|
||||||
bool), "The value to set `l2_normalize` must be type of bool."
|
|
||||||
self._model.l2_normalize = value
|
|
||||||
|
|
||||||
|
|
||||||
class ArcFace(FastDeployModel):
|
|
||||||
def __init__(self,
|
|
||||||
model_file,
|
|
||||||
params_file="",
|
|
||||||
runtime_option=None,
|
|
||||||
model_format=Frontend.ONNX):
|
|
||||||
# 调用基函数进行backend_option的初始化
|
|
||||||
# 初始化后的option保存在self._runtime_option
|
|
||||||
super(ArcFace, self).__init__(runtime_option)
|
|
||||||
|
|
||||||
self._model = C.vision.deepinsight.ArcFace(
|
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
|
||||||
assert self.initialized, "ArcFace initialize failed."
|
|
||||||
|
|
||||||
def predict(self, input_image):
|
|
||||||
return self._model.predict(input_image)
|
|
||||||
|
|
||||||
# 一些跟模型有关的属性封装
|
|
||||||
# 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持)
|
|
||||||
@property
|
|
||||||
def size(self):
|
|
||||||
return self._model.size
|
|
||||||
|
|
||||||
@property
|
|
||||||
def alpha(self):
|
|
||||||
return self._model.alpha
|
|
||||||
|
|
||||||
@property
|
|
||||||
def beta(self):
|
|
||||||
return self._model.beta
|
|
||||||
|
|
||||||
@property
|
|
||||||
def swap_rb(self):
|
|
||||||
return self._model.swap_rb
|
|
||||||
|
|
||||||
@property
|
|
||||||
def l2_normalize(self):
|
|
||||||
return self._model.l2_normalize
|
|
||||||
|
|
||||||
@size.setter
|
|
||||||
def size(self, wh):
|
|
||||||
assert isinstance(wh, (list, tuple)),\
|
|
||||||
"The value to set `size` must be type of tuple or list."
|
|
||||||
assert len(wh) == 2,\
|
|
||||||
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
|
||||||
len(wh))
|
|
||||||
self._model.size = wh
|
|
||||||
|
|
||||||
@alpha.setter
|
|
||||||
def alpha(self, value):
|
|
||||||
assert isinstance(value, (list, tuple)),\
|
|
||||||
"The value to set `alpha` must be type of tuple or list."
|
|
||||||
assert len(value) == 3,\
|
|
||||||
"The value to set `alpha` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
|
||||||
len(value))
|
|
||||||
self._model.alpha = value
|
|
||||||
|
|
||||||
@beta.setter
|
|
||||||
def beta(self, value):
|
|
||||||
assert isinstance(value, (list, tuple)),\
|
|
||||||
"The value to set `beta` must be type of tuple or list."
|
|
||||||
assert len(value) == 3,\
|
|
||||||
"The value to set `beta` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
|
||||||
len(value))
|
|
||||||
self._model.beta = value
|
|
||||||
|
|
||||||
@swap_rb.setter
|
|
||||||
def swap_rb(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, bool), "The value to set `swap_rb` must be type of bool."
|
|
||||||
self._model.swap_rb = value
|
|
||||||
|
|
||||||
@l2_normalize.setter
|
|
||||||
def l2_normalize(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value,
|
|
||||||
bool), "The value to set `l2_normalize` must be type of bool."
|
|
||||||
self._model.l2_normalize = value
|
|
||||||
|
|
||||||
|
|
||||||
class CosFace(FastDeployModel):
|
|
||||||
def __init__(self,
|
|
||||||
model_file,
|
|
||||||
params_file="",
|
|
||||||
runtime_option=None,
|
|
||||||
model_format=Frontend.ONNX):
|
|
||||||
# 调用基函数进行backend_option的初始化
|
|
||||||
# 初始化后的option保存在self._runtime_option
|
|
||||||
super(CosFace, self).__init__(runtime_option)
|
|
||||||
|
|
||||||
self._model = C.vision.deepinsight.CosFace(
|
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
|
||||||
assert self.initialized, "CosFace initialize failed."
|
|
||||||
|
|
||||||
def predict(self, input_image):
|
|
||||||
return self._model.predict(input_image)
|
|
||||||
|
|
||||||
# 一些跟模型有关的属性封装
|
|
||||||
# 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持)
|
|
||||||
@property
|
|
||||||
def size(self):
|
|
||||||
return self._model.size
|
|
||||||
|
|
||||||
@property
|
|
||||||
def alpha(self):
|
|
||||||
return self._model.alpha
|
|
||||||
|
|
||||||
@property
|
|
||||||
def beta(self):
|
|
||||||
return self._model.beta
|
|
||||||
|
|
||||||
@property
|
|
||||||
def swap_rb(self):
|
|
||||||
return self._model.swap_rb
|
|
||||||
|
|
||||||
@property
|
|
||||||
def l2_normalize(self):
|
|
||||||
return self._model.l2_normalize
|
|
||||||
|
|
||||||
@size.setter
|
|
||||||
def size(self, wh):
|
|
||||||
assert isinstance(wh, (list, tuple)),\
|
|
||||||
"The value to set `size` must be type of tuple or list."
|
|
||||||
assert len(wh) == 2,\
|
|
||||||
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
|
||||||
len(wh))
|
|
||||||
self._model.size = wh
|
|
||||||
|
|
||||||
@alpha.setter
|
|
||||||
def alpha(self, value):
|
|
||||||
assert isinstance(value, (list, tuple)),\
|
|
||||||
"The value to set `alpha` must be type of tuple or list."
|
|
||||||
assert len(value) == 3,\
|
|
||||||
"The value to set `alpha` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
|
||||||
len(value))
|
|
||||||
self._model.alpha = value
|
|
||||||
|
|
||||||
@beta.setter
|
|
||||||
def beta(self, value):
|
|
||||||
assert isinstance(value, (list, tuple)),\
|
|
||||||
"The value to set `beta` must be type of tuple or list."
|
|
||||||
assert len(value) == 3,\
|
|
||||||
"The value to set `beta` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
|
||||||
len(value))
|
|
||||||
self._model.beta = value
|
|
||||||
|
|
||||||
@swap_rb.setter
|
|
||||||
def swap_rb(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, bool), "The value to set `swap_rb` must be type of bool."
|
|
||||||
self._model.swap_rb = value
|
|
||||||
|
|
||||||
@l2_normalize.setter
|
|
||||||
def l2_normalize(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value,
|
|
||||||
bool), "The value to set `l2_normalize` must be type of bool."
|
|
||||||
self._model.l2_normalize = value
|
|
||||||
|
|
||||||
|
|
||||||
class PartialFC(FastDeployModel):
|
|
||||||
def __init__(self,
|
|
||||||
model_file,
|
|
||||||
params_file="",
|
|
||||||
runtime_option=None,
|
|
||||||
model_format=Frontend.ONNX):
|
|
||||||
# 调用基函数进行backend_option的初始化
|
|
||||||
# 初始化后的option保存在self._runtime_option
|
|
||||||
super(PartialFC, self).__init__(runtime_option)
|
|
||||||
|
|
||||||
self._model = C.vision.deepinsight.PartialFC(
|
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
|
||||||
assert self.initialized, "PartialFC initialize failed."
|
|
||||||
|
|
||||||
def predict(self, input_image):
|
|
||||||
return self._model.predict(input_image)
|
|
||||||
|
|
||||||
# 一些跟模型有关的属性封装
|
|
||||||
# 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持)
|
|
||||||
@property
|
|
||||||
def size(self):
|
|
||||||
return self._model.size
|
|
||||||
|
|
||||||
@property
|
|
||||||
def alpha(self):
|
|
||||||
return self._model.alpha
|
|
||||||
|
|
||||||
@property
|
|
||||||
def beta(self):
|
|
||||||
return self._model.beta
|
|
||||||
|
|
||||||
@property
|
|
||||||
def swap_rb(self):
|
|
||||||
return self._model.swap_rb
|
|
||||||
|
|
||||||
@property
|
|
||||||
def l2_normalize(self):
|
|
||||||
return self._model.l2_normalize
|
|
||||||
|
|
||||||
@size.setter
|
|
||||||
def size(self, wh):
|
|
||||||
assert isinstance(wh, (list, tuple)),\
|
|
||||||
"The value to set `size` must be type of tuple or list."
|
|
||||||
assert len(wh) == 2,\
|
|
||||||
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
|
||||||
len(wh))
|
|
||||||
self._model.size = wh
|
|
||||||
|
|
||||||
@alpha.setter
|
|
||||||
def alpha(self, value):
|
|
||||||
assert isinstance(value, (list, tuple)),\
|
|
||||||
"The value to set `alpha` must be type of tuple or list."
|
|
||||||
assert len(value) == 3,\
|
|
||||||
"The value to set `alpha` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
|
||||||
len(value))
|
|
||||||
self._model.alpha = value
|
|
||||||
|
|
||||||
@beta.setter
|
|
||||||
def beta(self, value):
|
|
||||||
assert isinstance(value, (list, tuple)),\
|
|
||||||
"The value to set `beta` must be type of tuple or list."
|
|
||||||
assert len(value) == 3,\
|
|
||||||
"The value to set `beta` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
|
||||||
len(value))
|
|
||||||
self._model.beta = value
|
|
||||||
|
|
||||||
@swap_rb.setter
|
|
||||||
def swap_rb(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, bool), "The value to set `swap_rb` must be type of bool."
|
|
||||||
self._model.swap_rb = value
|
|
||||||
|
|
||||||
@l2_normalize.setter
|
|
||||||
def l2_normalize(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value,
|
|
||||||
bool), "The value to set `l2_normalize` must be type of bool."
|
|
||||||
self._model.l2_normalize = value
|
|
||||||
|
|
||||||
|
|
||||||
class VPL(FastDeployModel):
|
|
||||||
def __init__(self,
|
|
||||||
model_file,
|
|
||||||
params_file="",
|
|
||||||
runtime_option=None,
|
|
||||||
model_format=Frontend.ONNX):
|
|
||||||
# 调用基函数进行backend_option的初始化
|
|
||||||
# 初始化后的option保存在self._runtime_option
|
|
||||||
super(VPL, self).__init__(runtime_option)
|
|
||||||
|
|
||||||
self._model = C.vision.deepinsight.VPL(
|
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
|
||||||
assert self.initialized, "VPL initialize failed."
|
|
||||||
|
|
||||||
def predict(self, input_image):
|
|
||||||
return self._model.predict(input_image)
|
|
||||||
|
|
||||||
# 一些跟模型有关的属性封装
|
|
||||||
# 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持)
|
|
||||||
@property
|
|
||||||
def size(self):
|
|
||||||
return self._model.size
|
|
||||||
|
|
||||||
@property
|
|
||||||
def alpha(self):
|
|
||||||
return self._model.alpha
|
|
||||||
|
|
||||||
@property
|
|
||||||
def beta(self):
|
|
||||||
return self._model.beta
|
|
||||||
|
|
||||||
@property
|
|
||||||
def swap_rb(self):
|
|
||||||
return self._model.swap_rb
|
|
||||||
|
|
||||||
@property
|
|
||||||
def l2_normalize(self):
|
|
||||||
return self._model.l2_normalize
|
|
||||||
|
|
||||||
@size.setter
|
|
||||||
def size(self, wh):
|
|
||||||
assert isinstance(wh, (list, tuple)),\
|
|
||||||
"The value to set `size` must be type of tuple or list."
|
|
||||||
assert len(wh) == 2,\
|
|
||||||
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
|
||||||
len(wh))
|
|
||||||
self._model.size = wh
|
|
||||||
|
|
||||||
@alpha.setter
|
|
||||||
def alpha(self, value):
|
|
||||||
assert isinstance(value, (list, tuple)),\
|
|
||||||
"The value to set `alpha` must be type of tuple or list."
|
|
||||||
assert len(value) == 3,\
|
|
||||||
"The value to set `alpha` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
|
||||||
len(value))
|
|
||||||
self._model.alpha = value
|
|
||||||
|
|
||||||
@beta.setter
|
|
||||||
def beta(self, value):
|
|
||||||
assert isinstance(value, (list, tuple)),\
|
|
||||||
"The value to set `beta` must be type of tuple or list."
|
|
||||||
assert len(value) == 3,\
|
|
||||||
"The value to set `beta` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
|
||||||
len(value))
|
|
||||||
self._model.beta = value
|
|
||||||
|
|
||||||
@swap_rb.setter
|
|
||||||
def swap_rb(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, bool), "The value to set `swap_rb` must be type of bool."
|
|
||||||
self._model.swap_rb = value
|
|
||||||
|
|
||||||
@l2_normalize.setter
|
|
||||||
def l2_normalize(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value,
|
|
||||||
bool), "The value to set `l2_normalize` must be type of bool."
|
|
||||||
self._model.l2_normalize = value
|
|
@@ -13,8 +13,12 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from .yolov7 import YOLOv7
|
from .contrib.yolov7 import YOLOv7
|
||||||
from .yolor import YOLOR
|
from .contrib.yolor import YOLOR
|
||||||
from .scaled_yolov4 import ScaledYOLOv4
|
from .contrib.scaled_yolov4 import ScaledYOLOv4
|
||||||
|
from .contrib.nanodet_plus import NanoDetPlus
|
||||||
|
from .contrib.yolox import YOLOX
|
||||||
|
from .contrib.yolov5 import YOLOv5
|
||||||
|
from .contrib.yolov5lite import YOLOv5Lite
|
||||||
|
from .contrib.yolov6 import YOLOv6
|
||||||
from .ppdet import PPYOLOE, PPYOLO, PPYOLOv2, PaddleYOLOX, PicoDet, FasterRCNN, YOLOv3
|
from .ppdet import PPYOLOE, PPYOLO, PPYOLOv2, PaddleYOLOX, PicoDet, FasterRCNN, YOLOv3
|
||||||
|
15
fastdeploy/vision/detection/contrib/__init__.py
Normal file
15
fastdeploy/vision/detection/contrib/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
from ... import FastDeployModel, Frontend
|
from .... import FastDeployModel, Frontend
|
||||||
from ... import c_lib_wrap as C
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
class NanoDetPlus(FastDeployModel):
|
class NanoDetPlus(FastDeployModel):
|
||||||
@@ -28,7 +28,7 @@ class NanoDetPlus(FastDeployModel):
|
|||||||
# 初始化后的option保存在self._runtime_option
|
# 初始化后的option保存在self._runtime_option
|
||||||
super(NanoDetPlus, self).__init__(runtime_option)
|
super(NanoDetPlus, self).__init__(runtime_option)
|
||||||
|
|
||||||
self._model = C.vision.rangilyu.NanoDetPlus(
|
self._model = C.vision.detection.NanoDetPlus(
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
assert self.initialized, "NanoDetPlus initialize failed."
|
assert self.initialized, "NanoDetPlus initialize failed."
|
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
from ... import FastDeployModel, Frontend
|
from .... import FastDeployModel, Frontend
|
||||||
from ... import c_lib_wrap as C
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
class ScaledYOLOv4(FastDeployModel):
|
class ScaledYOLOv4(FastDeployModel):
|
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
from ... import FastDeployModel, Frontend
|
from .... import FastDeployModel, Frontend
|
||||||
from ... import c_lib_wrap as C
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
class YOLOR(FastDeployModel):
|
class YOLOR(FastDeployModel):
|
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
from ... import FastDeployModel, Frontend
|
from .... import FastDeployModel, Frontend
|
||||||
from ... import c_lib_wrap as C
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
class YOLOv5(FastDeployModel):
|
class YOLOv5(FastDeployModel):
|
||||||
@@ -28,7 +28,7 @@ class YOLOv5(FastDeployModel):
|
|||||||
# 初始化后的option保存在self._runtime_option
|
# 初始化后的option保存在self._runtime_option
|
||||||
super(YOLOv5, self).__init__(runtime_option)
|
super(YOLOv5, self).__init__(runtime_option)
|
||||||
|
|
||||||
self._model = C.vision.ultralytics.YOLOv5(
|
self._model = C.vision.detection.YOLOv5(
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
assert self.initialized, "YOLOv5 initialize failed."
|
assert self.initialized, "YOLOv5 initialize failed."
|
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
from ... import FastDeployModel, Frontend
|
from .... import FastDeployModel, Frontend
|
||||||
from ... import c_lib_wrap as C
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
class YOLOv5Lite(FastDeployModel):
|
class YOLOv5Lite(FastDeployModel):
|
||||||
@@ -28,7 +28,7 @@ class YOLOv5Lite(FastDeployModel):
|
|||||||
# 初始化后的option保存在self._runtime_option
|
# 初始化后的option保存在self._runtime_option
|
||||||
super(YOLOv5Lite, self).__init__(runtime_option)
|
super(YOLOv5Lite, self).__init__(runtime_option)
|
||||||
|
|
||||||
self._model = C.vision.ppogg.YOLOv5Lite(
|
self._model = C.vision.detection.YOLOv5Lite(
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
assert self.initialized, "YOLOv5Lite initialize failed."
|
assert self.initialized, "YOLOv5Lite initialize failed."
|
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
from ... import FastDeployModel, Frontend
|
from .... import FastDeployModel, Frontend
|
||||||
from ... import c_lib_wrap as C
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
class YOLOv6(FastDeployModel):
|
class YOLOv6(FastDeployModel):
|
||||||
@@ -28,7 +28,7 @@ class YOLOv6(FastDeployModel):
|
|||||||
# 初始化后的option保存在self._runtime_option
|
# 初始化后的option保存在self._runtime_option
|
||||||
super(YOLOv6, self).__init__(runtime_option)
|
super(YOLOv6, self).__init__(runtime_option)
|
||||||
|
|
||||||
self._model = C.vision.meituan.YOLOv6(
|
self._model = C.vision.detection.YOLOv6(
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
assert self.initialized, "YOLOv6 initialize failed."
|
assert self.initialized, "YOLOv6 initialize failed."
|
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
from ... import FastDeployModel, Frontend
|
from .... import FastDeployModel, Frontend
|
||||||
from ... import c_lib_wrap as C
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
class YOLOv7(FastDeployModel):
|
class YOLOv7(FastDeployModel):
|
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
from ... import FastDeployModel, Frontend
|
from .... import FastDeployModel, Frontend
|
||||||
from ... import c_lib_wrap as C
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
class YOLOX(FastDeployModel):
|
class YOLOX(FastDeployModel):
|
||||||
@@ -28,8 +28,8 @@ class YOLOX(FastDeployModel):
|
|||||||
# 初始化后的option保存在self._runtime_option
|
# 初始化后的option保存在self._runtime_option
|
||||||
super(YOLOX, self).__init__(runtime_option)
|
super(YOLOX, self).__init__(runtime_option)
|
||||||
|
|
||||||
self._model = C.vision.megvii.YOLOX(model_file, params_file,
|
self._model = C.vision.detection.YOLOX(
|
||||||
self._runtime_option, model_format)
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
assert self.initialized, "YOLOX initialize failed."
|
assert self.initialized, "YOLOX initialize failed."
|
||||||
|
|
19
fastdeploy/vision/facedet/__init__.py
Normal file
19
fastdeploy/vision/facedet/__init__.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .contrib.yolov5face import YOLOv5Face
|
||||||
|
from .contrib.retinaface import RetinaFace
|
||||||
|
from .contrib.scrfd import SCRFD
|
||||||
|
from .contrib.ultraface import UltraFace
|
15
fastdeploy/vision/facedet/contrib/__init__.py
Normal file
15
fastdeploy/vision/facedet/contrib/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
from ... import FastDeployModel, Frontend
|
from .... import FastDeployModel, Frontend
|
||||||
from ... import c_lib_wrap as C
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
class RetinaFace(FastDeployModel):
|
class RetinaFace(FastDeployModel):
|
||||||
@@ -28,7 +28,7 @@ class RetinaFace(FastDeployModel):
|
|||||||
# 初始化后的option保存在self._runtime_option
|
# 初始化后的option保存在self._runtime_option
|
||||||
super(RetinaFace, self).__init__(runtime_option)
|
super(RetinaFace, self).__init__(runtime_option)
|
||||||
|
|
||||||
self._model = C.vision.biubug6.RetinaFace(
|
self._model = C.vision.facedet.RetinaFace(
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
assert self.initialized, "RetinaFace initialize failed."
|
assert self.initialized, "RetinaFace initialize failed."
|
158
fastdeploy/vision/facedet/contrib/scrfd.py
Normal file
158
fastdeploy/vision/facedet/contrib/scrfd.py
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
import logging
|
||||||
|
from .... import FastDeployModel, Frontend
|
||||||
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
|
class SCRFD(FastDeployModel):
|
||||||
|
def __init__(self,
|
||||||
|
model_file,
|
||||||
|
params_file="",
|
||||||
|
runtime_option=None,
|
||||||
|
model_format=Frontend.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.initialized判断整个模型的初始化是否成功
|
||||||
|
assert self.initialized, "SCRFD initialize failed."
|
||||||
|
|
||||||
|
def predict(self, input_image, conf_threshold=0.7, nms_iou_threshold=0.3):
|
||||||
|
return self._model.predict(input_image, conf_threshold,
|
||||||
|
nms_iou_threshold)
|
||||||
|
|
||||||
|
# 一些跟SCRFD模型有关的属性封装
|
||||||
|
# 多数是预处理相关,可通过修改如model.size = [640, 640]改变预处理时resize的大小(前提是模型支持)
|
||||||
|
@property
|
||||||
|
def size(self):
|
||||||
|
return self._model.size
|
||||||
|
|
||||||
|
@property
|
||||||
|
def padding_value(self):
|
||||||
|
return self._model.padding_value
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_no_pad(self):
|
||||||
|
return self._model.is_no_pad
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_mini_pad(self):
|
||||||
|
return self._model.is_mini_pad
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_scale_up(self):
|
||||||
|
return self._model.is_scale_up
|
||||||
|
|
||||||
|
@property
|
||||||
|
def stride(self):
|
||||||
|
return self._model.stride
|
||||||
|
|
||||||
|
@property
|
||||||
|
def downsample_strides(self):
|
||||||
|
return self._model.downsample_strides
|
||||||
|
|
||||||
|
@property
|
||||||
|
def landmarks_per_face(self):
|
||||||
|
return self._model.landmarks_per_face
|
||||||
|
|
||||||
|
@property
|
||||||
|
def use_kps(self):
|
||||||
|
return self._model.use_kps
|
||||||
|
|
||||||
|
@property
|
||||||
|
def max_nms(self):
|
||||||
|
return self._model.max_nms
|
||||||
|
|
||||||
|
@property
|
||||||
|
def num_anchors(self):
|
||||||
|
return self._model.num_anchors
|
||||||
|
|
||||||
|
@size.setter
|
||||||
|
def size(self, wh):
|
||||||
|
assert isinstance(wh, (list, tuple)),\
|
||||||
|
"The value to set `size` must be type of tuple or list."
|
||||||
|
assert len(wh) == 2,\
|
||||||
|
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
||||||
|
len(wh))
|
||||||
|
self._model.size = wh
|
||||||
|
|
||||||
|
@padding_value.setter
|
||||||
|
def padding_value(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value,
|
||||||
|
list), "The value to set `padding_value` must be type of list."
|
||||||
|
self._model.padding_value = value
|
||||||
|
|
||||||
|
@is_no_pad.setter
|
||||||
|
def is_no_pad(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value, bool), "The value to set `is_no_pad` must be type of bool."
|
||||||
|
self._model.is_no_pad = value
|
||||||
|
|
||||||
|
@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."
|
||||||
|
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."
|
||||||
|
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."
|
||||||
|
self._model.stride = value
|
||||||
|
|
||||||
|
@downsample_strides.setter
|
||||||
|
def downsample_strides(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value,
|
||||||
|
list), "The value to set `downsample_strides` must be type of list."
|
||||||
|
self._model.downsample_strides = value
|
||||||
|
|
||||||
|
@landmarks_per_face.setter
|
||||||
|
def landmarks_per_face(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value,
|
||||||
|
int), "The value to set `landmarks_per_face` must be type of int."
|
||||||
|
self._model.landmarks_per_face = value
|
||||||
|
|
||||||
|
@use_kps.setter
|
||||||
|
def use_kps(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value, bool), "The value to set `use_kps` must be type of bool."
|
||||||
|
self._model.use_kps = value
|
||||||
|
|
||||||
|
@max_nms.setter
|
||||||
|
def max_nms(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value, int), "The value to set `max_nms` must be type of int."
|
||||||
|
self._model.max_nms = value
|
||||||
|
|
||||||
|
@num_anchors.setter
|
||||||
|
def num_anchors(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value, int), "The value to set `num_anchors` must be type of int."
|
||||||
|
self._model.num_anchors = value
|
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
from ... import FastDeployModel, Frontend
|
from .... import FastDeployModel, Frontend
|
||||||
from ... import c_lib_wrap as C
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
class UltraFace(FastDeployModel):
|
class UltraFace(FastDeployModel):
|
||||||
@@ -28,7 +28,7 @@ class UltraFace(FastDeployModel):
|
|||||||
# 初始化后的option保存在self._runtime_option
|
# 初始化后的option保存在self._runtime_option
|
||||||
super(UltraFace, self).__init__(runtime_option)
|
super(UltraFace, self).__init__(runtime_option)
|
||||||
|
|
||||||
self._model = C.vision.linzaer.UltraFace(
|
self._model = C.vision.facedet.UltraFace(
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
assert self.initialized, "UltraFace initialize failed."
|
assert self.initialized, "UltraFace initialize failed."
|
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
from ... import FastDeployModel, Frontend
|
from .... import FastDeployModel, Frontend
|
||||||
from ... import c_lib_wrap as C
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
class YOLOv5Face(FastDeployModel):
|
class YOLOv5Face(FastDeployModel):
|
||||||
@@ -28,7 +28,7 @@ class YOLOv5Face(FastDeployModel):
|
|||||||
# 初始化后的option保存在self._runtime_option
|
# 初始化后的option保存在self._runtime_option
|
||||||
super(YOLOv5Face, self).__init__(runtime_option)
|
super(YOLOv5Face, self).__init__(runtime_option)
|
||||||
|
|
||||||
self._model = C.vision.deepcam.YOLOv5Face(
|
self._model = C.vision.facedet.YOLOv5Face(
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
assert self.initialized, "YOLOv5Face initialize failed."
|
assert self.initialized, "YOLOv5Face initialize failed."
|
20
fastdeploy/vision/faceid/__init__.py
Normal file
20
fastdeploy/vision/faceid/__init__.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .contrib.arcface import ArcFace
|
||||||
|
from .contrib.cosface import CosFace
|
||||||
|
from .contrib.insightface_rec import InsightFaceRecognitionModel
|
||||||
|
from .contrib.partial_fc import PartialFC
|
||||||
|
from .contrib.vpl import VPL
|
15
fastdeploy/vision/faceid/contrib/__init__.py
Normal file
15
fastdeploy/vision/faceid/contrib/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
100
fastdeploy/vision/faceid/contrib/arcface.py
Normal file
100
fastdeploy/vision/faceid/contrib/arcface.py
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
import logging
|
||||||
|
from .... import FastDeployModel, Frontend
|
||||||
|
from .... import c_lib_wrap as C
|
||||||
|
from ..contrib.insightface_rec import InsightFaceRecognitionModel
|
||||||
|
|
||||||
|
|
||||||
|
class ArcFace(FastDeployModel):
|
||||||
|
def __init__(self,
|
||||||
|
model_file,
|
||||||
|
params_file="",
|
||||||
|
runtime_option=None,
|
||||||
|
model_format=Frontend.ONNX):
|
||||||
|
# 调用基函数进行backend_option的初始化
|
||||||
|
# 初始化后的option保存在self._runtime_option
|
||||||
|
super(ArcFace, self).__init__(runtime_option)
|
||||||
|
|
||||||
|
self._model = C.vision.faceid.ArcFace(
|
||||||
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
|
assert self.initialized, "ArcFace initialize failed."
|
||||||
|
|
||||||
|
def predict(self, input_image):
|
||||||
|
return self._model.predict(input_image)
|
||||||
|
|
||||||
|
# 一些跟模型有关的属性封装
|
||||||
|
# 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持)
|
||||||
|
@property
|
||||||
|
def size(self):
|
||||||
|
return self._model.size
|
||||||
|
|
||||||
|
@property
|
||||||
|
def alpha(self):
|
||||||
|
return self._model.alpha
|
||||||
|
|
||||||
|
@property
|
||||||
|
def beta(self):
|
||||||
|
return self._model.beta
|
||||||
|
|
||||||
|
@property
|
||||||
|
def swap_rb(self):
|
||||||
|
return self._model.swap_rb
|
||||||
|
|
||||||
|
@property
|
||||||
|
def l2_normalize(self):
|
||||||
|
return self._model.l2_normalize
|
||||||
|
|
||||||
|
@size.setter
|
||||||
|
def size(self, wh):
|
||||||
|
assert isinstance(wh, (list, tuple)),\
|
||||||
|
"The value to set `size` must be type of tuple or list."
|
||||||
|
assert len(wh) == 2,\
|
||||||
|
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
||||||
|
len(wh))
|
||||||
|
self._model.size = wh
|
||||||
|
|
||||||
|
@alpha.setter
|
||||||
|
def alpha(self, value):
|
||||||
|
assert isinstance(value, (list, tuple)),\
|
||||||
|
"The value to set `alpha` must be type of tuple or list."
|
||||||
|
assert len(value) == 3,\
|
||||||
|
"The value to set `alpha` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
||||||
|
len(value))
|
||||||
|
self._model.alpha = value
|
||||||
|
|
||||||
|
@beta.setter
|
||||||
|
def beta(self, value):
|
||||||
|
assert isinstance(value, (list, tuple)),\
|
||||||
|
"The value to set `beta` must be type of tuple or list."
|
||||||
|
assert len(value) == 3,\
|
||||||
|
"The value to set `beta` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
||||||
|
len(value))
|
||||||
|
self._model.beta = value
|
||||||
|
|
||||||
|
@swap_rb.setter
|
||||||
|
def swap_rb(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value, bool), "The value to set `swap_rb` must be type of bool."
|
||||||
|
self._model.swap_rb = value
|
||||||
|
|
||||||
|
@l2_normalize.setter
|
||||||
|
def l2_normalize(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value,
|
||||||
|
bool), "The value to set `l2_normalize` must be type of bool."
|
||||||
|
self._model.l2_normalize = value
|
99
fastdeploy/vision/faceid/contrib/cosface.py
Normal file
99
fastdeploy/vision/faceid/contrib/cosface.py
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
import logging
|
||||||
|
from .... import FastDeployModel, Frontend
|
||||||
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
|
class CosFace(FastDeployModel):
|
||||||
|
def __init__(self,
|
||||||
|
model_file,
|
||||||
|
params_file="",
|
||||||
|
runtime_option=None,
|
||||||
|
model_format=Frontend.ONNX):
|
||||||
|
# 调用基函数进行backend_option的初始化
|
||||||
|
# 初始化后的option保存在self._runtime_option
|
||||||
|
super(CosFace, self).__init__(runtime_option)
|
||||||
|
|
||||||
|
self._model = C.vision.faceid.CosFace(
|
||||||
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
|
assert self.initialized, "CosFace initialize failed."
|
||||||
|
|
||||||
|
def predict(self, input_image):
|
||||||
|
return self._model.predict(input_image)
|
||||||
|
|
||||||
|
# 一些跟模型有关的属性封装
|
||||||
|
# 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持)
|
||||||
|
@property
|
||||||
|
def size(self):
|
||||||
|
return self._model.size
|
||||||
|
|
||||||
|
@property
|
||||||
|
def alpha(self):
|
||||||
|
return self._model.alpha
|
||||||
|
|
||||||
|
@property
|
||||||
|
def beta(self):
|
||||||
|
return self._model.beta
|
||||||
|
|
||||||
|
@property
|
||||||
|
def swap_rb(self):
|
||||||
|
return self._model.swap_rb
|
||||||
|
|
||||||
|
@property
|
||||||
|
def l2_normalize(self):
|
||||||
|
return self._model.l2_normalize
|
||||||
|
|
||||||
|
@size.setter
|
||||||
|
def size(self, wh):
|
||||||
|
assert isinstance(wh, (list, tuple)),\
|
||||||
|
"The value to set `size` must be type of tuple or list."
|
||||||
|
assert len(wh) == 2,\
|
||||||
|
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
||||||
|
len(wh))
|
||||||
|
self._model.size = wh
|
||||||
|
|
||||||
|
@alpha.setter
|
||||||
|
def alpha(self, value):
|
||||||
|
assert isinstance(value, (list, tuple)),\
|
||||||
|
"The value to set `alpha` must be type of tuple or list."
|
||||||
|
assert len(value) == 3,\
|
||||||
|
"The value to set `alpha` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
||||||
|
len(value))
|
||||||
|
self._model.alpha = value
|
||||||
|
|
||||||
|
@beta.setter
|
||||||
|
def beta(self, value):
|
||||||
|
assert isinstance(value, (list, tuple)),\
|
||||||
|
"The value to set `beta` must be type of tuple or list."
|
||||||
|
assert len(value) == 3,\
|
||||||
|
"The value to set `beta` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
||||||
|
len(value))
|
||||||
|
self._model.beta = value
|
||||||
|
|
||||||
|
@swap_rb.setter
|
||||||
|
def swap_rb(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value, bool), "The value to set `swap_rb` must be type of bool."
|
||||||
|
self._model.swap_rb = value
|
||||||
|
|
||||||
|
@l2_normalize.setter
|
||||||
|
def l2_normalize(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value,
|
||||||
|
bool), "The value to set `l2_normalize` must be type of bool."
|
||||||
|
self._model.l2_normalize = value
|
99
fastdeploy/vision/faceid/contrib/insightface_rec.py
Normal file
99
fastdeploy/vision/faceid/contrib/insightface_rec.py
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
import logging
|
||||||
|
from .... import FastDeployModel, Frontend
|
||||||
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
|
class InsightFaceRecognitionModel(FastDeployModel):
|
||||||
|
def __init__(self,
|
||||||
|
model_file,
|
||||||
|
params_file="",
|
||||||
|
runtime_option=None,
|
||||||
|
model_format=Frontend.ONNX):
|
||||||
|
# 调用基函数进行backend_option的初始化
|
||||||
|
# 初始化后的option保存在self._runtime_option
|
||||||
|
super(InsightFaceRecognitionModel, self).__init__(runtime_option)
|
||||||
|
|
||||||
|
self._model = C.vision.faceid.InsightFaceRecognitionModel(
|
||||||
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
|
assert self.initialized, "InsightFaceRecognitionModel initialize failed."
|
||||||
|
|
||||||
|
def predict(self, input_image):
|
||||||
|
return self._model.predict(input_image)
|
||||||
|
|
||||||
|
# 一些跟InsightFaceRecognitionModel模型有关的属性封装
|
||||||
|
# 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持)
|
||||||
|
@property
|
||||||
|
def size(self):
|
||||||
|
return self._model.size
|
||||||
|
|
||||||
|
@property
|
||||||
|
def alpha(self):
|
||||||
|
return self._model.alpha
|
||||||
|
|
||||||
|
@property
|
||||||
|
def beta(self):
|
||||||
|
return self._model.beta
|
||||||
|
|
||||||
|
@property
|
||||||
|
def swap_rb(self):
|
||||||
|
return self._model.swap_rb
|
||||||
|
|
||||||
|
@property
|
||||||
|
def l2_normalize(self):
|
||||||
|
return self._model.l2_normalize
|
||||||
|
|
||||||
|
@size.setter
|
||||||
|
def size(self, wh):
|
||||||
|
assert isinstance(wh, (list, tuple)),\
|
||||||
|
"The value to set `size` must be type of tuple or list."
|
||||||
|
assert len(wh) == 2,\
|
||||||
|
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
||||||
|
len(wh))
|
||||||
|
self._model.size = wh
|
||||||
|
|
||||||
|
@alpha.setter
|
||||||
|
def alpha(self, value):
|
||||||
|
assert isinstance(value, (list, tuple)),\
|
||||||
|
"The value to set `alpha` must be type of tuple or list."
|
||||||
|
assert len(value) == 3,\
|
||||||
|
"The value to set `alpha` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
||||||
|
len(value))
|
||||||
|
self._model.alpha = value
|
||||||
|
|
||||||
|
@beta.setter
|
||||||
|
def beta(self, value):
|
||||||
|
assert isinstance(value, (list, tuple)),\
|
||||||
|
"The value to set `beta` must be type of tuple or list."
|
||||||
|
assert len(value) == 3,\
|
||||||
|
"The value to set `beta` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
||||||
|
len(value))
|
||||||
|
self._model.beta = value
|
||||||
|
|
||||||
|
@swap_rb.setter
|
||||||
|
def swap_rb(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value, bool), "The value to set `swap_rb` must be type of bool."
|
||||||
|
self._model.swap_rb = value
|
||||||
|
|
||||||
|
@l2_normalize.setter
|
||||||
|
def l2_normalize(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value,
|
||||||
|
bool), "The value to set `l2_normalize` must be type of bool."
|
||||||
|
self._model.l2_normalize = value
|
99
fastdeploy/vision/faceid/contrib/partial_fc.py
Normal file
99
fastdeploy/vision/faceid/contrib/partial_fc.py
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
import logging
|
||||||
|
from .... import FastDeployModel, Frontend
|
||||||
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
|
class PartialFC(FastDeployModel):
|
||||||
|
def __init__(self,
|
||||||
|
model_file,
|
||||||
|
params_file="",
|
||||||
|
runtime_option=None,
|
||||||
|
model_format=Frontend.ONNX):
|
||||||
|
# 调用基函数进行backend_option的初始化
|
||||||
|
# 初始化后的option保存在self._runtime_option
|
||||||
|
super(PartialFC, self).__init__(runtime_option)
|
||||||
|
|
||||||
|
self._model = C.vision.faceid.PartialFC(
|
||||||
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
|
assert self.initialized, "PartialFC initialize failed."
|
||||||
|
|
||||||
|
def predict(self, input_image):
|
||||||
|
return self._model.predict(input_image)
|
||||||
|
|
||||||
|
# 一些跟模型有关的属性封装
|
||||||
|
# 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持)
|
||||||
|
@property
|
||||||
|
def size(self):
|
||||||
|
return self._model.size
|
||||||
|
|
||||||
|
@property
|
||||||
|
def alpha(self):
|
||||||
|
return self._model.alpha
|
||||||
|
|
||||||
|
@property
|
||||||
|
def beta(self):
|
||||||
|
return self._model.beta
|
||||||
|
|
||||||
|
@property
|
||||||
|
def swap_rb(self):
|
||||||
|
return self._model.swap_rb
|
||||||
|
|
||||||
|
@property
|
||||||
|
def l2_normalize(self):
|
||||||
|
return self._model.l2_normalize
|
||||||
|
|
||||||
|
@size.setter
|
||||||
|
def size(self, wh):
|
||||||
|
assert isinstance(wh, (list, tuple)),\
|
||||||
|
"The value to set `size` must be type of tuple or list."
|
||||||
|
assert len(wh) == 2,\
|
||||||
|
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
||||||
|
len(wh))
|
||||||
|
self._model.size = wh
|
||||||
|
|
||||||
|
@alpha.setter
|
||||||
|
def alpha(self, value):
|
||||||
|
assert isinstance(value, (list, tuple)),\
|
||||||
|
"The value to set `alpha` must be type of tuple or list."
|
||||||
|
assert len(value) == 3,\
|
||||||
|
"The value to set `alpha` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
||||||
|
len(value))
|
||||||
|
self._model.alpha = value
|
||||||
|
|
||||||
|
@beta.setter
|
||||||
|
def beta(self, value):
|
||||||
|
assert isinstance(value, (list, tuple)),\
|
||||||
|
"The value to set `beta` must be type of tuple or list."
|
||||||
|
assert len(value) == 3,\
|
||||||
|
"The value to set `beta` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
||||||
|
len(value))
|
||||||
|
self._model.beta = value
|
||||||
|
|
||||||
|
@swap_rb.setter
|
||||||
|
def swap_rb(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value, bool), "The value to set `swap_rb` must be type of bool."
|
||||||
|
self._model.swap_rb = value
|
||||||
|
|
||||||
|
@l2_normalize.setter
|
||||||
|
def l2_normalize(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value,
|
||||||
|
bool), "The value to set `l2_normalize` must be type of bool."
|
||||||
|
self._model.l2_normalize = value
|
99
fastdeploy/vision/faceid/contrib/vpl.py
Normal file
99
fastdeploy/vision/faceid/contrib/vpl.py
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
import logging
|
||||||
|
from .... import FastDeployModel, Frontend
|
||||||
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
|
class VPL(FastDeployModel):
|
||||||
|
def __init__(self,
|
||||||
|
model_file,
|
||||||
|
params_file="",
|
||||||
|
runtime_option=None,
|
||||||
|
model_format=Frontend.ONNX):
|
||||||
|
# 调用基函数进行backend_option的初始化
|
||||||
|
# 初始化后的option保存在self._runtime_option
|
||||||
|
super(VPL, self).__init__(runtime_option)
|
||||||
|
|
||||||
|
self._model = C.vision.faceid.VPL(model_file, params_file,
|
||||||
|
self._runtime_option, model_format)
|
||||||
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
|
assert self.initialized, "VPL initialize failed."
|
||||||
|
|
||||||
|
def predict(self, input_image):
|
||||||
|
return self._model.predict(input_image)
|
||||||
|
|
||||||
|
# 一些跟模型有关的属性封装
|
||||||
|
# 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持)
|
||||||
|
@property
|
||||||
|
def size(self):
|
||||||
|
return self._model.size
|
||||||
|
|
||||||
|
@property
|
||||||
|
def alpha(self):
|
||||||
|
return self._model.alpha
|
||||||
|
|
||||||
|
@property
|
||||||
|
def beta(self):
|
||||||
|
return self._model.beta
|
||||||
|
|
||||||
|
@property
|
||||||
|
def swap_rb(self):
|
||||||
|
return self._model.swap_rb
|
||||||
|
|
||||||
|
@property
|
||||||
|
def l2_normalize(self):
|
||||||
|
return self._model.l2_normalize
|
||||||
|
|
||||||
|
@size.setter
|
||||||
|
def size(self, wh):
|
||||||
|
assert isinstance(wh, (list, tuple)),\
|
||||||
|
"The value to set `size` must be type of tuple or list."
|
||||||
|
assert len(wh) == 2,\
|
||||||
|
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
||||||
|
len(wh))
|
||||||
|
self._model.size = wh
|
||||||
|
|
||||||
|
@alpha.setter
|
||||||
|
def alpha(self, value):
|
||||||
|
assert isinstance(value, (list, tuple)),\
|
||||||
|
"The value to set `alpha` must be type of tuple or list."
|
||||||
|
assert len(value) == 3,\
|
||||||
|
"The value to set `alpha` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
||||||
|
len(value))
|
||||||
|
self._model.alpha = value
|
||||||
|
|
||||||
|
@beta.setter
|
||||||
|
def beta(self, value):
|
||||||
|
assert isinstance(value, (list, tuple)),\
|
||||||
|
"The value to set `beta` must be type of tuple or list."
|
||||||
|
assert len(value) == 3,\
|
||||||
|
"The value to set `beta` must contatins 3 elements for each channels, but now it contains {} elements.".format(
|
||||||
|
len(value))
|
||||||
|
self._model.beta = value
|
||||||
|
|
||||||
|
@swap_rb.setter
|
||||||
|
def swap_rb(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value, bool), "The value to set `swap_rb` must be type of bool."
|
||||||
|
self._model.swap_rb = value
|
||||||
|
|
||||||
|
@l2_normalize.setter
|
||||||
|
def l2_normalize(self, value):
|
||||||
|
assert isinstance(
|
||||||
|
value,
|
||||||
|
bool), "The value to set `l2_normalize` must be type of bool."
|
||||||
|
self._model.l2_normalize = value
|
16
fastdeploy/vision/matting/__init__.py
Normal file
16
fastdeploy/vision/matting/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from .contrib.modnet import MODNet
|
15
fastdeploy/vision/matting/contrib/__init__.py
Normal file
15
fastdeploy/vision/matting/contrib/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import logging
|
import logging
|
||||||
from ... import FastDeployModel, Frontend
|
from .... import FastDeployModel, Frontend
|
||||||
from ... import c_lib_wrap as C
|
from .... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
class MODNet(FastDeployModel):
|
class MODNet(FastDeployModel):
|
||||||
@@ -28,7 +28,7 @@ class MODNet(FastDeployModel):
|
|||||||
# 初始化后的option保存在self._runtime_option
|
# 初始化后的option保存在self._runtime_option
|
||||||
super(MODNet, self).__init__(runtime_option)
|
super(MODNet, self).__init__(runtime_option)
|
||||||
|
|
||||||
self._model = C.vision.zhkkke.MODNet(
|
self._model = C.vision.matting.MODNet(
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
model_file, params_file, self._runtime_option, model_format)
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
# 通过self.initialized判断整个模型的初始化是否成功
|
||||||
assert self.initialized, "MODNet initialize failed."
|
assert self.initialized, "MODNet initialize failed."
|
@@ -17,12 +17,12 @@ import logging
|
|||||||
from ... import c_lib_wrap as C
|
from ... import c_lib_wrap as C
|
||||||
|
|
||||||
|
|
||||||
def vis_detection(im_data, det_result, line_size=2, font_size=0.5):
|
def vis_detection(im_data, det_result, line_size=1, font_size=0.5):
|
||||||
return C.vision.Visualize.vis_detection(im_data, det_result, line_size,
|
return C.vision.Visualize.vis_detection(im_data, det_result, line_size,
|
||||||
font_size)
|
font_size)
|
||||||
|
|
||||||
|
|
||||||
def vis_face_detection(im_data, face_det_result, line_size=2, font_size=0.5):
|
def vis_face_detection(im_data, face_det_result, line_size=1, font_size=0.5):
|
||||||
return C.vision.Visualize.vis_face_detection(im_data, face_det_result,
|
return C.vision.Visualize.vis_face_detection(im_data, face_det_result,
|
||||||
line_size, font_size)
|
line_size, font_size)
|
||||||
|
|
||||||
|
@@ -1,312 +0,0 @@
|
|||||||
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
from __future__ import absolute_import
|
|
||||||
import logging
|
|
||||||
from ... import FastDeployModel, Frontend
|
|
||||||
from ... import c_lib_wrap as C
|
|
||||||
|
|
||||||
|
|
||||||
class YOLOv7(FastDeployModel):
|
|
||||||
def __init__(self,
|
|
||||||
model_file,
|
|
||||||
params_file="",
|
|
||||||
runtime_option=None,
|
|
||||||
model_format=Frontend.ONNX):
|
|
||||||
# 调用基函数进行backend_option的初始化
|
|
||||||
# 初始化后的option保存在self._runtime_option
|
|
||||||
super(YOLOv7, self).__init__(runtime_option)
|
|
||||||
|
|
||||||
self._model = C.vision.wongkinyiu.YOLOv7(
|
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
|
||||||
assert self.initialized, "YOLOv7 initialize failed."
|
|
||||||
|
|
||||||
def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5):
|
|
||||||
return self._model.predict(input_image, conf_threshold,
|
|
||||||
nms_iou_threshold)
|
|
||||||
|
|
||||||
# 一些跟YOLOv7模型有关的属性封装
|
|
||||||
# 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持)
|
|
||||||
@property
|
|
||||||
def size(self):
|
|
||||||
return self._model.size
|
|
||||||
|
|
||||||
@property
|
|
||||||
def padding_value(self):
|
|
||||||
return self._model.padding_value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_no_pad(self):
|
|
||||||
return self._model.is_no_pad
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_mini_pad(self):
|
|
||||||
return self._model.is_mini_pad
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_scale_up(self):
|
|
||||||
return self._model.is_scale_up
|
|
||||||
|
|
||||||
@property
|
|
||||||
def stride(self):
|
|
||||||
return self._model.stride
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_wh(self):
|
|
||||||
return self._model.max_wh
|
|
||||||
|
|
||||||
@size.setter
|
|
||||||
def size(self, wh):
|
|
||||||
assert isinstance(wh, (list, tuple)),\
|
|
||||||
"The value to set `size` must be type of tuple or list."
|
|
||||||
assert len(wh) == 2,\
|
|
||||||
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
|
||||||
len(wh))
|
|
||||||
self._model.size = wh
|
|
||||||
|
|
||||||
@padding_value.setter
|
|
||||||
def padding_value(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value,
|
|
||||||
list), "The value to set `padding_value` must be type of list."
|
|
||||||
self._model.padding_value = value
|
|
||||||
|
|
||||||
@is_no_pad.setter
|
|
||||||
def is_no_pad(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, bool), "The value to set `is_no_pad` must be type of bool."
|
|
||||||
self._model.is_no_pad = value
|
|
||||||
|
|
||||||
@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."
|
|
||||||
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."
|
|
||||||
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."
|
|
||||||
self._model.stride = value
|
|
||||||
|
|
||||||
@max_wh.setter
|
|
||||||
def max_wh(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, float), "The value to set `max_wh` must be type of float."
|
|
||||||
self._model.max_wh = value
|
|
||||||
|
|
||||||
|
|
||||||
class YOLOR(FastDeployModel):
|
|
||||||
def __init__(self,
|
|
||||||
model_file,
|
|
||||||
params_file="",
|
|
||||||
runtime_option=None,
|
|
||||||
model_format=Frontend.ONNX):
|
|
||||||
# 调用基函数进行backend_option的初始化
|
|
||||||
# 初始化后的option保存在self._runtime_option
|
|
||||||
super(YOLOR, self).__init__(runtime_option)
|
|
||||||
|
|
||||||
self._model = C.vision.wongkinyiu.YOLOR(
|
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
|
||||||
assert self.initialized, "YOLOR initialize failed."
|
|
||||||
|
|
||||||
def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5):
|
|
||||||
return self._model.predict(input_image, conf_threshold,
|
|
||||||
nms_iou_threshold)
|
|
||||||
|
|
||||||
# 一些跟YOLOR模型有关的属性封装
|
|
||||||
# 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持)
|
|
||||||
@property
|
|
||||||
def size(self):
|
|
||||||
return self._model.size
|
|
||||||
|
|
||||||
@property
|
|
||||||
def padding_value(self):
|
|
||||||
return self._model.padding_value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_no_pad(self):
|
|
||||||
return self._model.is_no_pad
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_mini_pad(self):
|
|
||||||
return self._model.is_mini_pad
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_scale_up(self):
|
|
||||||
return self._model.is_scale_up
|
|
||||||
|
|
||||||
@property
|
|
||||||
def stride(self):
|
|
||||||
return self._model.stride
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_wh(self):
|
|
||||||
return self._model.max_wh
|
|
||||||
|
|
||||||
@size.setter
|
|
||||||
def size(self, wh):
|
|
||||||
assert isinstance(wh, (list, tuple)),\
|
|
||||||
"The value to set `size` must be type of tuple or list."
|
|
||||||
assert len(wh) == 2,\
|
|
||||||
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
|
||||||
len(wh))
|
|
||||||
self._model.size = wh
|
|
||||||
|
|
||||||
@padding_value.setter
|
|
||||||
def padding_value(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value,
|
|
||||||
list), "The value to set `padding_value` must be type of list."
|
|
||||||
self._model.padding_value = value
|
|
||||||
|
|
||||||
@is_no_pad.setter
|
|
||||||
def is_no_pad(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, bool), "The value to set `is_no_pad` must be type of bool."
|
|
||||||
self._model.is_no_pad = value
|
|
||||||
|
|
||||||
@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."
|
|
||||||
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."
|
|
||||||
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."
|
|
||||||
self._model.stride = value
|
|
||||||
|
|
||||||
@max_wh.setter
|
|
||||||
def max_wh(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, float), "The value to set `max_wh` must be type of float."
|
|
||||||
self._model.max_wh = value
|
|
||||||
|
|
||||||
|
|
||||||
class ScaledYOLOv4(FastDeployModel):
|
|
||||||
def __init__(self,
|
|
||||||
model_file,
|
|
||||||
params_file="",
|
|
||||||
runtime_option=None,
|
|
||||||
model_format=Frontend.ONNX):
|
|
||||||
# 调用基函数进行backend_option的初始化
|
|
||||||
# 初始化后的option保存在self._runtime_option
|
|
||||||
super(ScaledYOLOv4, self).__init__(runtime_option)
|
|
||||||
|
|
||||||
self._model = C.vision.wongkinyiu.ScaledYOLOv4(
|
|
||||||
model_file, params_file, self._runtime_option, model_format)
|
|
||||||
# 通过self.initialized判断整个模型的初始化是否成功
|
|
||||||
assert self.initialized, "ScaledYOLOv4 initialize failed."
|
|
||||||
|
|
||||||
def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5):
|
|
||||||
return self._model.predict(input_image, conf_threshold,
|
|
||||||
nms_iou_threshold)
|
|
||||||
|
|
||||||
# 一些跟ScaledYOLOv4模型有关的属性封装
|
|
||||||
# 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持)
|
|
||||||
@property
|
|
||||||
def size(self):
|
|
||||||
return self._model.size
|
|
||||||
|
|
||||||
@property
|
|
||||||
def padding_value(self):
|
|
||||||
return self._model.padding_value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_no_pad(self):
|
|
||||||
return self._model.is_no_pad
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_mini_pad(self):
|
|
||||||
return self._model.is_mini_pad
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_scale_up(self):
|
|
||||||
return self._model.is_scale_up
|
|
||||||
|
|
||||||
@property
|
|
||||||
def stride(self):
|
|
||||||
return self._model.stride
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_wh(self):
|
|
||||||
return self._model.max_wh
|
|
||||||
|
|
||||||
@size.setter
|
|
||||||
def size(self, wh):
|
|
||||||
assert isinstance(wh, (list, tuple)),\
|
|
||||||
"The value to set `size` must be type of tuple or list."
|
|
||||||
assert len(wh) == 2,\
|
|
||||||
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
|
|
||||||
len(wh))
|
|
||||||
self._model.size = wh
|
|
||||||
|
|
||||||
@padding_value.setter
|
|
||||||
def padding_value(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value,
|
|
||||||
list), "The value to set `padding_value` must be type of list."
|
|
||||||
self._model.padding_value = value
|
|
||||||
|
|
||||||
@is_no_pad.setter
|
|
||||||
def is_no_pad(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, bool), "The value to set `is_no_pad` must be type of bool."
|
|
||||||
self._model.is_no_pad = value
|
|
||||||
|
|
||||||
@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."
|
|
||||||
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."
|
|
||||||
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."
|
|
||||||
self._model.stride = value
|
|
||||||
|
|
||||||
@max_wh.setter
|
|
||||||
def max_wh(self, value):
|
|
||||||
assert isinstance(
|
|
||||||
value, float), "The value to set `max_wh` must be type of float."
|
|
||||||
self._model.max_wh = value
|
|
@@ -35,7 +35,7 @@ wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/0000000
|
|||||||
### YOLOv7类
|
### YOLOv7类
|
||||||
|
|
||||||
```
|
```
|
||||||
fastdeploy::vision::wongkinyiu::YOLOv7(
|
fastdeploy::vision::detection::YOLOv7(
|
||||||
const string& model_file,
|
const string& model_file,
|
||||||
const string& params_file = "",
|
const string& params_file = "",
|
||||||
const RuntimeOption& runtime_option = RuntimeOption(),
|
const RuntimeOption& runtime_option = RuntimeOption(),
|
||||||
|
@@ -35,7 +35,7 @@ void CpuInfer(const std::string& model_file, const std::string& image_file) {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GpuInfer() {
|
void GpuInfer(const std::string& model_file, const std::string& image_file) {
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseGpu();
|
option.UseGpu();
|
||||||
auto model = fastdeploy::vision::detection::YOLOv7(model_file, "", option);
|
auto model = fastdeploy::vision::detection::YOLOv7(model_file, "", option);
|
||||||
@@ -58,12 +58,11 @@ void GpuInfer() {
|
|||||||
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
std::cout << "Visualized result saved in ./vis_result.jpg" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrtInfer() {
|
void TrtInfer(const std::string& model_file, const std::string& image_file) {
|
||||||
auto option = fastdeploy::RuntimeOption();
|
auto option = fastdeploy::RuntimeOption();
|
||||||
option.UseGpu();
|
option.UseGpu();
|
||||||
option.UseTrtBackend();
|
option.UseTrtBackend();
|
||||||
option.SetTrtInputShape("image", {1, 3, 320, 320}, {1, 3, 640, 640},
|
option.SetTrtInputShape("images", {1, 3, 640, 640});
|
||||||
{1, 3, 1280, 1280});
|
|
||||||
auto model = fastdeploy::vision::detection::YOLOv7(model_file, "", option);
|
auto model = fastdeploy::vision::detection::YOLOv7(model_file, "", option);
|
||||||
if (!model.Initialized()) {
|
if (!model.Initialized()) {
|
||||||
std::cerr << "Failed to initialize." << std::endl;
|
std::cerr << "Failed to initialize." << std::endl;
|
||||||
@@ -96,11 +95,11 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (std::atoi(argv[3]) == 0) {
|
if (std::atoi(argv[3]) == 0) {
|
||||||
CpuInfer();
|
CpuInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 1) {
|
} else if (std::atoi(argv[3]) == 1) {
|
||||||
GpuInfer();
|
GpuInfer(argv[1], argv[2]);
|
||||||
} else if (std::atoi(argv[3]) == 2) {
|
} else if (std::atoi(argv[3]) == 2) {
|
||||||
TrtInfer();
|
TrtInfer(argv[1], argv[2]);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,8 @@
|
|||||||
```
|
```
|
||||||
#下载yolov7模型文件和测试图片
|
#下载yolov7模型文件和测试图片
|
||||||
wget https://bj.bcebos.com/paddlehub/fastdeploy/yolov7.onnx
|
wget https://bj.bcebos.com/paddlehub/fastdeploy/yolov7.onnx
|
||||||
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000087038.jpg
|
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
|
||||||
|
|
||||||
|
|
||||||
#下载部署示例代码
|
#下载部署示例代码
|
||||||
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
git clone https://github.com/PaddlePaddle/FastDeploy.git
|
||||||
|
@@ -31,8 +31,7 @@ def build_option(args):
|
|||||||
|
|
||||||
if args.use_trt:
|
if args.use_trt:
|
||||||
option.use_trt_backend()
|
option.use_trt_backend()
|
||||||
option.set_trt_input_shape("image", [1, 3, 320, 320],
|
option.set_trt_input_shape("images", [1, 3, 640, 640])
|
||||||
[1, 3, 640, 640], [1, 3, 1280, 1280])
|
|
||||||
return option
|
return option
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user