Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Model] Refactor YOLOv7 module #611

Merged
merged 78 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
018b902
add paddle_trt in benchmark
wjj19950828 Nov 1, 2022
05a4666
Merge remote-tracking branch 'upstream/develop' into update_benchmark
wjj19950828 Nov 1, 2022
0000234
update benchmark in device
wjj19950828 Nov 2, 2022
f5c1f63
resolve conflict
wjj19950828 Nov 2, 2022
20ddf39
update benchmark
wjj19950828 Nov 3, 2022
f212502
resolve conflict
wjj19950828 Nov 3, 2022
9a4797e
Merge remote-tracking branch 'upstream/develop' into update_benchmark
wjj19950828 Nov 4, 2022
2ce4005
update result doc
wjj19950828 Nov 4, 2022
565e373
Merge remote-tracking branch 'upstream/develop' into update_benchmark
wjj19950828 Nov 4, 2022
36889ff
fixed for CI
wjj19950828 Nov 4, 2022
c523ae2
Merge remote-tracking branch 'upstream/develop' into update_benchmark
wjj19950828 Nov 4, 2022
f32a09a
update python api_docs
wjj19950828 Nov 7, 2022
335712e
Merge remote-tracking branch 'upstream/develop' into update_benchmark
wjj19950828 Nov 7, 2022
7fa4dea
update index.rst
wjj19950828 Nov 7, 2022
4389060
add runtime cpp examples
wjj19950828 Nov 7, 2022
1aa7b96
Merge remote-tracking branch 'upstream/develop' into update_benchmark
wjj19950828 Nov 7, 2022
84d564f
deal with comments
wjj19950828 Nov 7, 2022
e6f4e63
Update infer_paddle_tensorrt.py
jiangjiajun Nov 7, 2022
050e6ae
resolve conflict
wjj19950828 Nov 8, 2022
1952c99
Add runtime quick start
wjj19950828 Nov 8, 2022
6fada61
Merge remote-tracking branch 'upstream/develop' into update_benchmark
wjj19950828 Nov 8, 2022
ff0b121
Merge branch 'update_benchmark' of https://github.com/wjj19950828/Fas…
wjj19950828 Nov 8, 2022
42f6a5e
Merge remote-tracking branch 'upstream/develop' into update_benchmark
wjj19950828 Nov 8, 2022
d495b8e
deal with comments
wjj19950828 Nov 8, 2022
731b822
fixed reused_input_tensors&&reused_output_tensors
wjj19950828 Nov 8, 2022
c7d89ef
Merge remote-tracking branch 'upstream/develop' into update_benchmark
wjj19950828 Nov 8, 2022
568d5ae
Merge remote-tracking branch 'upstream/develop' into update_benchmark
wjj19950828 Nov 9, 2022
f8e10a8
Merge remote-tracking branch 'upstream/develop' into update_benchmark
wjj19950828 Nov 9, 2022
c5c741d
fixed docs
wjj19950828 Nov 9, 2022
d4ebde0
fixed headpose typo
wjj19950828 Nov 9, 2022
a4bc615
Merge remote-tracking branch 'upstream/develop' into update_benchmark
wjj19950828 Nov 9, 2022
6f653da
fixed typo
wjj19950828 Nov 9, 2022
72477e1
Merge remote-tracking branch 'upstream/develop' into refactor_yolov5
wjj19950828 Nov 9, 2022
005897c
refactor yolov5
wjj19950828 Nov 9, 2022
0509089
update model infer
wjj19950828 Nov 9, 2022
0e8c38c
Merge remote-tracking branch 'upstream/develop' into refactor_yolov5
wjj19950828 Nov 10, 2022
febb2c1
refactor pybind for yolov5
wjj19950828 Nov 10, 2022
177995c
Merge remote-tracking branch 'upstream/develop' into refactor_yolov5
wjj19950828 Nov 10, 2022
92dc352
rm origin yolov5
wjj19950828 Nov 10, 2022
983301b
fixed bugs
wjj19950828 Nov 10, 2022
27113e3
rm cuda preprocess
wjj19950828 Nov 10, 2022
f7d9d20
fixed bugs
wjj19950828 Nov 10, 2022
448806a
Merge remote-tracking branch 'upstream/develop' into refactor_yolov5
wjj19950828 Nov 10, 2022
d2629e7
fixed bugs
wjj19950828 Nov 10, 2022
0a5611b
fixed bug
wjj19950828 Nov 10, 2022
5706ff6
fixed bug
wjj19950828 Nov 10, 2022
5817564
fix pybind
wjj19950828 Nov 10, 2022
3e94507
rm useless code
wjj19950828 Nov 10, 2022
b97542f
add convert_and_permute
wjj19950828 Nov 13, 2022
632dd87
Merge remote-tracking branch 'upstream/develop' into refactor_yolov5
wjj19950828 Nov 13, 2022
d83fd12
fixed bugs
wjj19950828 Nov 13, 2022
302ca01
fixed im_info for bs_predict
wjj19950828 Nov 13, 2022
4b9cc78
fixed bug
wjj19950828 Nov 13, 2022
c72cafa
add bs_predict for yolov5
wjj19950828 Nov 13, 2022
26a1281
resolve conflict
wjj19950828 Nov 14, 2022
0f3b4a7
Add runtime test and batch eval
wjj19950828 Nov 14, 2022
b9b719a
Merge remote-tracking branch 'upstream/develop' into refactor_yolov5
wjj19950828 Nov 14, 2022
386b908
deal with comments
wjj19950828 Nov 14, 2022
810d7cd
fixed bug
wjj19950828 Nov 14, 2022
b200232
update testcase
wjj19950828 Nov 14, 2022
97085a2
fixed batch eval bug
wjj19950828 Nov 14, 2022
fb111e1
Merge remote-tracking branch 'upstream/develop' into refactor_yolov5
wjj19950828 Nov 14, 2022
ac9b1a7
fixed preprocess bug
wjj19950828 Nov 14, 2022
feec5e8
Merge remote-tracking branch 'upstream/develop' into refactor_yolov5
wjj19950828 Nov 14, 2022
22feb4b
Merge remote-tracking branch 'upstream/develop' into refactor_yolov7
wjj19950828 Nov 15, 2022
31682cf
Merge remote-tracking branch 'upstream/develop' into refactor_yolov7
wjj19950828 Nov 15, 2022
aa06dc6
refactor yolov7
wjj19950828 Nov 16, 2022
4129408
Merge remote-tracking branch 'upstream/develop' into refactor_yolov7
wjj19950828 Nov 16, 2022
9c5f766
add yolov7 testcase
wjj19950828 Nov 16, 2022
e39d60a
rm resize_after_load and add is_scale_up
wjj19950828 Nov 17, 2022
9204e78
Merge remote-tracking branch 'upstream/develop' into refactor_yolov7
wjj19950828 Nov 17, 2022
bb1b8fc
fixed bug
wjj19950828 Nov 17, 2022
4d4117a
Merge remote-tracking branch 'upstream/develop' into refactor_yolov7
wjj19950828 Nov 17, 2022
ae21139
Merge remote-tracking branch 'upstream/develop' into refactor_yolov7
wjj19950828 Nov 17, 2022
5f7b935
set multi_label true
wjj19950828 Nov 17, 2022
5746cc2
Merge remote-tracking branch 'upstream/develop' into refactor_yolov7
wjj19950828 Nov 17, 2022
6fabf86
Merge remote-tracking branch 'upstream/develop' into refactor_yolov7
wjj19950828 Nov 17, 2022
eff67e3
Merge remote-tracking branch 'upstream/develop' into refactor_yolov7
wjj19950828 Nov 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion fastdeploy/vision.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "fastdeploy/vision/detection/contrib/yolov5/yolov5.h"
#include "fastdeploy/vision/detection/contrib/yolov5lite.h"
#include "fastdeploy/vision/detection/contrib/yolov6.h"
#include "fastdeploy/vision/detection/contrib/yolov7.h"
#include "fastdeploy/vision/detection/contrib/yolov7/yolov7.h"
#include "fastdeploy/vision/detection/contrib/yolov7end2end_ort.h"
#include "fastdeploy/vision/detection/contrib/yolov7end2end_trt.h"
#include "fastdeploy/vision/detection/contrib/yolox.h"
Expand Down
6 changes: 3 additions & 3 deletions fastdeploy/vision/detection/contrib/yolov5/postprocessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace detection {
YOLOv5Postprocessor::YOLOv5Postprocessor() {
conf_threshold_ = 0.25;
nms_threshold_ = 0.5;
multi_label_ = true;
multi_label_ = false;
max_wh_ = 7680.0;
}

Expand Down Expand Up @@ -103,9 +103,9 @@ bool YOLOv5Postprocessor::Run(const std::vector<FDTensor>& tensors, std::vector<
float ipt_h = iter_ipt->second[0];
float ipt_w = iter_ipt->second[1];
float scale = std::min(out_h / ipt_h, out_w / ipt_w);
float pad_h = (out_h - ipt_h * scale) / 2;
float pad_w = (out_w - ipt_w * scale) / 2;
for (size_t i = 0; i < (*results)[bs].boxes.size(); ++i) {
float pad_h = (out_h - ipt_h * scale) / 2;
float pad_w = (out_w - ipt_w * scale) / 2;
int32_t label_id = ((*results)[bs].label_ids)[i];
// clip box
(*results)[bs].boxes[i][0] = (*results)[bs].boxes[i][0] - max_wh_ * label_id;
Expand Down
4 changes: 2 additions & 2 deletions fastdeploy/vision/detection/contrib/yolov5/postprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class FASTDEPLOY_DECL YOLOv5Postprocessor {
/// Get nms_threshold, default 0.5
float GetNMSThreshold() const { return nms_threshold_; }

/// Set multi_label, default true
/// Set multi_label, set true for eval, default false
void SetMultiLabel(bool multi_label) {
multi_label_ = multi_label;
}

/// Get multi_label, default true
/// Get multi_label, default false
bool GetMultiLabel() const { return multi_label_; }

protected:
Expand Down
26 changes: 15 additions & 11 deletions fastdeploy/vision/detection/contrib/yolov5/preprocessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace vision {
namespace detection {

YOLOv5Preprocessor::YOLOv5Preprocessor() {
resize_after_load_ = false;
size_ = {640, 640};
padding_value_ = {114.0, 114.0, 114.0};
is_mini_pad_ = false;
Expand Down Expand Up @@ -50,7 +51,9 @@ void YOLOv5Preprocessor::LetterBox(FDMat* mat) {
resize_h = size_[1];
resize_w = size_[0];
}
Resize::Run(mat, resize_w, resize_h);
if (resize_h != mat->Height() || resize_w != mat->Width()) {
Resize::Run(mat, resize_w, resize_h);
}
if (pad_h > 0 || pad_w > 0) {
float half_h = pad_h * 1.0 / 2;
int top = int(round(half_h - 0.1));
Expand All @@ -67,18 +70,19 @@ bool YOLOv5Preprocessor::Preprocess(FDMat* mat, FDTensor* output,
// Record the shape of image and the shape of preprocessed image
(*im_info)["input_shape"] = {static_cast<float>(mat->Height()),
static_cast<float>(mat->Width())};

// process after image load
double ratio = (size_[0] * 1.0) / std::max(static_cast<float>(mat->Height()),
static_cast<float>(mat->Width()));
if (std::fabs(ratio - 1.0f) > 1e-06) {
int interp = cv::INTER_AREA;
if (ratio > 1.0) {
interp = cv::INTER_LINEAR;
if (resize_after_load_) {
double ratio = (size_[0] * 1.0) / std::max(static_cast<float>(mat->Height()),
static_cast<float>(mat->Width()));
if (std::fabs(ratio - 1.0f) > 1e-06) {
int interp = cv::INTER_AREA;
if (ratio > 1.0) {
interp = cv::INTER_LINEAR;
}
int resize_h = int(mat->Height() * ratio);
int resize_w = int(mat->Width() * ratio);
Resize::Run(mat, resize_w, resize_h, -1, -1, interp);
}
int resize_h = int(mat->Height() * ratio);
int resize_w = int(mat->Width() * ratio);
Resize::Run(mat, resize_w, resize_h, -1, -1, interp);
}
// yolov5's preprocess steps
// 1. letterbox
Expand Down
11 changes: 11 additions & 0 deletions fastdeploy/vision/detection/contrib/yolov5/preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,23 @@ class FASTDEPLOY_DECL YOLOv5Preprocessor {
/// Get padding value, size should be the same as channels
std::vector<float> GetPaddingValue() const { return padding_value_; }

/// Set resize_after_load, may have an impact on map, default false
void SetResizeAfterLoad(bool resize_after_load) {
resize_after_load_ = resize_after_load;
}

/// Get resize_after_load, default false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resize_after_load这个注释很难让人理解,有没有其它含义

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉resize_after_load,因为此处的resize等价is_scale_up,开放is_scale_up参数,默认为true

bool GetResizeAfterLoad() const { return resize_after_load_; }

protected:
bool Preprocess(FDMat* mat, FDTensor* output,
std::map<std::string, std::array<float, 2>>* im_info);

void LetterBox(FDMat* mat);

// whether resize after image load, may have an impact on map, default false
bool resize_after_load_;

// target size, tuple of (width, height), default size = {640, 640}
std::vector<int> size_;

Expand Down
3 changes: 2 additions & 1 deletion fastdeploy/vision/detection/contrib/yolov5/yolov5_pybind.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ void BindYOLOv5(pybind11::module& m) {
return make_pair(outputs, ims_info);
})
.def_property("size", &vision::detection::YOLOv5Preprocessor::GetSize, &vision::detection::YOLOv5Preprocessor::SetSize)
.def_property("padding_value", &vision::detection::YOLOv5Preprocessor::GetPaddingValue, &vision::detection::YOLOv5Preprocessor::SetPaddingValue);
.def_property("padding_value", &vision::detection::YOLOv5Preprocessor::GetPaddingValue, &vision::detection::YOLOv5Preprocessor::SetPaddingValue)
.def_property("resize_after_load", &vision::detection::YOLOv5Preprocessor::GetResizeAfterLoad, &vision::detection::YOLOv5Preprocessor::SetResizeAfterLoad);

pybind11::class_<vision::detection::YOLOv5Postprocessor>(
m, "YOLOv5Postprocessor")
Expand Down