1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
16 * @brief A SetGenerator provides utility functions to read labels and create a multimap of images for pre-processing
18 class ClassificationSetGenerator {
19 std::map<std::string, int> _classes;
21 std::vector<std::pair<int, std::string>> validationMapFromTxt(const std::string& file);
22 std::vector<std::pair<int, std::string>> validationMapFromFolder(const std::string& dir);
25 std::list<std::string> getDirContents(const std::string& dir, bool includePath = true);
30 * @brief Reads file with a list of classes names. Every found line is considered to be
31 * a class name with ID equal to line number - 1 (zero based)
32 * @param labels - name of a file with labels
33 * @return <class name, ID> map
35 std::map<std::string, int> readLabels(const std::string& labels);
38 * @brief Creates a vector of pairs <class id, path to picture> to reflect
39 * images data reflected by path provided
40 * @param path - can be a .txt file or a folder. In case of file parses it assuming format is
41 * relative_path_from_folder_with_txt_extension/image_id. In case of folder searches
42 * all subfolders which are named exactly like known classes and adds all containing
43 * files to a map with ID corresponding to subfolder name
44 * @return vector of pairs {ID: IMAGEPATH} describing all found images. In case folder path was
45 * provided and no class names are known returns empty map
47 std::vector<std::pair<int, std::string>> getValidationMap(const std::string& path);