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

[Fix] Fix several bugs in the preprocessing of single channel images #1666

Merged
merged 1 commit into from
Jan 19, 2023
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
9 changes: 5 additions & 4 deletions csrc/mmdeploy/operation/cuda/cvtcolor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,20 @@ class CvtColorImpl : public CvtColor {

auto height = src.height();
auto width = src.width();
auto channels = src.channel();
auto stride = width * channels;
auto src_channels = src.channel();
auto src_stride = width * src_channels;

Mat dst_mat(height, width, dst_fmt, src.type(), device());
auto dst_stride = width * dst_mat.channel();

auto convert = [&](auto type) -> Result<void> {
using T = typename decltype(type)::type;
auto converter = GetConverter<T>(src.pixel_format(), dst_fmt);
if (!converter) {
return Status(eNotSupported);
}
auto ret =
converter(cuda_stream, height, width, stride, src.data<T>(), stride, dst_mat.data<T>());
auto ret = converter(cuda_stream, height, width, src_stride, src.data<T>(), dst_stride,
dst_mat.data<T>());
if (ret != ppl::common::RC_SUCCESS) {
return Status(eFail);
}
Expand Down
2 changes: 1 addition & 1 deletion csrc/mmdeploy/preprocess/transform/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class PrepareImage : public Transform {
if (color_type_ == "color" || color_type_ == "color_ignore_orientation") {
OUTCOME_TRY(cvt_color_.Apply(src_mat, dst_mat, PixelFormat::kBGR));
} else {
OUTCOME_TRY(cvt_color_.Apply(dst_mat, dst_mat, PixelFormat::kGRAYSCALE));
OUTCOME_TRY(cvt_color_.Apply(src_mat, dst_mat, PixelFormat::kGRAYSCALE));
}
auto tensor = to_tensor(dst_mat);
if (to_float32_) {
Expand Down