Skip to content

Commit 60bd80e

Browse files
committed
build.dart updates
1 parent c986010 commit 60bd80e

File tree

4 files changed

+34
-31
lines changed

4 files changed

+34
-31
lines changed

packages/mediapipe-task-text/build.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import 'dart:io';
2-
import 'package:http/http.dart' as http;
32
import 'package:native_assets_cli/native_assets_cli.dart';
4-
import 'package:native_toolchain_c/native_toolchain_c.dart';
3+
import 'package:http/http.dart' as http;
54

65
const assetFilename = 'libtext_classifier.dylib';
76
const assetLocation =
8-
'https://storage.cloud.google.com/random-storage-asdf/$assetFilename';
7+
'https://storage.googleapis.com/random-storage-asdf/$assetFilename';
98

109
File outputFile = File(
1110
'/Users/craiglabenz/Dev/git/google/flutter-mediapipe/packages/mediapipe-task-text/logs-build.txt');
@@ -37,12 +36,16 @@ Future<void> _build(List<String> args) async {
3736
}
3837
downloadedFile.createSync();
3938
downloadedFile.writeAsBytes(downloadResponse.bodyBytes);
39+
} else {
40+
log('${downloadResponse.statusCode} :: ${downloadResponse.body}');
41+
return;
4042
}
4143
buildOutput.dependencies.dependencies
4244
.add(buildConfig.packageRoot.resolve('build.dart'));
4345
buildOutput.assets.add(
4446
Asset(
45-
id: 'package:mediapipe_text/src/mediapipe_text_bindings.dart',
47+
// What should this `id` be?
48+
id: 'package:mediapipe_text/mediapipe_text.dart',
4649
linkMode: LinkMode.dynamic,
4750
target: Target.macOSArm64,
4851
path: AssetAbsolutePath(downloadFileLocation),

packages/mediapipe-task-text/example/lib/main.dart

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,36 @@ class _MainAppState extends State<MainApp> {
5050

5151
// DefaultAssetBundle.of(context).
5252

53-
// final ByteData classifierBytes = await DefaultAssetBundle.of(context)
54-
// .load('assets/bert_classifier.tflite');
53+
final ByteData classifierBytes = await DefaultAssetBundle.of(context)
54+
.load('assets/bert_classifier.tflite');
5555

56-
final dir = io.Directory(path.current);
57-
final modelPath = path.joinAll(
58-
[dir.absolute.path, 'assets/bert_classifier.tflite'],
59-
);
60-
_log.finest('modelPath: $modelPath');
61-
if (io.File(modelPath).existsSync()) {
62-
_log.fine('Successfully found model.');
63-
} else {
64-
_log.severe('Invalid model path $modelPath. Model not found.');
65-
io.exit(1);
66-
}
56+
// final dir = io.Directory(path.current);
57+
// final modelPath = path.joinAll(
58+
// [dir.absolute.path, 'assets/bert_classifier.tflite'],
59+
// );
60+
// _log.finest('modelPath: $modelPath');
61+
// if (io.File(modelPath).existsSync()) {
62+
// _log.fine('Successfully found model.');
63+
// } else {
64+
// _log.severe('Invalid model path \n\t$modelPath.\n\nModel not found.');
65+
// io.exit(1);
66+
// }
6767

68-
final sdkPath = path.joinAll(
69-
[dir.absolute.path, 'assets/libtext_classifier.dylib'],
70-
);
71-
_log.finest('sdkPath: $sdkPath');
72-
if (io.File(sdkPath).existsSync()) {
73-
_log.fine('Successfully found SDK.');
74-
} else {
75-
_log.severe('Invalid SDK path $sdkPath. SDK not found.');
76-
io.exit(1);
77-
}
68+
// final sdkPath = path.joinAll(
69+
// [dir.absolute.path, 'assets/libtext_classifier.dylib'],
70+
// );
71+
// _log.finest('sdkPath: $sdkPath');
72+
// if (io.File(sdkPath).existsSync()) {
73+
// _log.fine('Successfully found SDK.');
74+
// } else {
75+
// _log.severe('Invalid SDK path $sdkPath. SDK not found.');
76+
// io.exit(1);
77+
// }
7878

7979
_classifier = TextClassifier(
80-
options: TextClassifierOptions.fromAssetPath(modelPath),
81-
// options: TextClassifierOptions.fromAssetBuffer(
82-
// Uint8List.view(classifierBytes.buffer)),
80+
// options: TextClassifierOptions.fromAssetPath(modelPath),
81+
options: TextClassifierOptions.fromAssetBuffer(
82+
Uint8List.view(classifierBytes.buffer)),
8383
// sdkPath: sdkPath,
8484
);
8585
}

packages/mediapipe-task-text/example/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ flutter:
2525

2626
assets:
2727
- assets/bert_classifier.tflite
28-
- assets/libtext_classifier.dylib

packages/mediapipe-task-text/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ dependencies:
1212
flutter:
1313
sdk: flutter
1414
logging: ^1.2.0
15+
http: ^1.1.0
1516
mediapipe_core:
1617
path: ../mediapipe-core
1718
native_assets_cli: ^0.3.0

0 commit comments

Comments
 (0)