Skip to content

Commit 5094db7

Browse files
committed
yet more
1 parent 622091f commit 5094db7

File tree

3 files changed

+54
-12
lines changed

3 files changed

+54
-12
lines changed

tfserving-flutter/codelab2/finished/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ flutter:
6262
uses-material-design: true
6363

6464
assets:
65-
- assets/vocab.txt
65+
- assets/vocab.txt
6666

6767
# An image asset can refer to one or more resolution-specific "variants", see
6868
# https://flutter.dev/to/resolution-aware-images

tfserving-flutter/codelab2/starter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ flutter:
6262
uses-material-design: true
6363

6464
assets:
65-
- assets/vocab.txt
65+
- assets/vocab.txt
6666

6767
# An image asset can refer to one or more resolution-specific "variants", see
6868
# https://flutter.dev/to/resolution-aware-images

tfserving-flutter/codelab_rebuild.yaml

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ steps:
3434
@@ -61,10 +61,8 @@ flutter:
3535
# the material Icons class.
3636
uses-material-design: true
37-
37+
3838
- # To add assets to your application, add an assets section, like this:
3939
- # assets:
4040
- # - images/a_dot_burr.jpeg
4141
- # - images/a_dot_ham.jpeg
4242
+ assets:
43-
+ - assets/vocab.txt
44-
43+
+ - assets/vocab.txt
44+
4545
# An image asset can refer to one or more resolution-specific "variants", see
4646
# https://flutter.dev/to/resolution-aware-images
4747
- name: Mkdir assets
@@ -654,8 +654,50 @@ steps:
654654
+ <true/>
655655
</dict>
656656
</plist>
657+
- name: Mkdir lib/proto
658+
path: codelab2/tfserving_flutter
659+
mkdir: lib/proto
660+
- name: Add generate_grpc_stub_dart.sh
661+
path: codelab2/tfserving_flutter/lib/proto/generate_grpc_stub_dart.sh
662+
replace-contents: |
663+
#!/bin/bash
664+
# This script generates the client stub for TF Serving
657665
666+
touch generated
667+
rm -rf generated
668+
mkdir generated
658669
670+
protoc -I./ ./tensorflow_serving/apis/input.proto --dart_out=grpc:./generated
671+
protoc -I./ ./tensorflow_serving/apis/regression.proto --dart_out=grpc:./generated
672+
protoc -I./ ./tensorflow_serving/apis/predict.proto --dart_out=grpc:./generated
673+
protoc -I./ ./tensorflow_serving/apis/prediction_service.proto --dart_out=grpc:./generated
674+
protoc -I./ ./tensorflow_serving/apis/get_model_metadata.proto --dart_out=grpc:./generated
675+
protoc -I./ ./tensorflow_serving/apis/inference.proto --dart_out=grpc:./generated
676+
protoc -I./ ./tensorflow_serving/apis/model.proto --dart_out=grpc:./generated
677+
protoc -I./ ./tensorflow_serving/apis/classification.proto --dart_out=grpc:./generated
678+
679+
protoc -I./ ./tensorflow/core/framework/graph.proto --dart_out=grpc:./generated
680+
protoc -I./ ./tensorflow/core/framework/tensor_shape.proto --dart_out=grpc:./generated
681+
protoc -I./ ./tensorflow/core/framework/function.proto --dart_out=grpc:./generated
682+
protoc -I./ ./tensorflow/core/framework/variable.proto --dart_out=grpc:./generated
683+
protoc -I./ ./tensorflow/core/framework/types.proto --dart_out=grpc:./generated
684+
protoc -I./ ./tensorflow/core/framework/full_type.proto --dart_out=grpc:./generated
685+
protoc -I./ ./tensorflow/core/framework/versions.proto --dart_out=grpc:./generated
686+
protoc -I./ ./tensorflow/core/framework/attr_value.proto --dart_out=grpc:./generated
687+
protoc -I./ ./tensorflow/core/framework/op_def.proto --dart_out=grpc:./generated
688+
protoc -I./ ./tensorflow/core/framework/node_def.proto --dart_out=grpc:./generated
689+
protoc -I./ ./tensorflow/core/framework/tensor.proto --dart_out=grpc:./generated
690+
protoc -I./ ./tensorflow/core/framework/resource_handle.proto --dart_out=grpc:./generated
691+
protoc -I./ ./tensorflow/core/example/feature.proto --dart_out=grpc:./generated
692+
protoc -I./ ./tensorflow/core/example/example.proto --dart_out=grpc:./generated
693+
protoc -I./ ./tensorflow/core/protobuf/struct.proto --dart_out=grpc:./generated
694+
protoc -I./ ./tensorflow/core/protobuf/meta_graph.proto --dart_out=grpc:./generated
695+
protoc -I./ ./tensorflow/core/protobuf/saver.proto --dart_out=grpc:./generated
696+
protoc -I./ ./tensorflow/core/protobuf/trackable_object_graph.proto --dart_out=grpc:./generated
697+
protoc -I./ ./tensorflow/core/protobuf/saved_object_graph.proto --dart_out=grpc:./generated
698+
699+
protoc -I./ ./google/protobuf/any.proto --dart_out=grpc:./generated
700+
protoc -I./ ./google/protobuf/wrappers.proto --dart_out=grpc:./generated
659701
- name: Copy codelab2/starter
660702
copydir:
661703
from: codelab2/tfserving_flutter
@@ -673,13 +715,13 @@ steps:
673715
--- b/tfserving-flutter/codelab2/finished/analysis_options.yaml
674716
+++ a/tfserving-flutter/codelab2/finished/analysis_options.yaml
675717
@@ -2,9 +2,6 @@ include: ../../../analysis_options.yaml
676-
718+
677719
analyzer:
678720
exclude: [lib/proto/generated/**]
679721
- errors:
680722
- unused_import: ignore
681723
- unused_field: ignore
682-
724+
683725
linter:
684726
rules:
685727
- name: Copy codelab2/finished
@@ -696,7 +738,7 @@ steps:
696738
_server = '127.0.0.1';
697739
}
698740
- // TODO: build _vocabMap if empty
699-
741+
700742
- // TODO: tokenize the input sentence.
701743
+ if (_vocabMap.isEmpty) {
702744
+ final vocabFileString = await rootBundle.loadString(vocabFile);
@@ -728,7 +770,7 @@ steps:
728770
+ break;
729771
+ }
730772
+ }
731-
773+
732774
if (_connectionMode == ConnectionModeType.rest) {
733775
- // TODO: create and send the REST request
734776
+ final response = await http.post(
@@ -737,7 +779,7 @@ steps:
737779
+ 'instances': [_tokenIndices],
738780
+ }),
739781
+ );
740-
782+
741783
- // TODO: process the REST response
742784
+ if (response.statusCode == 200) {
743785
+ Map<String, dynamic> result =
@@ -780,10 +822,10 @@ steps:
780822
+ const outputTensorName = 'dense_5';
781823
+ PredictRequest request = PredictRequest(
782824
+ modelSpec: modelSpec, inputs: {inputTensorName: inputTensor});
783-
825+
784826
- // TODO: send the gRPC request
785827
+ PredictResponse response = await _stub.predict(request);
786-
828+
787829
- // TODO: process the gRPC response
788830
+ if (response.outputs.containsKey(outputTensorName)) {
789831
+ if (response.outputs[outputTensorName]!.floatVal[1] >

0 commit comments

Comments
 (0)