Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
02d29aa
update .gitignore
DefTruth Jul 12, 2022
f9caef2
Merge branch 'develop' of https://github.com/DefTruth/FastDeploy into…
DefTruth Jul 12, 2022
afa8114
Added checking for cmake include dir
DefTruth Jul 12, 2022
659c14c
fixed missing trt_backend option bug when init from trt
DefTruth Jul 12, 2022
17a43ce
remove un-need data layout and add pre-check for dtype
DefTruth Jul 12, 2022
75948f8
changed RGB2BRG to BGR2RGB in ppcls model
DefTruth Jul 12, 2022
b57244d
add yolov6 c++ and yolov6 pybind
DefTruth Jul 13, 2022
71cd83c
Merge branch 'develop' of https://github.com/DefTruth/FastDeploy into…
DefTruth Jul 13, 2022
f847490
add model_zoo yolov6 c++/python demo
DefTruth Jul 14, 2022
c56fdc3
fixed CMakeLists.txt typos
DefTruth Jul 14, 2022
2300f57
update yolov6 cpp/README.md
DefTruth Jul 14, 2022
5670280
Merge branch 'PaddlePaddle:develop' into develop
DefTruth Jul 18, 2022
cb91b3c
add yolox c++/pybind and model_zoo demo
DefTruth Jul 18, 2022
9d7e9d9
move some helpers to private
DefTruth Jul 18, 2022
d2e51a2
fixed CMakeLists.txt typos
DefTruth Jul 18, 2022
eb63a0e
Merge branch 'develop' of https://github.com/DefTruth/FastDeploy into…
DefTruth Jul 18, 2022
df8b6a6
add normalize with alpha and beta
DefTruth Jul 18, 2022
8786384
add version notes for yolov5/yolov6/yolox
DefTruth Jul 18, 2022
fed2953
add copyright to yolov5.cc
DefTruth Jul 18, 2022
6ec3bd5
revert normalize
DefTruth Jul 18, 2022
367dad0
fixed some bugs in yolox
DefTruth Jul 18, 2022
95f8d01
update examples/CMakeLists.txt
DefTruth Jul 19, 2022
8de98d5
Merge branch 'PaddlePaddle-develop' into develop
DefTruth Jul 19, 2022
e339707
Merge branch 'PaddlePaddle:develop' into develop
DefTruth Jul 19, 2022
66fc4ae
Merge branch 'PaddlePaddle:develop' into develop
DefTruth Jul 19, 2022
d940c53
Merge pull request #7 from PaddlePaddle/develop
DefTruth Jul 21, 2022
3d41f5c
Add NanoDet-Plus Model support
DefTruth Jul 21, 2022
8c04d33
Merge branch 'nanodet_plus' of https://github.com/DefTruth/FastDeploy…
DefTruth Jul 21, 2022
7b4aa95
Merge branch 'develop' into nanodet_plus
jiangjiajun Jul 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

function(add_fastdeploy_executable FIELD CC_FILE)
# temp target name/file var in function scope
set(TEMP_TARGET_FILE ${CC_FILE})
Expand Down
53 changes: 53 additions & 0 deletions examples/vision/rangilyu_nanodet_plus.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "fastdeploy/vision.h"

