Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions csrc/mmdeploy/preprocess/transform/pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class Pad : public Transform {
data["pad_fixed_size"].push_back(pad_h);
data["pad_fixed_size"].push_back(pad_w);
} else {
padding = {0, 0, size_[1] - width, size_[0] - height};
data["pad_fixed_size"].push_back(size_[0]);
padding = {0, 0, size_[0] - width, size_[1] - height};
data["pad_fixed_size"].push_back(size_[1]);
data["pad_fixed_size"].push_back(size_[0]);
Comment on lines 86 to +87
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

That's weird. In mmcv's document, pad_shape is formed with (height, width) which should be self.size here.

Copy link
Member Author

Choose a reason for hiding this comment

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

}
} else if (size_divisor_ != 1) {
auto pad_h = (height + size_divisor_ - 1) / size_divisor_ * size_divisor_;
Expand Down
12 changes: 9 additions & 3 deletions csrc/mmdeploy/preprocess/transform/resize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ class Resize : public Transform {
MMDEPLOY_ERROR("'size' expects an array of size 2, but got {}", args["size"].size());
throw_exception(eInvalidArgument);
}
auto height = args["size"][0].get<int>();
auto width = args["size"][1].get<int>();
img_scale_ = {height, width};
// the order in openmmalb config is [width, height], while in SDK it is [height, width]
// keep the last dim -1
auto width = args["size"][0].get<int>();
auto height = args["size"][1].get<int>();
if (-1 == height) {
img_scale_ = {width, -1};
} else {
img_scale_ = {height, width};
}
} else {
MMDEPLOY_ERROR("'size' is expected to be an integer or and array of size 2");
throw_exception(eInvalidArgument);
Expand Down
2 changes: 1 addition & 1 deletion tests/test_csrc/preprocess/test_pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ TEST_CASE("transform 'Pad'", "[pad]") {
constexpr int width = 800;
for (auto& mat : mats) {
for (auto& mode : modes) {
Value cfg{{"type", "Pad"}, {"size", {height, width}}, {"padding_mode", mode}};
Value cfg{{"type", "Pad"}, {"size", {width, height}}, {"padding_mode", mode}};
auto [pad_left, pad_top, pad_right, pad_bottom] = GetPadSize(mat, height, width);
TestPad(cfg, mat, pad_top, pad_left, pad_bottom, pad_right, border_map[mode], 0);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_csrc/preprocess/test_resize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ TEST_CASE("resize transform: size", "[resize]") {
for (auto& mat : mats) {
for (auto& interp : interpolations) {
Value cfg{{"type", "Resize"},
{"size", {dst_height, dst_width}},
{"size", {dst_width, dst_height}},
{"keep_ratio", keep_ratio},
{"interpolation", interp}};
TestResize(cfg, kHost, mat, dst_height, dst_width);
Expand Down