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 img load for super-resolution in sdk #2426

Merged
merged 2 commits into from
Sep 13, 2023
Merged
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
8 changes: 7 additions & 1 deletion csrc/mmdeploy/preprocess/transform/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class PrepareImage : public Transform {
explicit PrepareImage(const Value& args) {
to_float32_ = args.value("to_float32", to_float32_);
color_type_ = args.value("color_type", color_type_);
channel_order_ = args.value("channel_order", channel_order_);

cvt_color_ = operation::Managed<CvtColor>::Create();
to_float_ = operation::Managed<ToFloat>::Create();
Expand Down Expand Up @@ -59,7 +60,11 @@ class PrepareImage : public Transform {
Mat src_mat = data["ori_img"].get<Mat>();
Mat dst_mat;
if (color_type_ == "color" || color_type_ == "color_ignore_orientation") {
OUTCOME_TRY(cvt_color_.Apply(src_mat, dst_mat, PixelFormat::kBGR));
if (channel_order_ == "bgr") {
OUTCOME_TRY(cvt_color_.Apply(src_mat, dst_mat, PixelFormat::kBGR));
} else {
OUTCOME_TRY(cvt_color_.Apply(src_mat, dst_mat, PixelFormat::kRGB));
}
} else {
OUTCOME_TRY(cvt_color_.Apply(src_mat, dst_mat, PixelFormat::kGRAYSCALE));
}
Expand Down Expand Up @@ -93,6 +98,7 @@ class PrepareImage : public Transform {
operation::Managed<ToFloat> to_float_;
bool to_float32_{false};
std::string color_type_{"color"};
std::string channel_order_{"bgr"};
};

MMDEPLOY_REGISTER_TRANSFORM2(PrepareImage, (LoadImageFromFile, 0));
Expand Down
Loading