currently, the layer number is at the beginning of the .model file, so we have to scan twice in python script, the first scan to get the layer number. Only one scan needed after put the layer number at the end of .model file.
Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -93,8 +93,10 @@ DNNModel *ff_dnn_load_model_native(const char *model_filename) · 92 unmodified lines | |||
| 93 | } | 93 | } |
| 94 | model->model = (void *)network; | 94 | model->model = (void *)network; |
| 95 | 95 | ||
| 96 | avio_seek(model_file_context, file_size - 4, SEEK_SET); | ||
| 96 | network->layers_num = (int32_t)avio_rl32(model_file_context); | 97 | network->layers_num = (int32_t)avio_rl32(model_file_context); |
| 97 | dnn_size = 4; | 98 | dnn_size = 4; |
| 99 | avio_seek(model_file_context, 0, SEEK_SET); | ||
| 98 | 100 | ||
| 99 | network->layers = av_mallocz(network->layers_num * sizeof(Layer)); | 101 | network->layers = av_mallocz(network->layers_num * sizeof(Layer)); |
| 100 | if (!network->layers){ | 102 | if (!network->layers){ |