int main() {
namespace vis = fastdeploy::vision;

std::string model_file = "../resources/models/nanodet-plus-m_320.onnx";
std::string img_path = "../resources/images/bus.jpg";
std::string vis_path =
"../resources/outputs/rangilyu_nanodet_plus_vis_result.jpg";

auto model = vis::rangilyu::NanoDetPlus(model_file);
if (!model.Initialized()) {
std::cerr << "Init Failed! Model: " << model_file << std::endl;
return -1;
} else {
std::cout << "Init Done! Model:" << model_file << std::endl;
}
model.EnableDebug();

cv::Mat im = cv::imread(img_path);
cv::Mat vis_im = im.clone();

vis::DetectionResult res;
if (!model.Predict(&im, &res)) {
std::cerr << "Prediction Failed." << std::endl;
return -1;
} else {
std::cout << "Prediction Done!" << std::endl;
}

// 输出预测框结果
std::cout << res.Str() << std::endl;

// 可视化预测结果
vis::Visualize::VisDetection(&vis_im, res);
cv::imwrite(vis_path, vis_im);
std::cout << "Detect Done! Saved: " << vis_path << std::endl;
return 0;
}
1 change: 1 addition & 0 deletions fastdeploy/vision.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "fastdeploy/vision/meituan/yolov6.h"
#include "fastdeploy/vision/ppcls/model.h"
#include "fastdeploy/vision/ppdet/ppyoloe.h"
#include "fastdeploy/vision/rangilyu/nanodet_plus.h"
#include "fastdeploy/vision/ppseg/model.h"
#include "fastdeploy/vision/ultralytics/yolov5.h"
#include "fastdeploy/vision/wongkinyiu/yolor.h"
Expand Down
1 change: 1 addition & 0 deletions fastdeploy/vision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@
from . import megvii
from . import visualize
from . import wongkinyiu
from . import rangilyu
14 changes: 7 additions & 7 deletions fastdeploy/vision/megvii/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def __init__(self,
# 初始化后的option保存在self._runtime_option
super(YOLOX, self).__init__(runtime_option)

self._model = C.vision.megvii.YOLOX(
model_file, params_file, self._runtime_option, model_format)
self._model = C.vision.megvii.YOLOX(model_file, params_file,
self._runtime_option, model_format)
# 通过self.initialized判断整个模型的初始化是否成功
assert self.initialized, "YOLOX initialize failed."

Expand All @@ -53,8 +53,8 @@ def is_decode_exported(self):

@property
def downsample_strides(self):
return self._model.downsample_strides
return self._model.downsample_strides

@property
def max_wh(self):
return self._model.max_wh
Expand All @@ -78,16 +78,16 @@ def padding_value(self, value):
@is_decode_exported.setter
def is_decode_exported(self, value):
assert isinstance(
value,
value,
bool), "The value to set `is_decode_exported` must be type of bool."
self._model.max_wh = value
self._model.is_decode_exported = value

@downsample_strides.setter
def downsample_strides(self, value):
assert isinstance(
value,
list), "The value to set `downsample_strides` must be type of list."
self._model.downsample_strides = value
self._model.downsample_strides = value

@max_wh.setter
def max_wh(self, value):
Expand Down
105 changes: 105 additions & 0 deletions fastdeploy/vision/rangilyu/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
import logging
from ... import FastDeployModel, Frontend
from ... import fastdeploy_main as C


class NanoDetPlus(FastDeployModel):
def __init__(self,
model_file,
params_file="",
runtime_option=None,
model_format=Frontend.ONNX):
# 调用基函数进行backend_option的初始化
# 初始化后的option保存在self._runtime_option
super(NanoDetPlus, self).__init__(runtime_option)

self._model = C.vision.rangilyu.NanoDetPlus(
model_file, params_file, self._runtime_option, model_format)
# 通过self.initialized判断整个模型的初始化是否成功
assert self.initialized, "NanoDetPlus initialize failed."

def predict(self, input_image, conf_threshold=0.25, nms_iou_threshold=0.5):
return self._model.predict(input_image, conf_threshold,
nms_iou_threshold)

# 一些跟NanoDetPlus模型有关的属性封装
# 多数是预处理相关,可通过修改如model.size = [416, 416]改变预处理时resize的大小(前提是模型支持)
@property
def size(self):
return self._model.size

@property
def padding_value(self):
return self._model.padding_value

@property
def keep_ratio(self):
return self._model.keep_ratio

@property
def downsample_strides(self):
return self._model.downsample_strides

@property
def max_wh(self):
return self._model.max_wh

@property
def reg_max(self):
return self._model.reg_max

@size.setter
def size(self, wh):
assert isinstance(wh, [list, tuple]),\
"The value to set `size` must be type of tuple or list."
assert len(wh) == 2,\
"The value to set `size` must contatins 2 elements means [width, height], but now it contains {} elements.".format(
len(wh))
self._model.size = wh

@padding_value.setter
def padding_value(self, value):
assert isinstance(
value,
list), "The value to set `padding_value` must be type of list."
self._model.padding_value = value

@keep_ratio.setter
def keep_ratio(self, value):
assert isinstance(
value, bool), "The value to set `keep_ratio` must be type of bool."
self._model.keep_ratio = value

@downsample_strides.setter
def downsample_strides(self, value):
assert isinstance(
value,
list), "The value to set `downsample_strides` must be type of list."
self._model.downsample_strides = value

@max_wh.setter
def max_wh(self, value):
assert isinstance(
value, float), "The value to set `max_wh` must be type of float."
self._model.max_wh = value

@reg_max.setter
def reg_max(self, value):
assert isinstance(
value, int), "The value to set `reg_max` must be type of int."
self._model.reg_max = value
Loading