Skip to content

Commit 1863fd3

Browse files
author
Mathieu
committed
chore(melos): update readme and add melos for FFI code generation
1 parent 5398864 commit 1863fd3

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

README.md

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</br>
55
</p>
66
<p align="center">
7-
7+
88
<a href="https://flutter.dev">
99
<img src="https://img.shields.io/badge/Platform-Flutter-02569B?logo=flutter"
1010
alt="Platform" />
@@ -18,7 +18,6 @@
1818
</a>
1919
<a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a>
2020

21-
2221
</a>
2322
</p>
2423

@@ -40,16 +39,14 @@ Thanks!
4039

4140
TensorFlow Lite Flutter plugin provides a flexible and fast solution for accessing TensorFlow Lite interpreter and performing inference. The API is similar to the TFLite Java and Swift APIs. It directly binds to TFLite C API making it efficient (low-latency). Offers acceleration support using NNAPI, GPU delegates on Android, Metal and CoreML delegates on iOS, and XNNPack delegate on Desktop platforms.
4241

43-
4442
## Key Features
4543

46-
* Multi-platform Support for Android and iOS
47-
* Flexibility to use any TFLite Model.
48-
* Acceleration using multi-threading.
49-
* Similar structure as TensorFlow Lite Java API.
50-
* Inference speeds close to native Android Apps built using the Java API.
51-
* Run inference in different isolates to prevent jank in UI thread.
52-
44+
- Multi-platform Support for Android and iOS
45+
- Flexibility to use any TFLite Model.
46+
- Acceleration using multi-threading.
47+
- Similar structure as TensorFlow Lite Java API.
48+
- Inference speeds close to native Android Apps built using the Java API.
49+
- Run inference in different isolates to prevent jank in UI thread.
5350

5451
## (Important) Initial setup : Add dynamic libraries to your app
5552

@@ -133,7 +130,7 @@ install(
133130

134131
## TFLite Flutter Helper Library
135132

136-
The helper library has been deprecated. New development underway for a replacement at https://github.com/google/flutter-mediapipe. Current timeline is to have wide support by the end of August, 2023.
133+
The helper library has been deprecated. New development underway for a replacement at <https://github.com/google/flutter-mediapipe>. Current timeline is to have wide support by the end of August, 2023.
137134

138135
## Import
139136

@@ -144,11 +141,12 @@ import 'package:tflite_flutter/tflite_flutter.dart';
144141
## Usage instructions
145142

146143
### Import the libraries
144+
147145
In the dependency section of `pubspec.yaml` file, add `tflite_flutter: ^0.10.1` (adjust the version accordingly based on the latest release)
148146

149147
### Creating the Interpreter
150148

151-
* **From asset**
149+
- **From asset**
152150

153151
Place `your_model.tflite` in `assets` directory. Make sure to include assets in `pubspec.yaml`.
154152

@@ -160,9 +158,10 @@ Refer to the documentation for info on creating interpreter from buffer or file.
160158
161159
### Performing inference
162160
163-
* **For single input and output**
161+
- **For single input and output**
164162
165163
Use `void run(Object input, Object output)`.
164+
166165
```dart
167166
// For ex: if input tensor shape [1,5] and type is float32
168167
var input = [[1.23, 6.54, 7.81, 3.21, 2.22]];
@@ -177,7 +176,7 @@ Refer to the documentation for info on creating interpreter from buffer or file.
177176
print(output);
178177
```
179178
180-
* **For multiple inputs and outputs**
179+
- **For multiple inputs and outputs**
181180
182181
Use `void runForMultipleInputs(List<Object> inputs, Map<int, Object> outputs)`.
183182
@@ -225,3 +224,20 @@ await isolateInterpreter.runForMultipleInputs(inputs, outputs);
225224
```
226225

227226
By using `IsolateInterpreter`, the inference runs in a separate isolate. This ensures that the main isolate, responsible for UI tasks, remains unblocked and responsive.
227+
228+
## Contribute to this package
229+
230+
This package is managed using [melos](https://pub.dev/packages/melos). Before starting to work on the project, make sure to run the bootstrap command.
231+
232+
```sh
233+
dart pub global activate melos # Install or activate melos globally
234+
melos bootstrap # Initialize the workspace and bootstrap the package
235+
```
236+
237+
### Generated code
238+
239+
This package uses [ffigen](https://pub.dev/packages/ffigen) to generate FFI bindings. To run code generation, you can use the following melos command:
240+
241+
```sh
242+
melos run ffigen
243+
```

melos.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ command:
2727
branch: main
2828
linkToCommits: true
2929
workspaceChangelog: true
30+
31+
scripts:
32+
ffigen:
33+
name: ffigen
34+
description: Call ffigen and generate bindings for `src/tensorflow_lite/c_api.h`.
35+
run: flutter pub run ffigen --config ffigen_tensorflow_lite.yaml

0 commit comments

Comments
 (0)