!6076 [Data]reame the lite of minddata tar name

Merge pull request !6076 from xulei/lite_test0905
This commit is contained in:
mindspore-ci-bot 2020-09-12 09:41:06 +08:00 committed by Gitee
commit 461eeaf70d
4 changed files with 44 additions and 25 deletions

View File

@ -208,6 +208,9 @@ static void ResizeBilinear1C(const unsigned char *src, int src_width, int src_he
}
bool ResizeBilinear(const LiteMat &src, LiteMat &dst, int dst_w, int dst_h) {
if (dst_h <= 0 || dst_w <= 0) {
return false;
}
if (src.data_type_ != LDataType::UINT8) {
return false;
}
@ -269,6 +272,9 @@ static bool ConvertRGBAToGRAY(const unsigned char *data, LDataType data_type, in
}
bool InitFromPixel(const unsigned char *data, LPixelType pixel_type, LDataType data_type, int w, int h, LiteMat &m) {
if (w <= 0 || h <= 0) {
return false;
}
if (pixel_type == LPixelType::RGBA2BGR) {
return ConvertRGBAToBGR(data, data_type, w, h, m);
} else if (pixel_type == LPixelType::RGBA2GRAY) {
@ -314,7 +320,10 @@ static void CropInternal(const LiteMat &src, LiteMat &dst, int x, int y, int w,
}
bool Crop(const LiteMat &src, LiteMat &dst, int x, int y, int w, int h) {
if (y < 0 || y + h > src.height_ || x < 0 || x + w > src.width_) {
if (x <= 0 || y <= 0 || w <= 0 || h <= 0) {
return false;
}
if (y + h > src.height_ || x + w > src.width_) {
return false;
}
@ -371,7 +380,7 @@ bool SubStractMeanNormalize(const LiteMat &src, LiteMat &dst, float *mean, float
}
template <typename T>
static void PaddWithConstant(const LiteMat &src, LiteMat &dst, const int top, const int bottom, const int left,
static void PadWithConstant(const LiteMat &src, LiteMat &dst, const int top, const int bottom, const int left,
const int right, const PaddBorderType pad_type, uint8_t fill_b_or_gray, uint8_t fill_g,
uint8_t fill_r) {
dst.Init(src.width_ + left + right, src.height_ + top + bottom, src.channel_, src.data_type_);
@ -444,12 +453,15 @@ static void PaddWithConstant(const LiteMat &src, LiteMat &dst, const int top, co
}
}
bool Padd(const LiteMat &src, LiteMat &dst, int top, int bottom, int left, int right, PaddBorderType pad_type,
bool Pad(const LiteMat &src, LiteMat &dst, int top, int bottom, int left, int right, PaddBorderType pad_type,
uint8_t fill_b_or_gray, uint8_t fill_g, uint8_t fill_r) {
if (top <= 0 || bottom <= 0 || left <= 0 || right <= 0) {
return false;
}
if (pad_type == PADD_BORDER_CONSTANT && src.data_type_ == LDataType::FLOAT32) {
PaddWithConstant<float>(src, dst, top, bottom, left, right, pad_type, fill_b_or_gray, fill_g, fill_r);
PadWithConstant<float>(src, dst, top, bottom, left, right, pad_type, fill_b_or_gray, fill_g, fill_r);
} else if (pad_type == PADD_BORDER_CONSTANT && src.data_type_ == LDataType::UINT8) {
PaddWithConstant<uint8_t>(src, dst, top, bottom, left, right, pad_type, fill_b_or_gray, fill_g, fill_r);
PadWithConstant<uint8_t>(src, dst, top, bottom, left, right, pad_type, fill_b_or_gray, fill_g, fill_r);
} else {
return false;
}

View File

@ -66,7 +66,7 @@ bool Crop(const LiteMat &src, LiteMat &dst, int x, int y, int w, int h);
bool SubStractMeanNormalize(const LiteMat &src, LiteMat &dst, float *mean, float *norm);
/// \brief padd image, the channel supports is 3 and 1
bool Padd(const LiteMat &src, LiteMat &dst, int top, int bottom, int left, int right, PaddBorderType pad_type,
bool Pad(const LiteMat &src, LiteMat &dst, int top, int bottom, int left, int right, PaddBorderType pad_type,
uint8_t fill_b_or_gray, uint8_t fill_g, uint8_t fill_r);
/// \brief Apply affine transformation for 1 channel image

View File

@ -210,8 +210,15 @@ if (BUILD_MINDDATA STREQUAL "lite" OR BUILD_MINDDATA STREQUAL "full")
endif ()
if (BUILD_MINDDATA STREQUAL "lite_cv")
# TODO: add sentencepiece dependency
#include(${TOP_DIR}/cmake/external_libs/sentencepiece.cmake)
if (PLATFORM_ARM64)
set(COMPONENT_NAME minddata-arm64-${PROCESS_UNIT})
elseif (PLATFORM_ARM32)
set(COMPONENT_NAME minddata-arm32-${PROCESS_UNIT})
elseif (WIN32)
set(COMPONENT_NAME minddata-win-${PROCESS_UNIT})
else ()
set(COMPONENT_NAME minddata-ubuntu-${PROCESS_UNIT})
endif()
add_compile_definitions(ENABLE_ANDROID)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/minddata)
endif ()

View File

@ -51,7 +51,7 @@ LiteMat Lite3CImageProcess(LiteMat &lite_mat_bgr) {
MS_LOG(ERROR) << "ResizeBilinear error";
}
LiteMat lite_mat_convert_float;
ret = ConvertTo(lite_mat_resize, lite_mat_convert_float, 1.0 );
ret = ConvertTo(lite_mat_resize, lite_mat_convert_float, 1.0);
if (!ret) {
MS_LOG(ERROR) << "ConvertTo error";
}
@ -222,7 +222,7 @@ TEST_F(MindDataImageProcess, TestPadd) {
ResizeBilinear(lite_mat_bgr, lite_mat_resize, 256, 256);
LiteMat makeborder;
Padd(lite_mat_resize, makeborder, top, bottom, left, right, PaddBorderType::PADD_BORDER_CONSTANT, 255, 255, 255);
Pad(lite_mat_resize, makeborder, top, bottom, left, right, PaddBorderType::PADD_BORDER_CONSTANT, 255, 255, 255);
cv::Mat dst_image(256 + top + bottom, 256 + left + right, CV_8UC3, makeborder.data_ptr_);
@ -245,7 +245,7 @@ TEST_F(MindDataImageProcess, TestGetDefaultBoxes) {
int cols = 4;
std::vector<double> benchmark_boxes(rows * cols);
std::ifstream in(benchmark, std::ios::in | std::ios::binary);
in.read(reinterpret_cast<char*>(benchmark_boxes.data()), benchmark_boxes.size() * sizeof(double));
in.read(reinterpret_cast<char *>(benchmark_boxes.data()), benchmark_boxes.size() * sizeof(double));
in.close();
std::vector<std::vector<float>> default_boxes = GetDefaultBoxes(config);
@ -284,13 +284,13 @@ TEST_F(MindDataImageProcess, TestAffine) {
for (size_t i = 0; i < rows; i++) {
for (size_t j = 0; j < cols; j++) {
if (i == 2 && j == 2) {
static_cast<UINT8_C1*>(src.data_ptr_)[i * cols + j] = 3;
static_cast<UINT8_C1 *>(src.data_ptr_)[i * cols + j] = 3;
} else if (i == 2) {
static_cast<UINT8_C1*>(src.data_ptr_)[i * cols + j] = 2;
static_cast<UINT8_C1 *>(src.data_ptr_)[i * cols + j] = 2;
} else if (j == 2) {
static_cast<UINT8_C1*>(src.data_ptr_)[i * cols + j] = 1;
static_cast<UINT8_C1 *>(src.data_ptr_)[i * cols + j] = 1;
} else {
static_cast<UINT8_C1*>(src.data_ptr_)[i * cols + j] = 0;
static_cast<UINT8_C1 *>(src.data_ptr_)[i * cols + j] = 0;
}
}
}
@ -305,13 +305,13 @@ TEST_F(MindDataImageProcess, TestAffine) {
for (size_t i = 0; i < rows; i++) {
for (size_t j = 0; j < cols; j++) {
if (i == 2 && j == 2) {
static_cast<UINT8_C1*>(expect.data_ptr_)[i * cols + j] = 3;
static_cast<UINT8_C1 *>(expect.data_ptr_)[i * cols + j] = 3;
} else if (i == 2) {
static_cast<UINT8_C1*>(expect.data_ptr_)[i * cols + j] = 1;
static_cast<UINT8_C1 *>(expect.data_ptr_)[i * cols + j] = 1;
} else if (j == 2) {
static_cast<UINT8_C1*>(expect.data_ptr_)[i * cols + j] = 2;
static_cast<UINT8_C1 *>(expect.data_ptr_)[i * cols + j] = 2;
} else {
static_cast<UINT8_C1*>(expect.data_ptr_)[i * cols + j] = 0;
static_cast<UINT8_C1 *>(expect.data_ptr_)[i * cols + j] = 0;
}
}
}
@ -329,8 +329,8 @@ TEST_F(MindDataImageProcess, TestAffine) {
for (size_t i = 0; i < rows; i++) {
for (size_t j = 0; j < cols; j++) {
EXPECT_EQ(static_cast<UINT8_C1*>(expect.data_ptr_)[i * cols + j].c1,
static_cast<UINT8_C1*>(dst.data_ptr_)[i * cols + j].c1);
EXPECT_EQ(static_cast<UINT8_C1 *>(expect.data_ptr_)[i * cols + j].c1,
static_cast<UINT8_C1 *>(dst.data_ptr_)[i * cols + j].c1);
}
}
}