Skip to content

Commit 7450dcf

Browse files
authored
Merge pull request #1700 from fluent/lynettemiles/sc-136162/update-fluent-bit-docs-pipeline-filters-tensorflow
2 parents 335c4cb + b519bf3 commit 7450dcf

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

pipeline/filters/tensorflow.md

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,73 @@
11
# Tensorflow
22

3-
## Tensorflow
3+
The _Tensorflow_ filter plugin allows running machine learning inference tasks on the records of data coming from input plugins or stream processors. This filter uses [Tensorflow Lite](https://www.tensorflow.org/lite/) as the inference engine, and requires Tensorflow Lite shared library to be present during build and at runtime.
44

5-
_Tensorflow Filter_ allows running Machine Learning inference tasks on the records of data coming from input plugins or stream processor. This filter uses [Tensorflow Lite](https://www.tensorflow.org/lite/) as the inference engine, and **requires Tensorflow Lite shared library to be present during build and at runtime**.
5+
Tensorflow Lite is a lightweight open source deep learning framework used for mobile and IoT applications. Tensorflow Lite only handles inference, not training. It loads pre-trained models (`.tflite` files) that are converted into Tensorflow Lite format (`FlatBuffer`). You can read more on converting [Tensorflow models](https://www.tensorflow.org/lite/convert).
66

7-
Tensorflow Lite is a lightweight open-source deep learning framework that is used for mobile and IoT applications. Tensorflow Lite only handles inference \(not training\), therefore, it loads pre-trained models \(`.tflite` files\) that are converted into Tensorflow Lite format \(`FlatBuffer`\). You can read more on converting Tensorflow models [here](https://www.tensorflow.org/lite/convert)
7+
The Tensorflow plugin for Fluent Bit has the following limitations:
88

9-
### Configuration Parameters
9+
- Currently supports single-input models
10+
- Uses Tensorflow 2.3 header files
11+
12+
## Configuration parameters
1013

1114
The plugin supports the following configuration parameters:
1215

1316
| Key | Description | Default |
1417
| :--- | :--- | :--- |
15-
| input\_field | Specify the name of the field in the record to apply inference on. | |
16-
| model\_file | Path to the model file \(`.tflite`\) to be loaded by Tensorflow Lite. | |
17-
| include\_input\_fields | Include all input filed in filter's output | True |
18-
| normalization\_value | Divide input values to normalization\_value | |
18+
| `input_field` | Specify the name of the field in the record to apply inference on. | _none_ |
19+
| `model_file` | Path to the model file (`.tflite`) to be loaded by Tensorflow Lite. | _none_ |
20+
| `include_input_fields` | Include all input filed in filter's output. | `True` |
21+
| `normalization_value` | Divide input values to `normalization_value`. | _none_ |
1922

20-
### Creating Tensorflow Lite shared library
23+
## Creating a Tensorflow Lite shared library
2124

22-
Clone [Tensorflow repository](https://github.com/tensorflow/tensorflow), install bazel package manager, and run the following command in order to create the shared library:
25+
To create a Tensorflow Lite shared library:
2326

24-
```bash
25-
$ bazel build -c opt //tensorflow/lite/c:tensorflowlite_c # see https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/c
26-
```
27+
1. Clone the [Tensorflow repository](https://github.com/tensorflow/tensorflow).
28+
1. Install the [Bazel](https://bazel.build/) package manager.
29+
1. Run the following command to create the shared library:
30+
31+
```bash
32+
bazel build -c opt //tensorflow/lite/c:tensorflowlite_c # see https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/c
33+
```
2734

28-
The script creates the shared library `bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so`. You need to copy the library to a location \(such as `/usr/lib`\) that can be used by Fluent Bit.
35+
The script creates the shared library
36+
`bazel-bin/tensorflow/lite/c/libtensorflowlite_c.so`.
37+
1. Copy the library to a location such as `/usr/lib` that can be used by Fluent Bit.
2938

30-
### Building Fluent Bit with Tensorflow filter plugin
39+
## Building Fluent Bit with Tensorflow filter plugin
3140

32-
Tensorflow filter plugin is disabled by default. You need to build Fluent Bit with Tensorflow plugin enabled. In addition, it requires access to Tensorflow Lite header files to compile. Therefore, you also need to pass the address of the Tensorflow source code on your machine to the [build script](https://github.com/fluent/fluent-bit#build-from-scratch):
41+
The Tensorflow filter plugin is disabled by default. You must build Fluent Bit with the Tensorflow plugin enabled. In addition, it requires access to Tensorflow Lite header files to compile. Therefore, you must pass the address of the Tensorflow source code on your machine to the [build script](https://github.com/fluent/fluent-bit#build-from-scratch):
3342

3443
```bash
3544
cmake -DFLB_FILTER_TENSORFLOW=On -DTensorflow_DIR=<AddressOfTensorflowSourceCode> ...
3645
```
3746

38-
#### Command line
47+
### Command line
3948

40-
If Tensorflow plugin initializes correctly, it reports successful creation of the interpreter, and prints a summary of model's input/output types and dimensions.
49+
If Tensorflow plugin initializes correctly, it reports successful creation of the interpreter, and prints a summary of model's input and output types and dimensions.
50+
51+
The command:
4152

4253
```bash
43-
$ bin/fluent-bit -i mqtt -p 'tag=mqtt.data' -F tensorflow -m '*' -p 'input_field=image' -p 'model_file=/home/user/model.tflite' -p 'include_input_fields=false' -p 'normalization_value=255' -o stdout
54+
bin/fluent-bit -i mqtt -p 'tag=mqtt.data' -F tensorflow -m '*' -p 'input_field=image' -p 'model_file=/home/user/model.tflite' -p
55+
```
56+
57+
produces an output like:
58+
59+
```text
60+
'include_input_fields=false' -p 'normalization_value=255' -o stdout
4461
[2020/08/04 20:00:00] [ info] Tensorflow Lite interpreter created!
4562
[2020/08/04 20:00:00] [ info] [tensorflow] ===== input #1 =====
4663
[2020/08/04 20:00:00] [ info] [tensorflow] type: FLOAT32 dimensions: {1, 224, 224, 3}
4764
[2020/08/04 20:00:00] [ info] [tensorflow] ===== output #1 ====
4865
[2020/08/04 20:00:00] [ info] [tensorflow] type: FLOAT32 dimensions: {1, 2}
4966
```
5067

51-
#### Configuration File
68+
### Configuration file
5269

53-
```text
70+
```python
5471
[SERVICE]
5572
Flush 1
5673
Daemon Off
@@ -72,9 +89,3 @@ $ bin/fluent-bit -i mqtt -p 'tag=mqtt.data' -F tensorflow -m '*' -p 'input_field
7289
Name stdout
7390
Match *
7491
```
75-
76-
## Limitations
77-
78-
1. Currently supports single-input models
79-
2. Uses Tensorflow 2.3 header files
80-

vale-styles/FluentBit/Spelling-exceptions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ autoscaler
1010
autoscaling
1111
backoff
1212
backpressure
13+
Bazel
1314
BitBake
1415
Blackhole
1516
blocklist
@@ -175,6 +176,7 @@ Tanzu
175176
Telegraf
176177
templated
177178
temporality
179+
Tensorflow
178180
Terraform
179181
Thanos
180182
Timeshift

0 commit comments

Comments
 (0)