diff --git a/docs/api_docs/python/face_detection.md b/docs/api_docs/python/face_detection.md new file mode 100644 index 0000000000..3e8d5762ca --- /dev/null +++ b/docs/api_docs/python/face_detection.md @@ -0,0 +1,34 @@ +# Face Detection API + +## fastdeploy.vision.facedet.RetinaFace + +```{eval-rst} +.. autoclass:: fastdeploy.vision.facedet.RetinaFace + :members: + :inherited-members: +``` + + +## fastdeploy.vision.facedet.SCRFD + +```{eval-rst} +.. autoclass:: fastdeploy.vision.facedet.SCRFD + :members: + :inherited-members: +``` + +## fastdeploy.vision.facedet.UltraFace + +```{eval-rst} +.. autoclass:: fastdeploy.vision.facedet.UltraFace + :members: + :inherited-members: +``` + +## fastdeploy.vision.facedet.YOLOv5Face + +```{eval-rst} +.. autoclass:: fastdeploy.vision.facedet.YOLOv5Face + :members: + :inherited-members: +``` diff --git a/docs/api_docs/python/face_recognition.md b/docs/api_docs/python/face_recognition.md new file mode 100644 index 0000000000..344aab7968 --- /dev/null +++ b/docs/api_docs/python/face_recognition.md @@ -0,0 +1,41 @@ +# Face Recognition API + +## fastdeploy.vision.faceid.AdaFace + +```{eval-rst} +.. autoclass:: fastdeploy.vision.faceid.AdaFace + :members: + :inherited-members: +``` + +## fastdeploy.vision.faceid.CosFace + +```{eval-rst} +.. autoclass:: fastdeploy.vision.faceid.CosFace + :members: + :inherited-members: +``` + +## fastdeploy.vision.faceid.ArcFace + +```{eval-rst} +.. autoclass:: fastdeploy.vision.faceid.ArcFace + :members: + :inherited-members: +``` + +## fastdeploy.vision.faceid.PartialFC + +```{eval-rst} +.. autoclass:: fastdeploy.vision.faceid.PartialFC + :members: + :inherited-members: +``` + +## fastdeploy.vision.faceid.VPL + +```{eval-rst} +.. autoclass:: fastdeploy.vision.faceid.VPL + :members: + :inherited-members: +``` diff --git a/docs/api_docs/python/index.rst b/docs/api_docs/python/index.rst index 873f83489a..06d4a95cbb 100644 --- a/docs/api_docs/python/index.rst +++ b/docs/api_docs/python/index.rst @@ -18,4 +18,6 @@ FastDeploy image_classification.md keypoint_detection.md matting.md + face_recognition.md + face_detection.md vision_results_en.md diff --git a/docs/api_docs/python/matting.md b/docs/api_docs/python/matting.md index 174f00cc6f..7c121110ac 100644 --- a/docs/api_docs/python/matting.md +++ b/docs/api_docs/python/matting.md @@ -1,3 +1,17 @@ # Matting API -comming soon... +## fastdeploy.vision.matting.MODNet + +```{eval-rst} +.. autoclass:: fastdeploy.vision.matting.MODNet + :members: + :inherited-members: +``` + +## fastdeploy.vision.matting.PPMatting + +```{eval-rst} +.. autoclass:: fastdeploy.vision.matting.PPMatting + :members: + :inherited-members: +``` diff --git a/docs/api_docs/python/object_detection.md b/docs/api_docs/python/object_detection.md index e3d50fcb3e..6bab167cf0 100644 --- a/docs/api_docs/python/object_detection.md +++ b/docs/api_docs/python/object_detection.md @@ -63,3 +63,93 @@ :members: :inherited-members: ``` + +## fastdeploy.vision.detection.NanoDetPlus + +```{eval-rst} +.. autoclass:: fastdeploy.vision.detection.NanoDetPlus + :members: + :inherited-members: +``` + +## fastdeploy.vision.detection.ScaledYOLOv4 + +```{eval-rst} +.. autoclass:: fastdeploy.vision.detection.ScaledYOLOv4 + :members: + :inherited-members: +``` + +## fastdeploy.vision.detection.YOLOR + +```{eval-rst} +.. autoclass:: fastdeploy.vision.detection.YOLOR + :members: + :inherited-members: +``` + +## fastdeploy.vision.detection.YOLOv5 + +```{eval-rst} +.. autoclass:: fastdeploy.vision.detection.YOLOv5 + :members: + :inherited-members: +``` + +## fastdeploy.vision.detection.YOLOv5Lite + +```{eval-rst} +.. autoclass:: fastdeploy.vision.detection.YOLOv5Lite + :members: + :inherited-members: +``` + +## fastdeploy.vision.detection.YOLOv6 + +```{eval-rst} +.. autoclass:: fastdeploy.vision.detection.YOLOv6 + :members: + :inherited-members: +``` + +## fastdeploy.vision.detection.YOLOv7 + +```{eval-rst} +.. autoclass:: fastdeploy.vision.detection.YOLOv7 + :members: + :inherited-members: +``` + + +## fastdeploy.vision.detection.YOLOR + +```{eval-rst} +.. autoclass:: fastdeploy.vision.detection.YOLOR + :members: + :inherited-members: +``` + + +## fastdeploy.vision.detection.YOLOv7End2EndORT + +```{eval-rst} +.. autoclass:: fastdeploy.vision.detection.YOLOv7End2EndORT + :members: + :inherited-members: +``` + +## fastdeploy.vision.detection.YOLOv7End2EndTRT + +```{eval-rst} +.. autoclass:: fastdeploy.vision.detection.YOLOv7End2EndTRT + :members: + :inherited-members: +``` + +## fastdeploy.vision.detection.YOLOX + +```{eval-rst} +.. autoclass:: fastdeploy.vision.detection.YOLOX + :members: + :inherited-members: +``` diff --git a/fastdeploy/vision/classification/contrib/resnet.h b/fastdeploy/vision/classification/contrib/resnet.h index f766f1bf50..f5db8b1bed 100644 --- a/fastdeploy/vision/classification/contrib/resnet.h +++ b/fastdeploy/vision/classification/contrib/resnet.h @@ -25,7 +25,7 @@ namespace vision { * */ namespace classification { -/*! @brief ResNet series model +/*! @brief Torchvision ResNet series model */ class FASTDEPLOY_DECL ResNet : public FastDeployModel { public: @@ -44,17 +44,18 @@ class FASTDEPLOY_DECL ResNet : public FastDeployModel { virtual std::string ModelName() const { return "ResNet"; } /** \brief Predict for the input "im", the result will be saved in "result". * - * \param[in] im Input image for inference. + * \param[in] im The input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format * \param[in] result Saving the inference result. * \param[in] topk The length of return values, e.g., if topk==2, the result will include the 2 most possible class label for input image. */ virtual bool Predict(cv::Mat* im, ClassifyResult* result, int topk = 1); - - /// Tuple of (width, height) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize + */ std::vector size; - /// Mean parameters for normalize + /// Mean parameters for normalize, size should be the the same as channels std::vector mean_vals; - /// Std parameters for normalize + /// Std parameters for normalize, size should be the the same as channels std::vector std_vals; diff --git a/fastdeploy/vision/common/result.h b/fastdeploy/vision/common/result.h index e37538280e..2cc4942403 100644 --- a/fastdeploy/vision/common/result.h +++ b/fastdeploy/vision/common/result.h @@ -154,88 +154,117 @@ struct FASTDEPLOY_DECL OCRResult : public BaseResult { std::string Str(); }; +/*! @brief Face detection result structure for all the face detection models + */ struct FASTDEPLOY_DECL FaceDetectionResult : public BaseResult { - // box: xmin, ymin, xmax, ymax + /** \brief All the detected object boxes for an input image, the size of `boxes` is the number of detected objects, and the element of `boxes` is a array of 4 float values, means [xmin, ymin, xmax, ymax] + */ std::vector> boxes; - // landmark: x, y, landmarks may empty if the - // model don't detect face with landmarks. - // Note, one face might have multiple landmarks, - // such as 5/19/21/68/98/..., etc. + /** \brief + * If the model detect face with landmarks, every detected object box correspoing to a landmark, which is a array of 2 float values, means location [x,y] + */ std::vector> landmarks; + /** \brief + * Indicates the confidence of all targets detected from a single image, and the number of elements is consistent with boxes.size() + */ std::vector scores; ResultType type = ResultType::FACE_DETECTION; - // set landmarks_per_face manually in your post processes. + /** \brief + * `landmarks_per_face` indicates the number of face landmarks for each detected face + * if the model's output contains face landmarks (such as YOLOv5Face, SCRFD, ...) + */ int landmarks_per_face; FaceDetectionResult() { landmarks_per_face = 0; } FaceDetectionResult(const FaceDetectionResult& res); - + /// Clear detection result void Clear(); void Reserve(int size); void Resize(int size); - + /// Debug function, convert the result to string to print std::string Str(); }; +/*! @brief Segmentation result structure for all the segmentation models + */ struct FASTDEPLOY_DECL SegmentationResult : public BaseResult { - // mask + /** \brief + * `label_map` stores the pixel-level category labels for input image. the number of pixels is equal to label_map.size() + */ std::vector label_map; + /** \brief + * `score_map` stores the probability of the predicted label for each pixel of input image. + */ std::vector score_map; + /// The output shape, means [H, W] std::vector shape; bool contain_score_map = false; ResultType type = ResultType::SEGMENTATION; - + /// Clear detection result void Clear(); void Reserve(int size); void Resize(int size); - + /// Debug function, convert the result to string to print std::string Str(); }; +/*! @brief Face recognition result structure for all the Face recognition models + */ struct FASTDEPLOY_DECL FaceRecognitionResult : public BaseResult { - // face embedding vector with 128/256/512 ... dim + /** \brief The feature embedding that represents the final extraction of the face recognition model can be used to calculate the feature similarity between faces. + */ std::vector embedding; ResultType type = ResultType::FACE_RECOGNITION; FaceRecognitionResult() {} FaceRecognitionResult(const FaceRecognitionResult& res); - + /// Clear detection result void Clear(); void Reserve(int size); void Resize(int size); - + /// Debug function, convert the result to string to print std::string Str(); }; +/*! @brief Matting result structure for all the Matting models + */ struct FASTDEPLOY_DECL MattingResult : public BaseResult { - // alpha matte and fgr (predicted foreground: HWC/BGR float32) + /** \brief + `alpha` is a one-dimensional vector, which is the predicted alpha transparency value. The range of values is [0., 1.], and the length is hxw. h, w are the height and width of the input image + */ std::vector alpha; // h x w + /** \brief + If the model can predict foreground, `foreground` save the predicted foreground image, the shape is [hight,width,channel] generally. + */ std::vector foreground; // h x w x c (c=3 default) - // height, width, channel for foreground and alpha - // must be (h,w,c) and setup before Reserve and Resize - // c is only for foreground if contain_foreground is true. + /** \brief + * The shape of output result, when contain_foreground == false, shape only contains (h, w), when contain_foreground == true, shape contains (h, w, c), and c is generally 3 + */ std::vector shape; + /** \brief + If the model can predict alpha matte and foreground, contain_foreground = true, default false + */ bool contain_foreground = false; ResultType type = ResultType::MATTING; MattingResult() {} MattingResult(const MattingResult& res); - + /// Clear detection result void Clear(); void Reserve(int size); void Resize(int size); - + /// Debug function, convert the result to string to print std::string Str(); }; diff --git a/fastdeploy/vision/detection/contrib/nanodet_plus.h b/fastdeploy/vision/detection/contrib/nanodet_plus.h index 34e353a730..9923e4d37d 100644 --- a/fastdeploy/vision/detection/contrib/nanodet_plus.h +++ b/fastdeploy/vision/detection/contrib/nanodet_plus.h @@ -53,21 +53,23 @@ class FASTDEPLOY_DECL NanoDetPlus : public FastDeployModel { float conf_threshold = 0.35f, float nms_iou_threshold = 0.5f); - /// tuple of input size (width, height), e.g (320, 320) - std::vector size; - /// padding value, size should be the same as channels - std::vector padding_value; /*! @brief - keep aspect ratio or not when perform resize operation. This option is set as `false` by default in NanoDet-Plus + Argument for image preprocessing step, tuple of input size (width, height), e.g (320, 320) */ + std::vector size; + // padding value, size should be the same as channels + std::vector padding_value; + // keep aspect ratio or not when perform resize operation. + // This option is set as `false` by default in NanoDet-Plus bool keep_ratio; - /*! @brief - downsample strides for NanoDet-Plus to generate anchors, will take (8, 16, 32, 64) as default values - */ + // downsample strides for NanoDet-Plus to generate anchors, + // will take (8, 16, 32, 64) as default values std::vector downsample_strides; - /// for offseting the boxes by classes when using NMS, default 4096 + // for offseting the boxes by classes when using NMS, default 4096 float max_wh; - /// reg_max for GFL regression, default 7 + /*! @brief + Argument for image postprocessing step, reg_max for GFL regression, default 7 + */ int reg_max; private: diff --git a/fastdeploy/vision/detection/contrib/scaledyolov4.h b/fastdeploy/vision/detection/contrib/scaledyolov4.h index 963c892ec9..a0108cfa57 100644 --- a/fastdeploy/vision/detection/contrib/scaledyolov4.h +++ b/fastdeploy/vision/detection/contrib/scaledyolov4.h @@ -50,23 +50,23 @@ class FASTDEPLOY_DECL ScaledYOLOv4 : public FastDeployModel { float conf_threshold = 0.25, float nms_iou_threshold = 0.5); - /// tuple of (width, height) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize + */ std::vector size; - /// padding value, size should be the same as channels + // padding value, size should be the same as channels std::vector padding_value; - /// only pad to the minimum rectange which height and width is times of stride + // only pad to the minimum rectange which height and width is times of stride bool is_mini_pad; - /*! @brief - while is_mini_pad = false and is_no_pad = true, will resize the image to the set size - */ + // while is_mini_pad = false and is_no_pad = true, + // will resize the image to the set size bool is_no_pad; - /*! @brief - if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 - */ + // if is_scale_up is false, the input image only can be zoom out, + // the maximum resize scale cannot exceed 1.0 bool is_scale_up; - /// padding stride, for is_mini_pad + // padding stride, for is_mini_pad int stride; - /// for offseting the boxes by classes when using NMS + // for offseting the boxes by classes when using NMS float max_wh; private: diff --git a/fastdeploy/vision/detection/contrib/yolor.h b/fastdeploy/vision/detection/contrib/yolor.h index af6ebf46f8..0f8e23537e 100644 --- a/fastdeploy/vision/detection/contrib/yolor.h +++ b/fastdeploy/vision/detection/contrib/yolor.h @@ -1,4 +1,5 @@ -// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. //NOLINT + + // 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. @@ -48,23 +49,24 @@ class FASTDEPLOY_DECL YOLOR : public FastDeployModel { float conf_threshold = 0.25, float nms_iou_threshold = 0.5); - /// tuple of (width, height) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize + */ std::vector size; - /// padding value, size should be the same as channels + // padding value, size should be the same as channels + std::vector padding_value; - /// only pad to the minimum rectange which height and width is times of stride + // only pad to the minimum rectange which height and width is times of stride bool is_mini_pad; - /*! @brief - while is_mini_pad = false and is_no_pad = true, will resize the image to the set size - */ + // while is_mini_pad = false and is_no_pad = true, + // will resize the image to the set size bool is_no_pad; - /*! @brief - if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 - */ + // if is_scale_up is false, the input image only can be zoom out, + // the maximum resize scale cannot exceed 1.0 bool is_scale_up; - /// padding stride, for is_mini_pad + // padding stride, for is_mini_pad int stride; - /// for offseting the boxes by classes when using NMS + // for offseting the boxes by classes when using NMS float max_wh; private: diff --git a/fastdeploy/vision/detection/contrib/yolov5.h b/fastdeploy/vision/detection/contrib/yolov5.h index e899ad4c54..15d98e6f23 100644 --- a/fastdeploy/vision/detection/contrib/yolov5.h +++ b/fastdeploy/vision/detection/contrib/yolov5.h @@ -77,23 +77,24 @@ class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel { float conf_threshold, float nms_iou_threshold, bool multi_label, float max_wh = 7680.0); - /// tuple of (width, height) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize + */ std::vector size_; - /// padding value, size should be the same as channels + // padding value, size should be the same as channels + std::vector padding_value_; - /// only pad to the minimum rectange which height and width is times of stride + // only pad to the minimum rectange which height and width is times of stride bool is_mini_pad_; - /*! @brief - while is_mini_pad = false and is_no_pad = true, will resize the image to the set size - */ + // while is_mini_pad = false and is_no_pad = true, + // will resize the image to the set size bool is_no_pad_; - /*! @brief - if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 - */ + // if is_scale_up is false, the input image only can be zoom out, + // the maximum resize scale cannot exceed 1.0 bool is_scale_up_; - /// padding stride, for is_mini_pad + // padding stride, for is_mini_pad int stride_; - /// for offseting the boxes by classes when using NMS + // for offseting the boxes by classes when using NMS float max_wh_; /// for different strategies to get boxes when postprocessing bool multi_label_; diff --git a/fastdeploy/vision/detection/contrib/yolov5lite.h b/fastdeploy/vision/detection/contrib/yolov5lite.h index 63717b01ce..8bbcf331ae 100644 --- a/fastdeploy/vision/detection/contrib/yolov5lite.h +++ b/fastdeploy/vision/detection/contrib/yolov5lite.h @@ -53,31 +53,30 @@ class FASTDEPLOY_DECL YOLOv5Lite : public FastDeployModel { void UseCudaPreprocessing(int max_img_size = 3840 * 2160); - /// tuple of (width, height) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize + */ std::vector size; - /// padding value, size should be the same as channels + // padding value, size should be the same as channels + std::vector padding_value; - /// only pad to the minimum rectange which height and width is times of stride + // only pad to the minimum rectange which height and width is times of stride bool is_mini_pad; - /*! @brief - while is_mini_pad = false and is_no_pad = true, will resize the image to the set size - */ + // while is_mini_pad = false and is_no_pad = true, + // will resize the image to the set size bool is_no_pad; - /*! @brief - if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 - */ + // if is_scale_up is false, the input image only can be zoom out, + // the maximum resize scale cannot exceed 1.0 bool is_scale_up; - /// padding stride, for is_mini_pad + // padding stride, for is_mini_pad int stride; - /// for offseting the boxes by classes when using NMS + // for offseting the boxes by classes when using NMS float max_wh; - /*! @brief - downsample strides for YOLOv5Lite to generate anchors, will take (8,16,32) as default values, might have stride=64. - */ + // downsample strides for YOLOv5Lite to generate anchors, + // will take (8,16,32) as default values, might have stride=64. std::vector downsample_strides; - /*! @brief - anchors parameters, downsample_strides will take (8,16,32), each stride has three anchors with width and hight - */ + // anchors parameters, downsample_strides will take (8,16,32), + // each stride has three anchors with width and hight std::vector> anchor_config; /*! @brief whether the model_file was exported with decode module. The official diff --git a/fastdeploy/vision/detection/contrib/yolov5lite_pybind.cc b/fastdeploy/vision/detection/contrib/yolov5lite_pybind.cc index cdd20f1698..b4f765e235 100644 --- a/fastdeploy/vision/detection/contrib/yolov5lite_pybind.cc +++ b/fastdeploy/vision/detection/contrib/yolov5lite_pybind.cc @@ -31,10 +31,12 @@ void BindYOLOv5Lite(pybind11::module& m) { .def("use_cuda_preprocessing", [](vision::detection::YOLOv5Lite& self, int max_image_size) { self.UseCudaPreprocessing(max_image_size); - }) + }) .def_readwrite("size", &vision::detection::YOLOv5Lite::size) .def_readwrite("padding_value", &vision::detection::YOLOv5Lite::padding_value) + .def_readwrite("downsample_strides", + &vision::detection::YOLOv5Lite::downsample_strides) .def_readwrite("is_mini_pad", &vision::detection::YOLOv5Lite::is_mini_pad) .def_readwrite("is_no_pad", &vision::detection::YOLOv5Lite::is_no_pad) .def_readwrite("is_scale_up", &vision::detection::YOLOv5Lite::is_scale_up) diff --git a/fastdeploy/vision/detection/contrib/yolov6.h b/fastdeploy/vision/detection/contrib/yolov6.h index b90197a2e1..1e0af6fd33 100644 --- a/fastdeploy/vision/detection/contrib/yolov6.h +++ b/fastdeploy/vision/detection/contrib/yolov6.h @@ -56,25 +56,25 @@ class FASTDEPLOY_DECL YOLOv6 : public FastDeployModel { void UseCudaPreprocessing(int max_img_size = 3840 * 2160); - /// tuple of (width, height) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize + */ std::vector size; - /// padding value, size should be the same as channels + // padding value, size should be the same as channels + std::vector padding_value; - /// only pad to the minimum rectange which height and width is times of stride + // only pad to the minimum rectange which height and width is times of stride bool is_mini_pad; - /*! @brief - while is_mini_pad = false and is_no_pad = true, will resize the image to the set size - */ + // while is_mini_pad = false and is_no_pad = true, + // will resize the image to the set size bool is_no_pad; - /*! @brief - if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 - */ + // if is_scale_up is false, the input image only can be zoom out, + // the maximum resize scale cannot exceed 1.0 bool is_scale_up; - /// padding stride, for is_mini_pad + // padding stride, for is_mini_pad int stride; - /*! @brief - 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; private: diff --git a/fastdeploy/vision/detection/contrib/yolov7.h b/fastdeploy/vision/detection/contrib/yolov7.h index e7921061d8..2eb038f719 100644 --- a/fastdeploy/vision/detection/contrib/yolov7.h +++ b/fastdeploy/vision/detection/contrib/yolov7.h @@ -53,23 +53,24 @@ class FASTDEPLOY_DECL YOLOv7 : public FastDeployModel { void UseCudaPreprocessing(int max_img_size = 3840 * 2160); - /// tuple of (width, height) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize + */ std::vector size; - /// padding value, size should be the same as channels + // padding value, size should be the same as channels + std::vector padding_value; - /// only pad to the minimum rectange which height and width is times of stride + // only pad to the minimum rectange which height and width is times of stride bool is_mini_pad; - /*! @brief - while is_mini_pad = false and is_no_pad = true, will resize the image to the set size - */ + // while is_mini_pad = false and is_no_pad = true, + // will resize the image to the set size bool is_no_pad; - /*! @brief - if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 - */ + // if is_scale_up is false, the input image only can be zoom out, + // the maximum resize scale cannot exceed 1.0 bool is_scale_up; - /// padding stride, for is_mini_pad + // padding stride, for is_mini_pad int stride; - /// for offseting the boxes by classes when using NMS + // for offseting the boxes by classes when using NMS float max_wh; private: diff --git a/fastdeploy/vision/detection/contrib/yolov7end2end_ort.h b/fastdeploy/vision/detection/contrib/yolov7end2end_ort.h index 6e0c0d578b..9434d69edb 100644 --- a/fastdeploy/vision/detection/contrib/yolov7end2end_ort.h +++ b/fastdeploy/vision/detection/contrib/yolov7end2end_ort.h @@ -47,21 +47,22 @@ class FASTDEPLOY_DECL YOLOv7End2EndORT : public FastDeployModel { virtual bool Predict(cv::Mat* im, DetectionResult* result, float conf_threshold = 0.25); - /// tuple of (width, height) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize + */ std::vector size; - /// padding value, size should be the same as channels + // padding value, size should be the same as channels + std::vector padding_value; - /// only pad to the minimum rectange which height and width is times of stride + // only pad to the minimum rectange which height and width is times of stride bool is_mini_pad; - /*! @brief - while is_mini_pad = false and is_no_pad = true, will resize the image to the set size - */ + // while is_mini_pad = false and is_no_pad = true, + // will resize the image to the set size bool is_no_pad; - /*! @brief - if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 - */ + // if is_scale_up is false, the input image only can be zoom out, + // the maximum resize scale cannot exceed 1.0 bool is_scale_up; - /// padding stride, for is_mini_pad + // padding stride, for is_mini_pad int stride; private: diff --git a/fastdeploy/vision/detection/contrib/yolov7end2end_trt.h b/fastdeploy/vision/detection/contrib/yolov7end2end_trt.h index 3a2494d493..f6ce6e943f 100644 --- a/fastdeploy/vision/detection/contrib/yolov7end2end_trt.h +++ b/fastdeploy/vision/detection/contrib/yolov7end2end_trt.h @@ -52,21 +52,22 @@ class FASTDEPLOY_DECL YOLOv7End2EndTRT : public FastDeployModel { void UseCudaPreprocessing(int max_img_size = 3840 * 2160); - /// tuple of (width, height) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize + */ std::vector size; - /// padding value, size should be the same as channels + // padding value, size should be the same as channels + std::vector padding_value; - /// only pad to the minimum rectange which height and width is times of stride + // only pad to the minimum rectange which height and width is times of stride bool is_mini_pad; - /*! @brief - while is_mini_pad = false and is_no_pad = true, will resize the image to the set size - */ + // while is_mini_pad = false and is_no_pad = true, + // will resize the image to the set size bool is_no_pad; - /*! @brief - if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 - */ + // if is_scale_up is false, the input image only can be zoom out, + // the maximum resize scale cannot exceed 1.0 bool is_scale_up; - /// padding stride, for is_mini_pad + // padding stride, for is_mini_pad int stride; private: diff --git a/fastdeploy/vision/detection/contrib/yolox.h b/fastdeploy/vision/detection/contrib/yolox.h index 07522832cc..c040c28a8e 100644 --- a/fastdeploy/vision/detection/contrib/yolox.h +++ b/fastdeploy/vision/detection/contrib/yolox.h @@ -51,9 +51,11 @@ class FASTDEPLOY_DECL YOLOX : public FastDeployModel { float conf_threshold = 0.25, float nms_iou_threshold = 0.5); - /// tuple of (width, height) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize + */ std::vector size; - /// padding value, size should be the same as channels + // padding value, size should be the same as channels std::vector padding_value; /*! @brief whether the model_file was exported with decode module. The official @@ -62,11 +64,10 @@ class FASTDEPLOY_DECL YOLOX : public FastDeployModel { was exported with decode module. */ bool is_decode_exported; - /*! @brief - downsample strides for YOLOX to generate anchors, will take (8,16,32) as default values, might have stride=64 - */ + // downsample strides for YOLOX to generate anchors, + // will take (8,16,32) as default values, might have stride=64 std::vector downsample_strides; - /// for offseting the boxes by classes when using NMS, default 4096 + // for offseting the boxes by classes when using NMS, default 4096 float max_wh; private: diff --git a/fastdeploy/vision/facedet/contrib/retinaface.h b/fastdeploy/vision/facedet/contrib/retinaface.h index 33708586a9..e7011df89d 100644 --- a/fastdeploy/vision/facedet/contrib/retinaface.h +++ b/fastdeploy/vision/facedet/contrib/retinaface.h @@ -52,19 +52,25 @@ class FASTDEPLOY_DECL RetinaFace : public FastDeployModel { float conf_threshold = 0.25f, float nms_iou_threshold = 0.4f); - /// tuple of (width, height), default (640, 640) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize, default (640, 640) + */ std::vector size; /*! @brief - variance in RetinaFace's prior-box(anchor) generate process, default (0.1, 0.2) + Argument for image postprocessing step, variance in RetinaFace's prior-box(anchor) generate process, default (0.1, 0.2) */ std::vector variance; /*! @brief - downsample strides (namely, steps) for RetinaFace to generate anchors, will take (8,16,32) as default values + Argument for image postprocessing step, downsample strides (namely, steps) for RetinaFace to generate anchors, will take (8,16,32) as default values */ std::vector downsample_strides; - /// min sizes, width and height for each anchor + /*! @brief + Argument for image postprocessing step, min sizes, width and height for each anchor + */ std::vector> min_sizes; - /// landmarks_per_face, default 5 in RetinaFace + /*! @brief + Argument for image postprocessing step, landmarks_per_face, default 5 in RetinaFace + */ int landmarks_per_face; private: diff --git a/fastdeploy/vision/facedet/contrib/scrfd.h b/fastdeploy/vision/facedet/contrib/scrfd.h index 964e9ac494..58dd8807b9 100644 --- a/fastdeploy/vision/facedet/contrib/scrfd.h +++ b/fastdeploy/vision/facedet/contrib/scrfd.h @@ -51,33 +51,40 @@ class FASTDEPLOY_DECL SCRFD : public FastDeployModel { float conf_threshold = 0.25f, float nms_iou_threshold = 0.4f); - /// tuple of (width, height), default (640, 640) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize, default (640, 640) + */ std::vector size; - /// padding value, size should be the same as channels + // padding value, size should be the same as channels + std::vector padding_value; - /// only pad to the minimum rectange which height and width is times of stride + // only pad to the minimum rectange which height and width is times of stride bool is_mini_pad; - /*! @brief - while is_mini_pad = false and is_no_pad = true, will resize the image to the set size - */ + // while is_mini_pad = false and is_no_pad = true, + // will resize the image to the set size bool is_no_pad; - /*! @brief - if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 - */ + // if is_scale_up is false, the input image only can be zoom out, + // the maximum resize scale cannot exceed 1.0 bool is_scale_up; - /// padding stride, for is_mini_pad + // padding stride, for is_mini_pad int stride; /*! @brief - downsample strides (namely, steps) for SCRFD to generate anchors, will take (8,16,32) as default values + Argument for image postprocessing step, downsample strides (namely, steps) for SCRFD to generate anchors, will take (8,16,32) as default values */ std::vector downsample_strides; - /// landmarks_per_face, default 5 in SCRFD + /*! @brief + Argument for image postprocessing step, landmarks_per_face, default 5 in SCRFD + */ int landmarks_per_face; - /// the outputs of onnx file with key points features or not + /*! @brief + Argument for image postprocessing step, the outputs of onnx file with key points features or not + */ bool use_kps; - /// the upperbond number of boxes processed by nms + /*! @brief + Argument for image postprocessing step, the upperbond number of boxes processed by nms + */ int max_nms; - /// number anchors of each stride + /// Argument for image postprocessing step, anchor number of each stride unsigned int num_anchors; private: diff --git a/fastdeploy/vision/facedet/contrib/ultraface.h b/fastdeploy/vision/facedet/contrib/ultraface.h index ebe1da986b..960bc0f5e1 100644 --- a/fastdeploy/vision/facedet/contrib/ultraface.h +++ b/fastdeploy/vision/facedet/contrib/ultraface.h @@ -52,7 +52,9 @@ class FASTDEPLOY_DECL UltraFace : public FastDeployModel { float conf_threshold = 0.7f, float nms_iou_threshold = 0.3f); - /// tuple of (width, height), default (320, 240) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize, default (320, 240) + */ std::vector size; private: diff --git a/fastdeploy/vision/facedet/contrib/yolov5face.h b/fastdeploy/vision/facedet/contrib/yolov5face.h index 921d68cce7..10479052de 100644 --- a/fastdeploy/vision/facedet/contrib/yolov5face.h +++ b/fastdeploy/vision/facedet/contrib/yolov5face.h @@ -50,26 +50,27 @@ class FASTDEPLOY_DECL YOLOv5Face : public FastDeployModel { float conf_threshold = 0.25, float nms_iou_threshold = 0.5); - /// tuple of (width, height) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize + */ std::vector size; - /// padding value, size should be the same as channels + // padding value, size should be the same as channels + std::vector padding_value; - /// only pad to the minimum rectange which height and width is times of stride + // only pad to the minimum rectange which height and width is times of stride bool is_mini_pad; - /*! @brief - while is_mini_pad = false and is_no_pad = true, will resize the image to the set size - */ + // while is_mini_pad = false and is_no_pad = true, + // will resize the image to the set size bool is_no_pad; - /*! @brief - if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 - */ + // if is_scale_up is false, the input image only can be zoom out, + // the maximum resize scale cannot exceed 1.0 bool is_scale_up; - /// padding stride, for is_mini_pad + // padding stride, for is_mini_pad int stride; /*! @brief - setup the number of landmarks for per face (if have), default 5 in + Argument for image postprocessing step, setup the number of landmarks for per face (if have), default 5 in official yolov5face note that, the outupt tensor's shape must be: (1,n,4+1+2*landmarks_per_face+1=box+obj+landmarks+cls) */ diff --git a/fastdeploy/vision/faceid/contrib/insightface_rec.h b/fastdeploy/vision/faceid/contrib/insightface_rec.h index e12765a20c..12f882d7aa 100644 --- a/fastdeploy/vision/faceid/contrib/insightface_rec.h +++ b/fastdeploy/vision/faceid/contrib/insightface_rec.h @@ -40,15 +40,21 @@ class FASTDEPLOY_DECL InsightFaceRecognitionModel : public FastDeployModel { virtual std::string ModelName() const { return "deepinsight/insightface"; } - /// tuple of (width, height), default (112, 112) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize, default (112, 112) + */ std::vector size; - /// alpha values for normalization + /// Argument for image preprocessing step, alpha values for normalization std::vector alpha; - /// beta values for normalization + /// Argument for image preprocessing step, beta values for normalization std::vector beta; - /// whether to swap the B and R channel, such as BGR->RGB, default true. + /*! @brief + Argument for image preprocessing step, whether to swap the B and R channel, such as BGR->RGB, default true. + */ bool swap_rb; - /// whether to apply l2 normalize to embedding values, default; + /*! @brief + Argument for image postprocessing step, whether to apply l2 normalize to embedding values, default false; + */ bool l2_normalize; /** \brief Predict the face recognition result for an input image * diff --git a/fastdeploy/vision/matting/contrib/modnet.h b/fastdeploy/vision/matting/contrib/modnet.h index 3e53e1ba6f..75148b60a1 100644 --- a/fastdeploy/vision/matting/contrib/modnet.h +++ b/fastdeploy/vision/matting/contrib/modnet.h @@ -39,13 +39,21 @@ class FASTDEPLOY_DECL MODNet : public FastDeployModel { std::string ModelName() const { return "matting/MODNet"; } - /// tuple of (width, height), default (256, 256) + /*! @brief + Argument for image preprocessing step, tuple of (width, height), decide the target size after resize, default (256, 256) + */ std::vector size; - /// parameters for normalization + /*! @brief + Argument for image preprocessing step, parameters for normalization, size should be the the same as channels + */ std::vector alpha; - /// parameters for normalization + /*! @brief + Argument for image preprocessing step, parameters for normalization, size should be the the same as channels + */ std::vector beta; - /// whether to swap the B and R channel, such as BGR->RGB, default true. + /*! @brief + Argument for image preprocessing step, whether to swap the B and R channel, such as BGR->RGB, default true. + */ bool swap_rb; /** \brief Predict the matting result for an input image * diff --git a/python/fastdeploy/vision/detection/contrib/nanodet_plus.py b/python/fastdeploy/vision/detection/contrib/nanodet_plus.py index a46dd7a9e6..b5a83fe2b2 100644 --- a/python/fastdeploy/vision/detection/contrib/nanodet_plus.py +++ b/python/fastdeploy/vision/detection/contrib/nanodet_plus.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a NanoDetPlus model exported by NanoDet. + + :param model_file: (str)Path of model file, e.g ./nanodet.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(NanoDetPlus, self).__init__(runtime_option) @@ -34,6 +41,13 @@ def __init__(self, assert self.initialized, "NanoDetPlus initialize failed." def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): + """Detect an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.25 + :param nms_iou_threshold: iou threashold for NMS, default is 0.5 + :return: DetectionResult + """ return self._model.predict(input_image, conf_threshold, nms_iou_threshold) @@ -41,26 +55,36 @@ def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): # 多数是预处理相关,可通过修改如model.size = [416, 416]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def padding_value(self): + # padding value, size should be the same as channels return self._model.padding_value @property def keep_ratio(self): + # keep aspect ratio or not when perform resize operation. This option is set as false by default in NanoDet-Plus return self._model.keep_ratio @property def downsample_strides(self): + # downsample strides for NanoDet-Plus to generate anchors, will take (8, 16, 32, 64) as default values return self._model.downsample_strides @property def max_wh(self): + # for offseting the boxes by classes when using NMS, default 4096 return self._model.max_wh @property def reg_max(self): + """ + reg_max for GFL regression, default 7 + """ return self._model.reg_max @size.setter diff --git a/python/fastdeploy/vision/detection/contrib/scaled_yolov4.py b/python/fastdeploy/vision/detection/contrib/scaled_yolov4.py index aebb60fb00..1e46ba1a14 100644 --- a/python/fastdeploy/vision/detection/contrib/scaled_yolov4.py +++ b/python/fastdeploy/vision/detection/contrib/scaled_yolov4.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a ScaledYOLOv4 model exported by ScaledYOLOv4. + + :param model_file: (str)Path of model file, e.g ./scaled_yolov4.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(ScaledYOLOv4, self).__init__(runtime_option) @@ -34,6 +41,13 @@ def __init__(self, assert self.initialized, "ScaledYOLOv4 initialize failed." def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): + """Detect an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.25 + :param nms_iou_threshold: iou threashold for NMS, default is 0.5 + :return: DetectionResult + """ return self._model.predict(input_image, conf_threshold, nms_iou_threshold) @@ -41,30 +55,39 @@ def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): # 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def padding_value(self): + # padding value, size should be the same as channels return self._model.padding_value @property def is_no_pad(self): + # while is_mini_pad = false and is_no_pad = true, will resize the image to the set size return self._model.is_no_pad @property def is_mini_pad(self): + # only pad to the minimum rectange which height and width is times of stride return self._model.is_mini_pad @property def is_scale_up(self): + # if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 return self._model.is_scale_up @property def stride(self): + # padding stride, for is_mini_pad return self._model.stride @property def max_wh(self): + # for offseting the boxes by classes when using NMS return self._model.max_wh @size.setter @@ -92,19 +115,21 @@ def is_no_pad(self, 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." + value, + bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, bool), "The value to set `is_scale_up` must be type of bool." + value, + bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance(value, - int), "The value to set `stride` must be type of int." + assert isinstance( + value, int), "The value to set `stride` must be type of int." self._model.stride = value @max_wh.setter diff --git a/python/fastdeploy/vision/detection/contrib/yolor.py b/python/fastdeploy/vision/detection/contrib/yolor.py index 0545076128..6326630e1a 100644 --- a/python/fastdeploy/vision/detection/contrib/yolor.py +++ b/python/fastdeploy/vision/detection/contrib/yolor.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a YOLOR model exported by YOLOR + + :param model_file: (str)Path of model file, e.g ./yolor.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOR, self).__init__(runtime_option) @@ -34,6 +41,13 @@ def __init__(self, assert self.initialized, "YOLOR initialize failed." def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): + """Detect an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.25 + :param nms_iou_threshold: iou threashold for NMS, default is 0.5 + :return: DetectionResult + """ return self._model.predict(input_image, conf_threshold, nms_iou_threshold) @@ -41,30 +55,39 @@ def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): # 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def padding_value(self): + # padding value, size should be the same as channels return self._model.padding_value @property def is_no_pad(self): + # while is_mini_pad = false and is_no_pad = true, will resize the image to the set size return self._model.is_no_pad @property def is_mini_pad(self): + # only pad to the minimum rectange which height and width is times of stride return self._model.is_mini_pad @property def is_scale_up(self): + # if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 return self._model.is_scale_up @property def stride(self): + # padding stride, for is_mini_pad return self._model.stride @property def max_wh(self): + # for offseting the boxes by classes when using NMS return self._model.max_wh @size.setter @@ -92,19 +115,21 @@ def is_no_pad(self, 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." + value, + bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, bool), "The value to set `is_scale_up` must be type of bool." + value, + bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance(value, - int), "The value to set `stride` must be type of int." + assert isinstance( + value, int), "The value to set `stride` must be type of int." self._model.stride = value @max_wh.setter diff --git a/python/fastdeploy/vision/detection/contrib/yolov5.py b/python/fastdeploy/vision/detection/contrib/yolov5.py index 9fdd2b77ec..a5068df5e7 100644 --- a/python/fastdeploy/vision/detection/contrib/yolov5.py +++ b/python/fastdeploy/vision/detection/contrib/yolov5.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a YOLOv5 model exported by YOLOv5. + + :param model_file: (str)Path of model file, e.g ./yolov5.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv5, self).__init__(runtime_option) @@ -34,12 +41,16 @@ def __init__(self, assert self.initialized, "YOLOv5 initialize failed." def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): + """Detect an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.25 + :param nms_iou_threshold: iou threashold for NMS, default is 0.5 + :return: DetectionResult + """ return self._model.predict(input_image, conf_threshold, nms_iou_threshold) - def use_cuda_preprocessing(self, max_image_size=3840 * 2160): - return self._model.use_cuda_preprocessing(max_image_size) - @staticmethod def preprocess(input_image, size=[640, 640], @@ -69,30 +80,39 @@ def postprocess(infer_result, # 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def padding_value(self): + # padding value, size should be the same as channels return self._model.padding_value @property def is_no_pad(self): + # while is_mini_pad = false and is_no_pad = true, will resize the image to the set size return self._model.is_no_pad @property def is_mini_pad(self): + # only pad to the minimum rectange which height and width is times of stride return self._model.is_mini_pad @property def is_scale_up(self): + # if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 return self._model.is_scale_up @property def stride(self): + # padding stride, for is_mini_pad return self._model.stride @property def max_wh(self): + # for offseting the boxes by classes when using NMS return self._model.max_wh @property @@ -124,19 +144,21 @@ def is_no_pad(self, 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." + value, + bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, bool), "The value to set `is_scale_up` must be type of bool." + value, + bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance(value, - int), "The value to set `stride` must be type of int." + assert isinstance( + value, int), "The value to set `stride` must be type of int." self._model.stride = value @max_wh.setter @@ -148,5 +170,6 @@ def max_wh(self, value): @multi_label.setter def multi_label(self, value): assert isinstance( - value, bool), "The value to set `multi_label` must be type of bool." + value, + bool), "The value to set `multi_label` must be type of bool." self._model.multi_label = value diff --git a/python/fastdeploy/vision/detection/contrib/yolov5lite.py b/python/fastdeploy/vision/detection/contrib/yolov5lite.py index f502777404..606dc98c43 100644 --- a/python/fastdeploy/vision/detection/contrib/yolov5lite.py +++ b/python/fastdeploy/vision/detection/contrib/yolov5lite.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a YOLOv5Lite model exported by YOLOv5Lite. + + :param model_file: (str)Path of model file, e.g ./yolov5lite.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv5Lite, self).__init__(runtime_option) @@ -34,50 +41,76 @@ def __init__(self, assert self.initialized, "YOLOv5Lite initialize failed." def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): + """Detect an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.25 + :param nms_iou_threshold: iou threashold for NMS, default is 0.5 + :return: DetectionResult + """ return self._model.predict(input_image, conf_threshold, nms_iou_threshold) - def use_cuda_preprocessing(self, max_image_size=3840 * 2160): - return self._model.use_cuda_preprocessing(max_image_size) - # 一些跟YOLOv5Lite模型有关的属性封装 # 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def padding_value(self): + # padding value, size should be the same as channels return self._model.padding_value @property def is_no_pad(self): + # while is_mini_pad = false and is_no_pad = true, will resize the image to the set size return self._model.is_no_pad @property def is_mini_pad(self): + # only pad to the minimum rectange which height and width is times of stride return self._model.is_mini_pad @property def is_scale_up(self): + # if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 return self._model.is_scale_up @property def stride(self): + # padding stride, for is_mini_pad return self._model.stride @property def max_wh(self): + # for offseting the boxes by classes when using NMS return self._model.max_wh @property def is_decode_exported(self): + """ + whether the model_file was exported with decode module. + The official YOLOv5Lite/export.py script will export ONNX file without decode module. + Please set it 'true' manually if the model file was exported with decode module. + false : ONNX files without decode module. true : ONNX file with decode module. + """ return self._model.is_decode_exported @property def anchor_config(self): return self._model.anchor_config + @property + def downsample_strides(self): + """ + downsample strides for YOLOv5Lite to generate anchors, will take (8,16,32) as default values, might have stride=64. + """ + return self._model.downsample_strides + @size.setter def size(self, wh): assert isinstance(wh, (list, tuple)),\ @@ -103,19 +136,21 @@ def is_no_pad(self, 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." + value, + bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, bool), "The value to set `is_scale_up` must be type of bool." + value, + bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance(value, - int), "The value to set `stride` must be type of int." + assert isinstance( + value, int), "The value to set `stride` must be type of int." self._model.stride = value @max_wh.setter @@ -138,3 +173,10 @@ def anchor_config(self, anchor_config_val): assert isinstance(anchor_config_val[0], list),\ "The value to set `anchor_config` must be 2-dimensions tuple or list" self._model.anchor_config = anchor_config_val + + @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 diff --git a/python/fastdeploy/vision/detection/contrib/yolov6.py b/python/fastdeploy/vision/detection/contrib/yolov6.py index 5e09de4d6a..9f95331144 100644 --- a/python/fastdeploy/vision/detection/contrib/yolov6.py +++ b/python/fastdeploy/vision/detection/contrib/yolov6.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a YOLOv6 model exported by YOLOv6. + + :param model_file: (str)Path of model file, e.g ./yolov6.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv6, self).__init__(runtime_option) @@ -34,40 +41,53 @@ def __init__(self, assert self.initialized, "YOLOv6 initialize failed." def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): + """Detect an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.25 + :param nms_iou_threshold: iou threashold for NMS, default is 0.5 + :return: DetectionResult + """ return self._model.predict(input_image, conf_threshold, nms_iou_threshold) - def use_cuda_preprocessing(self, max_image_size=3840 * 2160): - return self._model.use_cuda_preprocessing(max_image_size) - # 一些跟YOLOv6模型有关的属性封装 # 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def padding_value(self): + # padding value, size should be the same as channels return self._model.padding_value @property def is_no_pad(self): + # while is_mini_pad = false and is_no_pad = true, will resize the image to the set size return self._model.is_no_pad @property def is_mini_pad(self): + # only pad to the minimum rectange which height and width is times of stride return self._model.is_mini_pad @property def is_scale_up(self): + # if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 return self._model.is_scale_up @property def stride(self): + # padding stride, for is_mini_pad return self._model.stride @property def max_wh(self): + # for offseting the boxes by classes when using NMS return self._model.max_wh @size.setter @@ -95,19 +115,21 @@ def is_no_pad(self, 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." + value, + bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, bool), "The value to set `is_scale_up` must be type of bool." + value, + bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance(value, - int), "The value to set `stride` must be type of int." + assert isinstance( + value, int), "The value to set `stride` must be type of int." self._model.stride = value @max_wh.setter diff --git a/python/fastdeploy/vision/detection/contrib/yolov7.py b/python/fastdeploy/vision/detection/contrib/yolov7.py index a102fd83ae..53ef24a101 100644 --- a/python/fastdeploy/vision/detection/contrib/yolov7.py +++ b/python/fastdeploy/vision/detection/contrib/yolov7.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a YOLOv7 model exported by YOLOv7. + + :param model_file: (str)Path of model file, e.g ./yolov7.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv7, self).__init__(runtime_option) @@ -34,40 +41,53 @@ def __init__(self, assert self.initialized, "YOLOv7 initialize failed." def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): + """Detect an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.25 + :param nms_iou_threshold: iou threashold for NMS, default is 0.5 + :return: DetectionResult + """ return self._model.predict(input_image, conf_threshold, nms_iou_threshold) - def use_cuda_preprocessing(self, max_image_size=3840 * 2160): - return self._model.use_cuda_preprocessing(max_image_size) - # 一些跟YOLOv7模型有关的属性封装 # 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def padding_value(self): + # padding value, size should be the same as channels return self._model.padding_value @property def is_no_pad(self): + # while is_mini_pad = false and is_no_pad = true, will resize the image to the set size return self._model.is_no_pad @property def is_mini_pad(self): + # only pad to the minimum rectange which height and width is times of stride return self._model.is_mini_pad @property def is_scale_up(self): + # if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 return self._model.is_scale_up @property def stride(self): + # padding stride, for is_mini_pad return self._model.stride @property def max_wh(self): + # for offseting the boxes by classes when using NMS return self._model.max_wh @size.setter @@ -95,19 +115,21 @@ def is_no_pad(self, 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." + value, + bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, bool), "The value to set `is_scale_up` must be type of bool." + value, + bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance(value, - int), "The value to set `stride` must be type of int." + assert isinstance( + value, int), "The value to set `stride` must be type of int." self._model.stride = value @max_wh.setter diff --git a/python/fastdeploy/vision/detection/contrib/yolov7end2end_ort.py b/python/fastdeploy/vision/detection/contrib/yolov7end2end_ort.py index 41b79f7862..e16ec6a901 100644 --- a/python/fastdeploy/vision/detection/contrib/yolov7end2end_ort.py +++ b/python/fastdeploy/vision/detection/contrib/yolov7end2end_ort.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a YOLOv7End2EndORT model exported by YOLOv7. + + :param model_file: (str)Path of model file, e.g ./yolov7end2end_ort.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv7End2EndORT, self).__init__(runtime_option) @@ -34,32 +41,46 @@ def __init__(self, assert self.initialized, "YOLOv7End2End initialize failed." def predict(self, input_image, conf_threshold=0.25): + """Detect an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.25 + :return: DetectionResult + """ return self._model.predict(input_image, conf_threshold) # 一些跟模型有关的属性封装 # 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def padding_value(self): + # padding value, size should be the same as channels return self._model.padding_value @property def is_no_pad(self): + # while is_mini_pad = false and is_no_pad = true, will resize the image to the set size return self._model.is_no_pad @property def is_mini_pad(self): + # only pad to the minimum rectange which height and width is times of stride return self._model.is_mini_pad @property def is_scale_up(self): + # if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 return self._model.is_scale_up @property def stride(self): + # padding stride, for is_mini_pad return self._model.stride @size.setter @@ -87,17 +108,19 @@ def is_no_pad(self, 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." + value, + bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, bool), "The value to set `is_scale_up` must be type of bool." + value, + bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance(value, - int), "The value to set `stride` must be type of int." + assert isinstance( + value, int), "The value to set `stride` must be type of int." self._model.stride = value diff --git a/python/fastdeploy/vision/detection/contrib/yolov7end2end_trt.py b/python/fastdeploy/vision/detection/contrib/yolov7end2end_trt.py index d0c2e90ac1..4a2621b44c 100644 --- a/python/fastdeploy/vision/detection/contrib/yolov7end2end_trt.py +++ b/python/fastdeploy/vision/detection/contrib/yolov7end2end_trt.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a YOLOv7End2EndTRT model exported by YOLOv7. + + :param model_file: (str)Path of model file, e.g ./yolov7end2end_trt.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv7End2EndTRT, self).__init__(runtime_option) @@ -34,35 +41,46 @@ def __init__(self, assert self.initialized, "YOLOv7End2EndTRT initialize failed." def predict(self, input_image, conf_threshold=0.25): - return self._model.predict(input_image, conf_threshold) + """Detect an input image - def use_cuda_preprocessing(self, max_image_size=3840 * 2160): - return self._model.use_cuda_preprocessing(max_image_size) + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.25 + :return: DetectionResult + """ + return self._model.predict(input_image, conf_threshold) # 一些跟模型有关的属性封装 # 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def padding_value(self): + # padding value, size should be the same as channels return self._model.padding_value @property def is_no_pad(self): + # while is_mini_pad = false and is_no_pad = true, will resize the image to the set size return self._model.is_no_pad @property def is_mini_pad(self): + # only pad to the minimum rectange which height and width is times of stride return self._model.is_mini_pad @property def is_scale_up(self): + # if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 return self._model.is_scale_up @property def stride(self): + # padding stride, for is_mini_pad return self._model.stride @size.setter @@ -90,17 +108,19 @@ def is_no_pad(self, 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." + value, + bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, bool), "The value to set `is_scale_up` must be type of bool." + value, + bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance(value, - int), "The value to set `stride` must be type of int." + assert isinstance( + value, int), "The value to set `stride` must be type of int." self._model.stride = value diff --git a/python/fastdeploy/vision/detection/contrib/yolox.py b/python/fastdeploy/vision/detection/contrib/yolox.py index e7f0da1aad..c121cd8026 100644 --- a/python/fastdeploy/vision/detection/contrib/yolox.py +++ b/python/fastdeploy/vision/detection/contrib/yolox.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a YOLOX model exported by YOLOX. + + :param model_file: (str)Path of model file, e.g ./yolox.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOX, self).__init__(runtime_option) @@ -34,6 +41,13 @@ def __init__(self, assert self.initialized, "YOLOX initialize failed." def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): + """Detect an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.25 + :param nms_iou_threshold: iou threashold for NMS, default is 0.5 + :return: DetectionResult + """ return self._model.predict(input_image, conf_threshold, nms_iou_threshold) @@ -41,22 +55,35 @@ def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): # 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def padding_value(self): + # padding value, size should be the same as channels return self._model.padding_value @property def is_decode_exported(self): + """ + whether the model_file was exported with decode module. + The official YOLOX/tools/export_onnx.py script will export ONNX file without decode module. + Please set it 'true' manually if the model file was exported with decode module. + """ return self._model.is_decode_exported @property def downsample_strides(self): + """ + downsample strides for YOLOX to generate anchors, will take (8,16,32) as default values, might have stride=64. + """ return self._model.downsample_strides @property def max_wh(self): + # for offseting the boxes by classes when using NMS return self._model.max_wh @size.setter diff --git a/python/fastdeploy/vision/facedet/contrib/retinaface.py b/python/fastdeploy/vision/facedet/contrib/retinaface.py index 88eb3ccb36..9afa5055c6 100644 --- a/python/fastdeploy/vision/facedet/contrib/retinaface.py +++ b/python/fastdeploy/vision/facedet/contrib/retinaface.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a RetinaFace model exported by RetinaFace. + + :param model_file: (str)Path of model file, e.g ./retinaface.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(RetinaFace, self).__init__(runtime_option) @@ -34,6 +41,13 @@ def __init__(self, assert self.initialized, "RetinaFace initialize failed." def predict(self, input_image, conf_threshold=0.7, nms_iou_threshold=0.3): + """Detect the location and key points of human faces from an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.7 + :param nms_iou_threshold: iou threashold for NMS, default is 0.3 + :return: FaceDetectionResult + """ return self._model.predict(input_image, conf_threshold, nms_iou_threshold) @@ -41,22 +55,37 @@ def predict(self, input_image, conf_threshold=0.7, nms_iou_threshold=0.3): # 多数是预处理相关,可通过修改如model.size = [640, 480]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def variance(self): + """ + Argument for image postprocessing step, variance in RetinaFace's prior-box(anchor) generate process, default (0.1, 0.2) + """ return self._model.variance @property def downsample_strides(self): + """ + Argument for image postprocessing step, downsample strides (namely, steps) for RetinaFace to generate anchors, will take (8,16,32) as default values + """ return self._model.downsample_strides @property def min_sizes(self): + """ + Argument for image postprocessing step, min sizes, width and height for each anchor + """ return self._model.min_sizes @property def landmarks_per_face(self): + """ + Argument for image postprocessing step, landmarks_per_face, default 5 in RetinaFace + """ return self._model.landmarks_per_face @size.setter diff --git a/python/fastdeploy/vision/facedet/contrib/scrfd.py b/python/fastdeploy/vision/facedet/contrib/scrfd.py index bdf4ea08eb..fa8e1cfd7d 100644 --- a/python/fastdeploy/vision/facedet/contrib/scrfd.py +++ b/python/fastdeploy/vision/facedet/contrib/scrfd.py @@ -24,16 +24,30 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a SCRFD model exported by SCRFD. + + :param model_file: (str)Path of model file, e.g ./scrfd.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(SCRFD, self).__init__(runtime_option) - self._model = C.vision.facedet.SCRFD(model_file, params_file, - self._runtime_option, model_format) + self._model = C.vision.facedet.SCRFD( + model_file, params_file, self._runtime_option, model_format) # 通过self.initialized判断整个模型的初始化是否成功 assert self.initialized, "SCRFD initialize failed." def predict(self, input_image, conf_threshold=0.7, nms_iou_threshold=0.3): + """Detect the location and key points of human faces from an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.7 + :param nms_iou_threshold: iou threashold for NMS, default is 0.3 + :return: FaceDetectionResult + """ return self._model.predict(input_image, conf_threshold, nms_iou_threshold) @@ -41,26 +55,34 @@ def predict(self, input_image, conf_threshold=0.7, nms_iou_threshold=0.3): # 多数是预处理相关,可通过修改如model.size = [640, 640]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def padding_value(self): + # padding value, size should be the same as channels return self._model.padding_value @property def is_no_pad(self): + # while is_mini_pad = false and is_no_pad = true, will resize the image to the set size return self._model.is_no_pad @property def is_mini_pad(self): + # only pad to the minimum rectange which height and width is times of stride return self._model.is_mini_pad @property def is_scale_up(self): + # if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 return self._model.is_scale_up @property def stride(self): + # padding stride, for is_mini_pad return self._model.stride @property @@ -108,19 +130,21 @@ def is_no_pad(self, 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." + value, + bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, bool), "The value to set `is_scale_up` must be type of bool." + value, + bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance(value, - int), "The value to set `stride` must be type of int." + assert isinstance( + value, int), "The value to set `stride` must be type of int." self._model.stride = value @downsample_strides.setter diff --git a/python/fastdeploy/vision/facedet/contrib/ultraface.py b/python/fastdeploy/vision/facedet/contrib/ultraface.py index 3228833db1..8d84a6d86f 100644 --- a/python/fastdeploy/vision/facedet/contrib/ultraface.py +++ b/python/fastdeploy/vision/facedet/contrib/ultraface.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a UltraFace model exported by UltraFace. + + :param model_file: (str)Path of model file, e.g ./ultraface.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(UltraFace, self).__init__(runtime_option) @@ -34,6 +41,13 @@ def __init__(self, assert self.initialized, "UltraFace initialize failed." def predict(self, input_image, conf_threshold=0.7, nms_iou_threshold=0.3): + """Detect the location and key points of human faces from an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.7 + :param nms_iou_threshold: iou threashold for NMS, default is 0.3 + :return: FaceDetectionResult + """ return self._model.predict(input_image, conf_threshold, nms_iou_threshold) @@ -41,6 +55,9 @@ def predict(self, input_image, conf_threshold=0.7, nms_iou_threshold=0.3): # 多数是预处理相关,可通过修改如model.size = [640, 480]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @size.setter diff --git a/python/fastdeploy/vision/facedet/contrib/yolov5face.py b/python/fastdeploy/vision/facedet/contrib/yolov5face.py index 7fd294b3a8..be09e840a8 100644 --- a/python/fastdeploy/vision/facedet/contrib/yolov5face.py +++ b/python/fastdeploy/vision/facedet/contrib/yolov5face.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a YOLOv5Face model exported by YOLOv5Face. + + :param model_file: (str)Path of model file, e.g ./yolov5face.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(YOLOv5Face, self).__init__(runtime_option) @@ -34,6 +41,13 @@ def __init__(self, assert self.initialized, "YOLOv5Face initialize failed." def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): + """Detect the location and key points of human faces from an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :param conf_threshold: confidence threashold for postprocessing, default is 0.25 + :param nms_iou_threshold: iou threashold for NMS, default is 0.5 + :return: FaceDetectionResult + """ return self._model.predict(input_image, conf_threshold, nms_iou_threshold) @@ -41,30 +55,41 @@ def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5): # 多数是预处理相关,可通过修改如model.size = [1280, 1280]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def padding_value(self): + # padding value, size should be the same as channels return self._model.padding_value @property def is_no_pad(self): + # while is_mini_pad = false and is_no_pad = true, will resize the image to the set size return self._model.is_no_pad @property def is_mini_pad(self): + # only pad to the minimum rectange which height and width is times of stride return self._model.is_mini_pad @property def is_scale_up(self): + # if is_scale_up is false, the input image only can be zoom out, the maximum resize scale cannot exceed 1.0 return self._model.is_scale_up @property def stride(self): + # padding stride, for is_mini_pad return self._model.stride @property def landmarks_per_face(self): + """ + Argument for image postprocessing step, landmarks_per_face, default 5 in YOLOv5Face + """ return self._model.landmarks_per_face @size.setter @@ -92,19 +117,21 @@ def is_no_pad(self, 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." + value, + bool), "The value to set `is_mini_pad` must be type of bool." self._model.is_mini_pad = value @is_scale_up.setter def is_scale_up(self, value): assert isinstance( - value, bool), "The value to set `is_scale_up` must be type of bool." + value, + bool), "The value to set `is_scale_up` must be type of bool." self._model.is_scale_up = value @stride.setter def stride(self, value): - assert isinstance(value, - int), "The value to set `stride` must be type of int." + assert isinstance( + value, int), "The value to set `stride` must be type of int." self._model.stride = value @landmarks_per_face.setter diff --git a/python/fastdeploy/vision/faceid/contrib/adaface.py b/python/fastdeploy/vision/faceid/contrib/adaface.py index ceeb4faedc..c0b6d9b1dd 100644 --- a/python/fastdeploy/vision/faceid/contrib/adaface.py +++ b/python/fastdeploy/vision/faceid/contrib/adaface.py @@ -23,6 +23,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.PADDLE): + """Load a AdaFace model exported by InsigtFace. + + :param model_file: (str)Path of model file, e.g ./adaface.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(AdaFace, self).__init__(runtime_option) @@ -33,28 +40,48 @@ def __init__(self, assert self.initialized, "AdaFace initialize failed." def predict(self, input_image): + """ Predict the face recognition result for an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :return: FaceRecognitionResult + """ return self._model.predict(input_image) # 一些跟模型有关的属性封装 # 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def alpha(self): + """ + Argument for image preprocessing step, alpha value for normalization + """ return self._model.alpha @property def beta(self): + """ + Argument for image preprocessing step, beta value for normalization + """ return self._model.beta @property def swap_rb(self): + """ + Argument for image preprocessing step, whether to swap the B and R channel, such as BGR->RGB, default true. + """ return self._model.swap_rb @property def l2_normalize(self): + """ + Argument for image preprocessing step, whether to apply l2 normalize to embedding values, default; + """ return self._model.l2_normalize @size.setter diff --git a/python/fastdeploy/vision/faceid/contrib/arcface.py b/python/fastdeploy/vision/faceid/contrib/arcface.py index 2e4785fa92..be0a09d954 100644 --- a/python/fastdeploy/vision/faceid/contrib/arcface.py +++ b/python/fastdeploy/vision/faceid/contrib/arcface.py @@ -25,6 +25,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a ArcFace model exported by InsigtFace. + + :param model_file: (str)Path of model file, e.g ./arcface.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(ArcFace, self).__init__(runtime_option) @@ -35,28 +42,48 @@ def __init__(self, assert self.initialized, "ArcFace initialize failed." def predict(self, input_image): + """ Predict the face recognition result for an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :return: FaceRecognitionResult + """ return self._model.predict(input_image) # 一些跟模型有关的属性封装 # 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def alpha(self): + """ + Argument for image preprocessing step, alpha value for normalization + """ return self._model.alpha @property def beta(self): + """ + Argument for image preprocessing step, beta value for normalization + """ return self._model.beta @property def swap_rb(self): + """ + Argument for image preprocessing step, whether to swap the B and R channel, such as BGR->RGB, default true. + """ return self._model.swap_rb @property def l2_normalize(self): + """ + Argument for image preprocessing step, whether to apply l2 normalize to embedding values, default; + """ return self._model.l2_normalize @size.setter diff --git a/python/fastdeploy/vision/faceid/contrib/cosface.py b/python/fastdeploy/vision/faceid/contrib/cosface.py index f7b620227b..982f3c4810 100644 --- a/python/fastdeploy/vision/faceid/contrib/cosface.py +++ b/python/fastdeploy/vision/faceid/contrib/cosface.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a CosFace model exported by InsigtFace. + + :param model_file: (str)Path of model file, e.g ./cosface.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(CosFace, self).__init__(runtime_option) @@ -34,28 +41,48 @@ def __init__(self, assert self.initialized, "CosFace initialize failed." def predict(self, input_image): + """ Predict the face recognition result for an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :return: FaceRecognitionResult + """ return self._model.predict(input_image) # 一些跟模型有关的属性封装 # 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def alpha(self): + """ + Argument for image preprocessing step, alpha value for normalization + """ return self._model.alpha @property def beta(self): + """ + Argument for image preprocessing step, beta value for normalization + """ return self._model.beta @property def swap_rb(self): + """ + Argument for image preprocessing step, whether to swap the B and R channel, such as BGR->RGB, default true. + """ return self._model.swap_rb @property def l2_normalize(self): + """ + Argument for image preprocessing step, whether to apply l2 normalize to embedding values, default False; + """ return self._model.l2_normalize @size.setter diff --git a/python/fastdeploy/vision/faceid/contrib/insightface_rec.py b/python/fastdeploy/vision/faceid/contrib/insightface_rec.py index df23fd6cd8..2793b88f4e 100644 --- a/python/fastdeploy/vision/faceid/contrib/insightface_rec.py +++ b/python/fastdeploy/vision/faceid/contrib/insightface_rec.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a InsightFace model exported by InsigtFace. + + :param model_file: (str)Path of model file, e.g ./arcface.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(InsightFaceRecognitionModel, self).__init__(runtime_option) @@ -34,28 +41,48 @@ def __init__(self, assert self.initialized, "InsightFaceRecognitionModel initialize failed." def predict(self, input_image): + """ Predict the face recognition result for an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :return: FaceRecognitionResult + """ return self._model.predict(input_image) # 一些跟InsightFaceRecognitionModel模型有关的属性封装 # 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def alpha(self): + """ + Argument for image preprocessing step, alpha value for normalization + """ return self._model.alpha @property def beta(self): + """ + Argument for image preprocessing step, beta value for normalization + """ return self._model.beta @property def swap_rb(self): + """ + Argument for image preprocessing step, whether to swap the B and R channel, such as BGR->RGB, default true. + """ return self._model.swap_rb @property def l2_normalize(self): + """ + Argument for image preprocessing step, whether to apply l2 normalize to embedding values, default False; + """ return self._model.l2_normalize @size.setter diff --git a/python/fastdeploy/vision/faceid/contrib/partial_fc.py b/python/fastdeploy/vision/faceid/contrib/partial_fc.py index dcc57d2e89..de31b0a273 100644 --- a/python/fastdeploy/vision/faceid/contrib/partial_fc.py +++ b/python/fastdeploy/vision/faceid/contrib/partial_fc.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a PartialFC model exported by InsigtFace. + + :param model_file: (str)Path of model file, e.g ./partial_fc.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(PartialFC, self).__init__(runtime_option) @@ -34,28 +41,48 @@ def __init__(self, assert self.initialized, "PartialFC initialize failed." def predict(self, input_image): + """ Predict the face recognition result for an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :return: FaceRecognitionResult + """ return self._model.predict(input_image) # 一些跟模型有关的属性封装 # 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def alpha(self): + """ + Argument for image preprocessing step, alpha value for normalization + """ return self._model.alpha @property def beta(self): + """ + Argument for image preprocessing step, beta value for normalization + """ return self._model.beta @property def swap_rb(self): + """ + Argument for image preprocessing step, whether to swap the B and R channel, such as BGR->RGB, default true. + """ return self._model.swap_rb @property def l2_normalize(self): + """ + Argument for image preprocessing step, whether to apply l2 normalize to embedding values, default False; + """ return self._model.l2_normalize @size.setter diff --git a/python/fastdeploy/vision/faceid/contrib/vpl.py b/python/fastdeploy/vision/faceid/contrib/vpl.py index 3d77abbce0..3a8df5f169 100644 --- a/python/fastdeploy/vision/faceid/contrib/vpl.py +++ b/python/fastdeploy/vision/faceid/contrib/vpl.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a VPL model exported by InsigtFace. + + :param model_file: (str)Path of model file, e.g ./vpl.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(VPL, self).__init__(runtime_option) @@ -34,28 +41,48 @@ def __init__(self, assert self.initialized, "VPL initialize failed." def predict(self, input_image): + """ Predict the face recognition result for an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :return: FaceRecognitionResult + """ return self._model.predict(input_image) # 一些跟模型有关的属性封装 # 多数是预处理相关,可通过修改如model.size = [112, 112]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def alpha(self): + """ + Argument for image preprocessing step, alpha value for normalization + """ return self._model.alpha @property def beta(self): + """ + Argument for image preprocessing step, beta value for normalization + """ return self._model.beta @property def swap_rb(self): + """ + Argument for image preprocessing step, whether to swap the B and R channel, such as BGR->RGB, default true. + """ return self._model.swap_rb @property def l2_normalize(self): + """ + Argument for image preprocessing step, whether to apply l2 normalize to embedding values, default False; + """ return self._model.l2_normalize @size.setter diff --git a/python/fastdeploy/vision/matting/contrib/modnet.py b/python/fastdeploy/vision/matting/contrib/modnet.py index 17bfb76f8e..33fb5a025d 100644 --- a/python/fastdeploy/vision/matting/contrib/modnet.py +++ b/python/fastdeploy/vision/matting/contrib/modnet.py @@ -24,6 +24,13 @@ def __init__(self, params_file="", runtime_option=None, model_format=ModelFormat.ONNX): + """Load a MODNet model exported by MODNet. + + :param model_file: (str)Path of model file, e.g ./modnet.onnx + :param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ # 调用基函数进行backend_option的初始化 # 初始化后的option保存在self._runtime_option super(MODNet, self).__init__(runtime_option) @@ -34,24 +41,41 @@ def __init__(self, assert self.initialized, "MODNet initialize failed." def predict(self, input_image): + """ Predict the matting result for an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :return: MattingResult + """ return self._model.predict(input_image) # 一些跟模型有关的属性封装 # 多数是预处理相关,可通过修改如model.size = [256, 256]改变预处理时resize的大小(前提是模型支持) @property def size(self): + """ + Argument for image preprocessing step, the preprocess image size, tuple of (width, height) + """ return self._model.size @property def alpha(self): + """ + Argument for image preprocessing step, alpha value for normalization + """ return self._model.alpha @property def beta(self): + """ + Argument for image preprocessing step, beta value for normalization + """ return self._model.beta @property def swap_rb(self): + """ + Argument for image preprocessing step, whether to swap the B and R channel, such as BGR->RGB, default true. + """ return self._model.swap_rb @size.setter diff --git a/python/fastdeploy/vision/matting/ppmatting/__init__.py b/python/fastdeploy/vision/matting/ppmatting/__init__.py index 450ac4aa75..5d1f46387a 100644 --- a/python/fastdeploy/vision/matting/ppmatting/__init__.py +++ b/python/fastdeploy/vision/matting/ppmatting/__init__.py @@ -25,6 +25,14 @@ def __init__(self, config_file, runtime_option=None, model_format=ModelFormat.PADDLE): + """Load a PPMatting model exported by PaddleSeg. + + :param model_file: (str)Path of model file, e.g PPMatting-512/model.pdmodel + :param params_file: (str)Path of parameters file, e.g PPMatting-512/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string + :param config_file: (str)Path of configuration file for deployment, e.g PPMatting-512/deploy.yml + :param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU + :param model_format: (fastdeploy.ModelForamt)Model format of the loaded model + """ super(PPMatting, self).__init__(runtime_option) assert model_format == ModelFormat.PADDLE, "PPMatting model only support model format of ModelFormat.Paddle now." @@ -34,5 +42,10 @@ def __init__(self, assert self.initialized, "PPMatting model initialize failed." def predict(self, input_image): + """ Predict the matting result for an input image + + :param input_image: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format + :return: MattingResult + """ assert input_image is not None, "The input image data is None." return self._model.predict(input_image)