Skip to content

Commit f7bed11

Browse files
committed
build.dart updates
1 parent c986010 commit f7bed11

File tree

4 files changed

+37
-31
lines changed

4 files changed

+37
-31
lines changed

packages/mediapipe-task-text/build.dart

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

66
const assetFilename = 'libtext_classifier.dylib';
77
const assetLocation =
8-
'https://storage.cloud.google.com/random-storage-asdf/$assetFilename';
8+
'https://storage.googleapis.com/random-storage-asdf/$assetFilename';
99

1010
File outputFile = File(
1111
'/Users/craiglabenz/Dev/git/google/flutter-mediapipe/packages/mediapipe-task-text/logs-build.txt');
@@ -29,20 +29,26 @@ Future<void> _build(List<String> args) async {
2929
final downloadUri = Uri.parse(assetLocation);
3030
final downloadFileLocation = buildConfig.outDir.resolve(assetFilename);
3131
log('Downloading $downloadUri');
32-
final downloadResponse = await http.get(downloadUri);
32+
final downloadResponse =
33+
// await client.get(downloadUri.host, downloadUri.port, downloadUri.path);
34+
await http.get(downloadUri);
3335
final downloadedFile = File(downloadFileLocation.toFilePath());
3436
if (downloadResponse.statusCode == 200) {
3537
if (downloadedFile.existsSync()) {
3638
downloadedFile.deleteSync();
3739
}
3840
downloadedFile.createSync();
41+
// final allBytes = <int>[];
42+
// await for (List<int> bytes in downloadResponse) {
43+
// allBytes.addAll(bytes);
44+
// }
3945
downloadedFile.writeAsBytes(downloadResponse.bodyBytes);
4046
}
4147
buildOutput.dependencies.dependencies
4248
.add(buildConfig.packageRoot.resolve('build.dart'));
4349
buildOutput.assets.add(
4450
Asset(
45-
id: 'package:mediapipe_text/src/mediapipe_text_bindings.dart',
51+
id: 'package:mediapipe_text/mediapipe_text.dart',
4652
linkMode: LinkMode.dynamic,
4753
target: Target.macOSArm64,
4854
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)