1 /** 2 * Copyright 2021 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_LITE_TOOLS_CONVERTER_CONFIG_PARSER_PREPROCESS_PARSER_H 18 #define MINDSPORE_LITE_TOOLS_CONVERTER_CONFIG_PARSER_PREPROCESS_PARSER_H 19 #include <string> 20 #include <map> 21 #include <vector> 22 #include "tools/converter/preprocess/preprocess_param.h" 23 #include "tools/converter/config_parser/config_file_parser.h" 24 25 namespace mindspore { 26 namespace lite { 27 class PreprocessParser { 28 public: 29 int ParsePreprocess(const DataPreProcessString &data_pre_process_str, 30 preprocess::DataPreProcessParam *data_pre_process); 31 32 private: 33 int ParseInputType(const std::string &input_type_str, preprocess::InputType *input_type); 34 35 int ParseImagePreProcess(const DataPreProcessString &data_pre_process_str, 36 preprocess::ImagePreProcessParam *image_pre_process); 37 38 int ParseImageNormalize(const DataPreProcessString &data_pre_process_str, 39 preprocess::ImagePreProcessParam *image_pre_process); 40 41 int ParseImageResize(const DataPreProcessString &data_pre_process_str, 42 preprocess::ImagePreProcessParam *image_pre_process); 43 44 int ParseImageCenterCrop(const DataPreProcessString &data_pre_process_str, 45 preprocess::ImagePreProcessParam *image_pre_process); 46 47 int ParseImageToFormat(const std::string &image_to_format_str, preprocess::ImageToFormat *image_to_format); 48 49 int ParseCalibratePath(const std::string &str, std::map<std::string, std::string> *value); 50 51 int CollectCalibInputs(const std::map<std::string, std::string> &calibrate_data_path, size_t limited_count, 52 std::map<std::string, std::vector<std::string>> *inputs); 53 }; 54 } // namespace lite 55 } // namespace mindspore 56 #endif // MINDSPORE_LITE_TOOLS_CONVERTER_CONFIG_PARSER_PREPROCESS_PARSER_H 57