! * @brief Find the model file or label file according to the file name * @param fname The model file name or label file name * @return The fullname of the file that founded * @note Firstly, search the file in current directory; * if failed, search the file in "Tengine_root/models/"; * if still failed, display error message and return empty string. */
| 100 | * if still failed, display error message and return empty string. |
| 101 | */ |
| 102 | std::string get_file(const char* fname) |
| 103 | { |
| 104 | FILE* fp; |
| 105 | std::string fn = fname; |
| 106 | |
| 107 | const std::string mod_sch1 = "./" + fn; |
| 108 | const std::string mod_sch2 = get_root_path() + "models/" + fn; |
| 109 | |
| 110 | fp = fopen(mod_sch1.c_str(), "r"); |
| 111 | if(fp) |
| 112 | { |
| 113 | fclose(fp); |
| 114 | return mod_sch1; |
| 115 | } |
| 116 | else |
| 117 | { |
| 118 | fp = fopen(mod_sch2.c_str(), "r"); |
| 119 | if(fp) |
| 120 | { |
| 121 | fclose(fp); |
| 122 | return mod_sch2; |
| 123 | } |
| 124 | else |
| 125 | { |
| 126 | std::cerr << "Can't find " << fn << " in current dir and models dir.\n"; |
| 127 | return std::string(""); |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | bool check_file_exist(const std::string file_name) |
| 133 | { |