| 170 | static void dummy_deallocator(void* data, size_t len, void* arg) {} |
| 171 | |
| 172 | int main(int argc, char* argv[]) |
| 173 | { |
| 174 | const string root_path = get_root_path(); |
| 175 | #ifdef MOBILE_NET |
| 176 | const string model_file = root_path + "models/frozen_mobilenet_v1_224.pb"; |
| 177 | const string image_file = root_path + "tests/images/cat.jpg"; |
| 178 | const string label_file = root_path + "models/synset_words.txt"; |
| 179 | int input_height = 224; |
| 180 | int input_width = 224; |
| 181 | float input_mean = -127; |
| 182 | float input_std = 127; |
| 183 | #elif RESNET50 |
| 184 | const string model_file = root_path + "models/frozen_resnet50v1.pb"; |
| 185 | const string image_file = root_path + "tests/images/bike.jpg"; |
| 186 | const string label_file = root_path + "models/synset_words.txt"; |
| 187 | int input_height = 224; |
| 188 | int input_width = 224; |
| 189 | float input_mean = 0; |
| 190 | float input_std = 1; |
| 191 | #else |
| 192 | const string model_file = root_path + "models/inception_v3_2016_08_28_frozen.pb"; |
| 193 | const string image_file = root_path + "tests/images/grace_hopper.jpg"; |
| 194 | const string label_file = root_path + "models/imagenet_slim_labels.txt"; |
| 195 | int input_height = 299; |
| 196 | int input_width = 299; |
| 197 | float input_mean = 0; |
| 198 | float input_std = 255; |
| 199 | #endif |
| 200 | |
| 201 | #ifdef MOBILE_NET |
| 202 | string input_layer = "input"; |
| 203 | string output_layer = "MobilenetV1/Predictions/Softmax"; |
| 204 | #elif RESNET50 |
| 205 | string input_layer = "input"; |
| 206 | string output_layer = "resnet_v1_50/predictions/Softmax"; |
| 207 | #else |
| 208 | string input_layer = "input"; |
| 209 | string output_layer = "InceptionV3/Predictions/Softmax"; |
| 210 | #endif |
| 211 | |
| 212 | // Load and initialize the model |
| 213 | TF_Graph* graph = TF_NewGraph(); |
| 214 | TF_Session* session = LoadGraph(model_file.c_str(), graph); |
| 215 | if(!session) |
| 216 | return -1; |
| 217 | |
| 218 | // Read image file |
| 219 | cv::Mat img; |
| 220 | float* input_data = ReadImageFile(image_file.c_str(), img, input_height, input_width, input_mean, input_std); |
| 221 | if(!input_data) |
| 222 | return -1; |
| 223 | |
| 224 | // Create input tensor |
| 225 | vector<TF_Output> input_names; |
| 226 | vector<TF_Tensor*> input_values; |
| 227 | |
| 228 | TF_Operation* input_name = TF_GraphOperationByName(graph, input_layer.c_str()); |
| 229 | input_names.push_back({input_name, 0}); |
nothing calls this directly
no test coverage detected