Skip to content

Commit

Permalink
Modify YOLOv7 Infer file and the external model namespace (PaddlePadd…
Browse files Browse the repository at this point in the history
…le#87)

* first commit for yolov7

* pybind for yolov7

* CPP README.md

* CPP README.md

* modified yolov7.cc

* README.md

* python file modify

* delete license in fastdeploy/

* repush the conflict part

* README.md modified

* README.md modified

* file path modified

* file path modified

* file path modified

* file path modified

* file path modified

* README modified

* README modified

* move some helpers to private

* add examples for yolov7

* api.md modified

* api.md modified

* api.md modified

* YOLOv7

* yolov7 release link

* yolov7 release link

* yolov7 release link

* copyright

* change some helpers to private

* change variables to const and fix documents.

* gitignore

* Transfer some funtions to private member of class

* Transfer some funtions to private member of class

* Merge from develop (#9)

* Fix compile problem in different python version (#26)

* fix some usage problem in linux

* Fix compile problem

Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>

* Add PaddleDetetion/PPYOLOE model support (#22)

* add ppdet/ppyoloe

* Add demo code and documents

* add convert processor to vision (#27)

* update .gitignore

* Added checking for cmake include dir

* fixed missing trt_backend option bug when init from trt

* remove un-need data layout and add pre-check for dtype

* changed RGB2BRG to BGR2RGB in ppcls model

* add model_zoo yolov6 c++/python demo

* fixed CMakeLists.txt typos

* update yolov6 cpp/README.md

* add yolox c++/pybind and model_zoo demo

* move some helpers to private

* fixed CMakeLists.txt typos

* add normalize with alpha and beta

* add version notes for yolov5/yolov6/yolox

* add copyright to yolov5.cc

* revert normalize

* fixed some bugs in yolox

* fixed examples/CMakeLists.txt to avoid conflicts

* add convert processor to vision

* format examples/CMakeLists summary

* Fix bug while the inference result is empty with YOLOv5 (#29)

* Add multi-label function for yolov5

* Update README.md

Update doc

* Update fastdeploy_runtime.cc

fix variable option.trt_max_shape wrong name

* Update runtime_option.md

Update resnet model dynamic shape setting name from images to x

* Fix bug when inference result boxes are empty

* Delete detection.py

Co-authored-by: Jason <jiangjiajun@baidu.com>
Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>
Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
Co-authored-by: huangjianhui <852142024@qq.com>

* first commit for yolor

* for merge

* Develop (#11)

* Fix compile problem in different python version (#26)

* fix some usage problem in linux

* Fix compile problem

Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>

* Add PaddleDetetion/PPYOLOE model support (#22)

* add ppdet/ppyoloe

* Add demo code and documents

* add convert processor to vision (#27)

* update .gitignore

* Added checking for cmake include dir

* fixed missing trt_backend option bug when init from trt

* remove un-need data layout and add pre-check for dtype

* changed RGB2BRG to BGR2RGB in ppcls model

* add model_zoo yolov6 c++/python demo

* fixed CMakeLists.txt typos

* update yolov6 cpp/README.md

* add yolox c++/pybind and model_zoo demo

* move some helpers to private

* fixed CMakeLists.txt typos

* add normalize with alpha and beta

* add version notes for yolov5/yolov6/yolox

* add copyright to yolov5.cc

* revert normalize

* fixed some bugs in yolox

* fixed examples/CMakeLists.txt to avoid conflicts

* add convert processor to vision

* format examples/CMakeLists summary

* Fix bug while the inference result is empty with YOLOv5 (#29)

* Add multi-label function for yolov5

* Update README.md

Update doc

* Update fastdeploy_runtime.cc

fix variable option.trt_max_shape wrong name

* Update runtime_option.md

Update resnet model dynamic shape setting name from images to x

* Fix bug when inference result boxes are empty

* Delete detection.py

Co-authored-by: Jason <jiangjiajun@baidu.com>
Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>
Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
Co-authored-by: huangjianhui <852142024@qq.com>

* Yolor (#16)

* Develop (#11) (#12)

* Fix compile problem in different python version (#26)

* fix some usage problem in linux

* Fix compile problem

Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>

* Add PaddleDetetion/PPYOLOE model support (#22)

* add ppdet/ppyoloe

* Add demo code and documents

* add convert processor to vision (#27)

* update .gitignore

* Added checking for cmake include dir

* fixed missing trt_backend option bug when init from trt

* remove un-need data layout and add pre-check for dtype

* changed RGB2BRG to BGR2RGB in ppcls model

* add model_zoo yolov6 c++/python demo

* fixed CMakeLists.txt typos

* update yolov6 cpp/README.md

* add yolox c++/pybind and model_zoo demo

* move some helpers to private

* fixed CMakeLists.txt typos

* add normalize with alpha and beta

* add version notes for yolov5/yolov6/yolox

* add copyright to yolov5.cc

* revert normalize

* fixed some bugs in yolox

* fixed examples/CMakeLists.txt to avoid conflicts

* add convert processor to vision

* format examples/CMakeLists summary

* Fix bug while the inference result is empty with YOLOv5 (#29)

* Add multi-label function for yolov5

* Update README.md

Update doc

* Update fastdeploy_runtime.cc

fix variable option.trt_max_shape wrong name

* Update runtime_option.md

Update resnet model dynamic shape setting name from images to x

* Fix bug when inference result boxes are empty

* Delete detection.py

Co-authored-by: Jason <jiangjiajun@baidu.com>
Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>
Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
Co-authored-by: huangjianhui <852142024@qq.com>

Co-authored-by: Jason <jiangjiajun@baidu.com>
Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>
Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
Co-authored-by: huangjianhui <852142024@qq.com>

* Develop (#13)

* Fix compile problem in different python version (#26)

* fix some usage problem in linux

* Fix compile problem

Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>

* Add PaddleDetetion/PPYOLOE model support (#22)

* add ppdet/ppyoloe

* Add demo code and documents

* add convert processor to vision (#27)

* update .gitignore

* Added checking for cmake include dir

* fixed missing trt_backend option bug when init from trt

* remove un-need data layout and add pre-check for dtype

* changed RGB2BRG to BGR2RGB in ppcls model

* add model_zoo yolov6 c++/python demo

* fixed CMakeLists.txt typos

* update yolov6 cpp/README.md

* add yolox c++/pybind and model_zoo demo

* move some helpers to private

* fixed CMakeLists.txt typos

* add normalize with alpha and beta

* add version notes for yolov5/yolov6/yolox

* add copyright to yolov5.cc

* revert normalize

* fixed some bugs in yolox

* fixed examples/CMakeLists.txt to avoid conflicts

* add convert processor to vision

* format examples/CMakeLists summary

* Fix bug while the inference result is empty with YOLOv5 (#29)

* Add multi-label function for yolov5

* Update README.md

Update doc

* Update fastdeploy_runtime.cc

fix variable option.trt_max_shape wrong name

* Update runtime_option.md

Update resnet model dynamic shape setting name from images to x

* Fix bug when inference result boxes are empty

* Delete detection.py

Co-authored-by: Jason <jiangjiajun@baidu.com>
Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>
Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
Co-authored-by: huangjianhui <852142024@qq.com>

* documents

* documents

* documents

* documents

* documents

* documents

* documents

* documents

* documents

* documents

* documents

* documents

* Develop (#14)

* Fix compile problem in different python version (#26)

* fix some usage problem in linux

* Fix compile problem

Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>

* Add PaddleDetetion/PPYOLOE model support (#22)

* add ppdet/ppyoloe

* Add demo code and documents

* add convert processor to vision (#27)

* update .gitignore

* Added checking for cmake include dir

* fixed missing trt_backend option bug when init from trt

* remove un-need data layout and add pre-check for dtype

* changed RGB2BRG to BGR2RGB in ppcls model

* add model_zoo yolov6 c++/python demo

* fixed CMakeLists.txt typos

* update yolov6 cpp/README.md

* add yolox c++/pybind and model_zoo demo

* move some helpers to private

* fixed CMakeLists.txt typos

* add normalize with alpha and beta

* add version notes for yolov5/yolov6/yolox

* add copyright to yolov5.cc

* revert normalize

* fixed some bugs in yolox

* fixed examples/CMakeLists.txt to avoid conflicts

* add convert processor to vision

* format examples/CMakeLists summary

* Fix bug while the inference result is empty with YOLOv5 (#29)

* Add multi-label function for yolov5

* Update README.md

Update doc

* Update fastdeploy_runtime.cc

fix variable option.trt_max_shape wrong name

* Update runtime_option.md

Update resnet model dynamic shape setting name from images to x

* Fix bug when inference result boxes are empty

* Delete detection.py

Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>
Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
Co-authored-by: huangjianhui <852142024@qq.com>

Co-authored-by: Jason <jiangjiajun@baidu.com>
Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>
Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
Co-authored-by: huangjianhui <852142024@qq.com>
Co-authored-by: Jason <928090362@qq.com>

* add is_dynamic for YOLO series (#22)

* modify namespace for yolov5lite

* modify namespace for external detection models

* modify namespace for yolov5lite

* modify namespace for face models

* py namespace for external model

* fix compile error and infer file

* change paddleyolox to yolox

* delete space in cmakelist

* check code specification

Co-authored-by: Jason <jiangjiajun@baidu.com>
Co-authored-by: root <root@bjyz-sys-gpu-kongming3.bjyz.baidu.com>
Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
Co-authored-by: huangjianhui <852142024@qq.com>
Co-authored-by: Jason <928090362@qq.com>
  • Loading branch information
6 people authored Aug 10, 2022
1 parent de2a87a commit 9918374
Show file tree
Hide file tree
Showing 88 changed files with 1,461 additions and 1,405 deletions.
34 changes: 16 additions & 18 deletions csrcs/fastdeploy/vision.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,27 @@

#include "fastdeploy/core/config.h"
#ifdef ENABLE_VISION
#include "fastdeploy/vision/biubug6/retinaface.h"
#include "fastdeploy/vision/deepcam/yolov5face.h"
#include "fastdeploy/vision/deepinsight/arcface.h"
#include "fastdeploy/vision/deepinsight/cosface.h"
#include "fastdeploy/vision/deepinsight/insightface_rec.h"
#include "fastdeploy/vision/deepinsight/partial_fc.h"
#include "fastdeploy/vision/deepinsight/scrfd.h"
#include "fastdeploy/vision/deepinsight/vpl.h"

#include "fastdeploy/vision/detection/contrib/nanodet_plus.h"
#include "fastdeploy/vision/detection/contrib/scaledyolov4.h"
#include "fastdeploy/vision/detection/contrib/yolor.h"
#include "fastdeploy/vision/detection/contrib/yolov5.h"
#include "fastdeploy/vision/detection/contrib/yolov5lite.h"
#include "fastdeploy/vision/detection/contrib/yolov6.h"
#include "fastdeploy/vision/detection/contrib/yolov7.h"
#include "fastdeploy/vision/detection/ppdet/model.h"

#include "fastdeploy/vision/linzaer/ultraface.h"
#include "fastdeploy/vision/megvii/yolox.h"
#include "fastdeploy/vision/meituan/yolov6.h"
#include "fastdeploy/vision/detection/contrib/yolox.h"
#include "fastdeploy/vision/facedet/contrib/retinaface.h"
#include "fastdeploy/vision/facedet/contrib/scrfd.h"
#include "fastdeploy/vision/facedet/contrib/ultraface.h"
#include "fastdeploy/vision/facedet/contrib/yolov5face.h"
#include "fastdeploy/vision/faceid/contrib/arcface.h"
#include "fastdeploy/vision/faceid/contrib/cosface.h"
#include "fastdeploy/vision/faceid/contrib/insightface_rec.h"
#include "fastdeploy/vision/faceid/contrib/partial_fc.h"
#include "fastdeploy/vision/faceid/contrib/vpl.h"
#include "fastdeploy/vision/matting/contrib/modnet.h"
#include "fastdeploy/vision/ppcls/model.h"
#include "fastdeploy/vision/ppogg/yolov5lite.h"
#include "fastdeploy/vision/detection/ppdet/model.h"
#include "fastdeploy/vision/ppseg/model.h"
#include "fastdeploy/vision/rangilyu/nanodet_plus.h"
#include "fastdeploy/vision/ultralytics/yolov5.h"
#include "fastdeploy/vision/zhkkke/modnet.h"
#endif

#include "fastdeploy/vision/visualize/visualize.h"
144 changes: 0 additions & 144 deletions csrcs/fastdeploy/vision/deepinsight/deepinsight_pybind.cc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "fastdeploy/vision/rangilyu/nanodet_plus.h"
#include "fastdeploy/vision/detection/contrib/nanodet_plus.h"
#include "fastdeploy/utils/perf.h"
#include "fastdeploy/vision/utils/utils.h"

namespace fastdeploy {

namespace vision {

namespace rangilyu {
namespace detection {

struct NanoDetPlusCenterPoint {
int grid0;
Expand Down Expand Up @@ -350,6 +350,6 @@ bool NanoDetPlus::Predict(cv::Mat* im, DetectionResult* result,
return true;
}

} // namespace rangilyu
} // namespace detection
} // namespace vision
} // namespace fastdeploy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace fastdeploy {

namespace vision {

namespace rangilyu {
namespace detection {

class FASTDEPLOY_DECL NanoDetPlus : public FastDeployModel {
public:
Expand All @@ -34,7 +34,7 @@ class FASTDEPLOY_DECL NanoDetPlus : public FastDeployModel {
const Frontend& model_format = Frontend::ONNX);

// 定义模型的名称
std::string ModelName() const { return "RangiLyu/nanodet"; }
std::string ModelName() const { return "nanodet"; }

// 模型预测接口,即用户调用的接口
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
Expand Down Expand Up @@ -96,6 +96,6 @@ class FASTDEPLOY_DECL NanoDetPlus : public FastDeployModel {
bool is_dynamic_input_;
};

} // namespace rangilyu
} // namespace detection
} // namespace vision
} // namespace fastdeploy
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,25 @@
#include "fastdeploy/pybind/main.h"

namespace fastdeploy {
void BindMegvii(pybind11::module& m) {
auto megvii_module =
m.def_submodule("megvii", "https://github.com/megvii/YOLOX");
pybind11::class_<vision::megvii::YOLOX, FastDeployModel>(
megvii_module, "YOLOX")
void BindNanoDetPlus(pybind11::module& m) {
pybind11::class_<vision::detection::NanoDetPlus, FastDeployModel>(
m, "NanoDetPlus")
.def(pybind11::init<std::string, std::string, RuntimeOption, Frontend>())
.def("predict",
[](vision::megvii::YOLOX& self, pybind11::array& data,
[](vision::detection::NanoDetPlus& self, pybind11::array& data,
float conf_threshold, float nms_iou_threshold) {
auto mat = PyArrayToCvMat(data);
vision::DetectionResult res;
self.Predict(&mat, &res, conf_threshold, nms_iou_threshold);
return res;
})
.def_readwrite("size", &vision::megvii::YOLOX::size)
.def_readwrite("size", &vision::detection::NanoDetPlus::size)
.def_readwrite("padding_value",
&vision::megvii::YOLOX::padding_value)
.def_readwrite("is_decode_exported",
&vision::megvii::YOLOX::is_decode_exported)
&vision::detection::NanoDetPlus::padding_value)
.def_readwrite("keep_ratio", &vision::detection::NanoDetPlus::keep_ratio)
.def_readwrite("downsample_strides",
&vision::megvii::YOLOX::downsample_strides)
.def_readwrite("max_wh", &vision::megvii::YOLOX::max_wh);
&vision::detection::NanoDetPlus::downsample_strides)
.def_readwrite("max_wh", &vision::detection::NanoDetPlus::max_wh)
.def_readwrite("reg_max", &vision::detection::NanoDetPlus::reg_max);
}
} // namespace fastdeploy
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "fastdeploy/vision/ultralytics/yolov5.h"
#include "fastdeploy/vision/detection/contrib/yolov5.h"
#include "fastdeploy/utils/perf.h"
#include "fastdeploy/vision/utils/utils.h"

namespace fastdeploy {
namespace vision {
namespace ultralytics {
namespace detection {

void LetterBox(Mat* mat, std::vector<int> size, std::vector<float> color,
bool _auto, bool scale_fill = false, bool scale_up = true,
int stride = 32) {
void YOLOv5::LetterBox(Mat* mat, std::vector<int> size,
std::vector<float> color, bool _auto, bool scale_fill,
bool scale_up, int stride) {
float scale =
std::min(size[1] * 1.0 / mat->Height(), size[0] * 1.0 / mat->Width());
if (!scale_up) {
Expand Down Expand Up @@ -204,9 +204,9 @@ bool YOLOv5::Postprocess(
}

if (result->boxes.size() == 0) {
return true;
return true;
}

utils::NMS(result, nms_iou_threshold);

// scale the boxes to the origin image shape
Expand Down Expand Up @@ -290,6 +290,6 @@ bool YOLOv5::Predict(cv::Mat* im, DetectionResult* result, float conf_threshold,
return true;
}

} // namespace ultralytics
} // namespace detection
} // namespace vision
} // namespace fastdeploy
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace fastdeploy {
namespace vision {
namespace ultralytics {
namespace detection {

class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel {
public:
Expand All @@ -30,7 +30,7 @@ class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel {
const Frontend& model_format = Frontend::ONNX);

// 定义模型的名称
std::string ModelName() const { return "ultralytics/yolov5"; }
std::string ModelName() const { return "yolov5"; }

// 模型预测接口,即用户调用的接口
// im 为用户的输入数据,目前对于CV均定义为cv::Mat
Expand All @@ -39,7 +39,7 @@ class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel {
// nms_iou_threshold 为后处理的参数
virtual bool Predict(cv::Mat* im, DetectionResult* result,
float conf_threshold = 0.25,
float nms_iou_threshold = 0.5);
float nms_iou_threshold = 0.5);

// 以下为模型在预测时的一些参数,基本是前后处理所需
// 用户在创建模型后,可根据模型的要求,以及自己的需求
Expand Down Expand Up @@ -81,21 +81,28 @@ class FASTDEPLOY_DECL YOLOv5 : public FastDeployModel {
// conf_threshold 后处理时过滤box的置信度阈值
// nms_iou_threshold 后处理时NMS设定的iou阈值
// multi_label 后处理时box选取是否采用多标签方式
bool Postprocess(
FDTensor& infer_result, DetectionResult* result,
const std::map<std::string, std::array<float, 2>>& im_info,
float conf_threshold, float nms_iou_threshold, bool multi_label);
bool Postprocess(FDTensor& infer_result, DetectionResult* result,
const std::map<std::string, std::array<float, 2>>& im_info,
float conf_threshold, float nms_iou_threshold,
bool multi_label);

// 查看输入是否为动态维度的 不建议直接使用 不同模型的逻辑可能不一致
bool IsDynamicInput() const { return is_dynamic_input_; }
bool IsDynamicInput() const { return is_dynamic_input_; }

// whether to inference with dynamic shape (e.g ONNX export with dynamic shape or not.)
// YOLOv5 official 'export_onnx.py' script will export dynamic ONNX by default.
// while is_dynamic_shape if 'false', is_mini_pad will force 'false'. This value will
// auto check by fastdeploy after the internal Runtime already initialized.
void LetterBox(Mat* mat, std::vector<int> size, std::vector<float> color,
bool _auto, bool scale_fill = false, bool scale_up = true,
int stride = 32);

// whether to inference with dynamic shape (e.g ONNX export with dynamic shape
// or not.)
// YOLOv5 official 'export_onnx.py' script will export dynamic ONNX by
// default.
// while is_dynamic_shape if 'false', is_mini_pad will force 'false'. This
// value will
// auto check by fastdeploy after the internal Runtime already initialized.
bool is_dynamic_input_;
};

} // namespace ultralytics
} // namespace detection
} // namespace vision
} // namespace fastdeploy
Loading

0 comments on commit 9918374

Please sign in to comment.