History

Adds dnn inference module for simple convolutional networks. Reimplements srcnn filter based on it.

Sergey Lavrushkin committed 8 years ago

Commit bdf1bbd1 parent cba16799 files · +2680 −1093Browse files

Showing the changes to libavfilter/dnn_interface.h (1 of 9 files). Show all

Unified · Split

libavfilter/dnn_interface.h+64−0
@@ -0,0 +1,64 @@
1+/*
2+ * Copyright (c) 2018 Sergey Lavrushkin
3+ *
4+ * This file is part of FFmpeg.
5+ *
6+ * FFmpeg is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * FFmpeg is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with FFmpeg; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+/**
22+ * @file
23+ * DNN inference engine interface.
24+ */
25+
26+#ifndef AVFILTER_DNN_INTERFACE_H
27+#define AVFILTER_DNN_INTERFACE_H
28+
29+typedef enum {DNN_SUCCESS, DNN_ERROR} DNNReturnType;
30+
31+typedef enum {DNN_NATIVE} DNNBackendType;
32+
33+typedef enum {DNN_SRCNN} DNNDefaultModel;
34+
35+typedef struct DNNData{
36+ float* data;
37+ int width, height, channels;
38+} DNNData;
39+
40+
41+typedef struct DNNModel{
42+ // Stores model that can be different for different backends.
43+ void* model;
44+ // Sets model input and output, while allocating additional memory for intermediate calculations.
45+ // Should be called at least once before model execution.
46+ DNNReturnType (*set_input_output)(void* model, const DNNData* input, const DNNData* output);
47+} DNNModel;
48+
49+// Stores pointers to functions for loading, executing, freeing DNN models for one of the backends.
50+typedef struct DNNModule{
51+ // Loads model and parameters from given file. Returns NULL if it is not possible.
52+ DNNModel* (*load_model)(const char* model_filename);
53+ // Loads one of the default models
54+ DNNModel* (*load_default_model)(DNNDefaultModel model_type);
55+ // Executes model with specified input and output. Returns DNN_ERROR otherwise.
56+ DNNReturnType (*execute_model)(const DNNModel* model);
57+ // Frees memory allocated for model.
58+ void (*free_model)(DNNModel** model);
59+} DNNModule;
60+
61+// Initializes DNNModule depending on chosen backend.
62+DNNModule* ff_get_dnn_module(DNNBackendType backend_type);
63+
64+#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t