-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds example to
mediapipe-task-text
(#15)
* initial commit of example * build file changes from `flutter pub get` * update main.dart * removes commented code * updates example for isolates design * Use `native-assets` to vendor MediaPipe SDK (#9) * adding bare structure for native assets * add MVP / first draft of build.dart * build.dart updates * update build.dart TODO: stream file * model memory troubleshooting * vendoring script tweak * remove development logging * removes pointless build method * Add utility to collect headers from google/mediapipe (#10) * adds cmd to pull header files from google/mediapipe * polish and missing parts from git surgery * More comments and touch ups * Apply suggestions from code review * moves build command into `tool/` directory and renames folder `build_cmd` -> `builder` * complete build_cmd -> builder rename * Update readme * Added licenses * Adds DownloadModelCommand --------- Co-authored-by: Kate Lovett <katelovett@google.com> * adds mediapipe_text package * Update .vscode/settings.json added newline * resync headers * regenerated core bindings * native assets troubleshooting this commit is broken * Removes redundant count field * update build.dart for correct bindings path * download text classification model for CI * better memory freeing in executor * added SafeArea to example * added CI to PRs into text package * ci tooling change * remove accidentally commited model * more CI shenanigans * lowers minimum Dart version for builder * added smoke test for text example * Added CI/CD for examples * More CI tweaks * entering "please work" territory * d'oh * trying more random stuff * one more time * it'd be funny if this helped * more print statements * enable reaching new print statements * more logging * see what's in build dir * another test * adding flutter config list * turn off fail-fast for beta and master * moar logs * way moar prints * moare things * commit rest of rename * moar whatevers * adds manifest files generated by new sdks_finder command * adds sdks_finder command to builder utility * propagates changes to existing commands * updates in response to code review * updates to build.dart and tests * add Android runtime * sdks_finder logging improvement for when build folders change names * refreshed symbols from google/mediapipe * cleanup * loosens closeness thresholds in integration tests * separate build commands for macos architectures * restores fail-fast setting to CI * removed stale logging statements from CI * removes accidentally committed lines * add formatting of sdk_downloads.dart for CI * fixes broken example test * code touch ups from @Piinks code review --------- Co-authored-by: Kate Lovett <katelovett@google.com>
- Loading branch information
1 parent
4cd5730
commit 37b2c76
Showing
119 changed files
with
3,881 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import 'dart:ffi'; | ||
import 'package:ffi/ffi.dart'; | ||
|
||
import 'package:mediapipe_core/mediapipe_core.dart'; | ||
import 'package:mediapipe_core/src/third_party/mediapipe/generated/mediapipe_common_bindings.dart' | ||
as core_bindings; | ||
|
||
/// Hydrates a faked [core_bindings.Category] object. | ||
void populateCategory( | ||
core_bindings.Category category, { | ||
int index = 1, | ||
double score = 0.9, | ||
String? categoryName = 'Positive', | ||
String? displayName, | ||
}) { | ||
category.index = index; | ||
category.score = score; | ||
|
||
if (categoryName != null) { | ||
category.category_name = prepareString(categoryName); | ||
} | ||
if (displayName != null) { | ||
category.display_name = prepareString(displayName); | ||
} | ||
} | ||
|
||
/// Hydrates a faked [core_bindings.Classifications] object. | ||
/// | ||
/// If [categories] is passed, [numCategories] must indicate its length; | ||
/// otherwise, this function generates [numCategories] faked | ||
/// [core_bindings.Category] objects. | ||
void populateClassifications( | ||
core_bindings.Classifications classifications, { | ||
Pointer<core_bindings.Category>? categories, | ||
int numCategories = 2, | ||
int headIndex = 1, | ||
String headName = 'Head', | ||
}) { | ||
if (isNotNullOrNullPointer(categories)) { | ||
classifications.categories = categories!; | ||
classifications.categories_count = numCategories; | ||
} else { | ||
final ptrs = calloc<core_bindings.Category>(numCategories); | ||
int count = 0; | ||
while (count < numCategories) { | ||
populateCategory(ptrs[count]); | ||
count++; | ||
} | ||
classifications.categories = ptrs; | ||
classifications.categories_count = numCategories; | ||
} | ||
classifications.head_name = prepareString(headName); | ||
classifications.head_index = headIndex; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.