!19061 Export .so & header files of lite_cv when MSLITE_ENABLE_TRAIN=on
Merge pull request !19061 from luoyang/issues
This commit is contained in:
commit
264d7fafce
|
@ -23,7 +23,9 @@ set(MINDSPORE_LITE_TRAIN_LIB_NAME libmindspore-lite-train)
|
|||
set(BENCHMARK_TRAIN_NAME benchmark_train)
|
||||
set(BENCHMARK_TRAIN_ROOT_DIR ${RUNTIME_PKG_NAME}/tools/benchmark_train)
|
||||
|
||||
# full mode will also package the files of lite_cv mode.
|
||||
if(BUILD_MINDDATA STREQUAL "full")
|
||||
# full header files
|
||||
install(FILES
|
||||
${TOP_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h
|
||||
${TOP_DIR}/mindspore/ccsrc/minddata/dataset/include/dataset/data_helper.h
|
||||
|
@ -65,6 +67,10 @@ if(BUILD_MINDDATA STREQUAL "full")
|
|||
install(FILES ${TOP_DIR}/mindspore/lite/build/securec/src/libsecurec.a
|
||||
DESTINATION ${SECUREC_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
|
||||
endif()
|
||||
|
||||
# lite_cv header files
|
||||
install(DIRECTORY ${TOP_DIR}/mindspore/ccsrc/minddata/dataset/kernels/image/lite_cv
|
||||
DESTINATION ${MIND_DATA_INC_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
|
||||
endif()
|
||||
|
||||
if(BUILD_MINDDATA STREQUAL "wrapper")
|
||||
|
|
|
@ -5,8 +5,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -fPIC -std=c++17")
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
|
||||
|
||||
set(MS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mindspore-lite-1.2.0-linux-x64/runtime")
|
||||
set(LITECV_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mindspore-lite-1.2.0-linux-x64/runtime/include/dataset")
|
||||
|
||||
include_directories(${MS_DIR})
|
||||
include_directories(${MS_DIR} ${LITECV_DIR})
|
||||
|
||||
|
||||
add_executable(testlenet
|
||||
|
@ -29,4 +30,14 @@ target_link_libraries(testresize
|
|||
${MS_DIR}/third_party/libjpeg-turbo/lib/libjpeg.so.62
|
||||
${MS_DIR}/third_party/libjpeg-turbo/lib/libturbojpeg.so.0
|
||||
${MS_DIR}/lib/libmindspore-lite.so
|
||||
pthread)
|
||||
|
||||
add_executable(testlitecv
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/testlitecv.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(testlitecv
|
||||
${MS_DIR}/lib/libminddata-lite.so
|
||||
${MS_DIR}/third_party/libjpeg-turbo/lib/libjpeg.so.62
|
||||
${MS_DIR}/third_party/libjpeg-turbo/lib/libturbojpeg.so.0
|
||||
pthread)
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* Copyright 2021 Huawei Technologies Co., Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "include/api/types.h"
|
||||
#include "include/dataset/lite_cv/lite_mat.h"
|
||||
#include "include/dataset/lite_cv/image_process.h"
|
||||
#include "include/dataset/vision_lite.h"
|
||||
#include "include/dataset/execute.h"
|
||||
|
||||
using mindspore::dataset::Execute;
|
||||
using mindspore::dataset::LDataType;
|
||||
using mindspore::dataset::LiteMat;
|
||||
using mindspore::dataset::PaddBorderType;
|
||||
using mindspore::dataset::vision::Decode;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
std::ifstream ifs("test_image.jpg");
|
||||
|
||||
if (!ifs.is_open() || !ifs.good()) {
|
||||
std::cout << "fail to load image, check image path" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ifs.seekg(0, std::ios::end);
|
||||
size_t size = ifs.tellg();
|
||||
mindspore::MSTensor image("file", mindspore::DataType::kNumberTypeUInt8, {static_cast<int64_t>(size)}, nullptr, size);
|
||||
|
||||
ifs.seekg(0, std::ios::beg);
|
||||
ifs.read(reinterpret_cast<char *>(image.MutableData()), size);
|
||||
ifs.close();
|
||||
|
||||
auto decode = Decode();
|
||||
auto executor = Execute(decode);
|
||||
executor(image, &image);
|
||||
|
||||
LiteMat lite_mat_rgb(image.Shape()[1], image.Shape()[0], image.Shape()[2], const_cast<void *>(image.Data().get()),
|
||||
LDataType::UINT8);
|
||||
std::cout << "lite_mat_rgb: height=" << lite_mat_rgb.height_ << ", width=" << lite_mat_rgb.width_ << std::endl;
|
||||
LiteMat lite_mat_resize;
|
||||
|
||||
ResizeBilinear(lite_mat_rgb, lite_mat_resize, 256, 256);
|
||||
std::cout << "lite_mat_resize: height=" << lite_mat_resize.height_ << ", width=" << lite_mat_resize.width_
|
||||
<< std::endl;
|
||||
|
||||
LiteMat lite_mat_pad;
|
||||
Pad(lite_mat_resize, lite_mat_pad, 30, 30, 10, 10, PaddBorderType::PADD_BORDER_CONSTANT, 255, 255, 255);
|
||||
std::cout << "lite_mat_pad: height=" << lite_mat_pad.height_ << ", width=" << lite_mat_pad.width_ << std::endl;
|
||||
}
|
Loading…
Reference in New Issue