├── __init__.py ├── trainer └── __init__.py ├── distributed ├── checkpoint │ └── .gitkeeper └── README.md ├── android_client ├── app │ ├── .gitignore │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── values │ │ │ │ │ ├── strings.xml │ │ │ │ │ ├── colors.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ │ ├── ic_launcher.xml │ │ │ │ │ └── ic_launcher_round.xml │ │ │ │ └── layout │ │ │ │ │ └── activity_main.xml │ │ │ ├── assets │ │ │ │ └── tensorflow_template_application_model.pb │ │ │ ├── cpp │ │ │ │ └── native-lib.cpp │ │ │ └── AndroidManifest.xml │ │ ├── test │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── tobe │ │ │ │ └── androidclient │ │ │ │ └── ExampleUnitTest.java │ │ └── androidTest │ │ │ └── java │ │ │ └── com │ │ │ └── tobe │ │ │ └── androidclient │ │ │ └── ExampleInstrumentedTest.java │ ├── proguard-rules.pro │ └── build.gradle ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .gitignore ├── build.gradle └── gradle.properties ├── http_service ├── cancer_predict │ ├── __init__.py │ ├── migrations │ │ └── __init__.py │ ├── tests.py │ ├── admin.py │ ├── models.py │ ├── apps.py │ └── urls.py ├── restful_server │ ├── __init__.py │ ├── wsgi.py │ └── urls.py ├── db.sqlite3 ├── predict.sh ├── predict_examples.json ├── images │ ├── predict.png │ └── online_train.png ├── manage.py └── README.md ├── java_predict_client ├── src │ └── main │ │ ├── proto │ │ ├── tensorflow │ │ │ ├── go │ │ │ │ ├── op │ │ │ │ │ └── .gitignore │ │ │ │ └── genop │ │ │ │ │ └── .gitignore │ │ │ ├── tools │ │ │ │ ├── git │ │ │ │ │ └── .gitignore │ │ │ │ ├── swig │ │ │ │ │ └── .gitignore │ │ │ │ ├── tfprof │ │ │ │ │ ├── tfprof_log.proto │ │ │ │ │ ├── tfprof_options.proto │ │ │ │ │ └── tfprof_output.proto │ │ │ │ └── ci_build │ │ │ │ │ └── install │ │ │ │ │ └── .bazelrc │ │ │ ├── contrib │ │ │ │ ├── makefile │ │ │ │ │ └── .gitignore │ │ │ │ ├── ios_examples │ │ │ │ │ └── .gitignore │ │ │ │ ├── pi_examples │ │ │ │ │ └── .gitignore │ │ │ │ └── tensorboard │ │ │ │ │ └── plugins │ │ │ │ │ └── projector │ │ │ │ │ └── projector_config.proto │ │ │ ├── tensorboard │ │ │ │ ├── .bowerrc │ │ │ │ └── .gitignore │ │ │ ├── examples │ │ │ │ └── udacity │ │ │ │ │ └── .gitignore │ │ │ ├── python │ │ │ │ ├── framework │ │ │ │ │ └── cpp_shape_inference.proto │ │ │ │ ├── training │ │ │ │ │ └── checkpoint_state.proto │ │ │ │ └── util │ │ │ │ │ └── protobuf │ │ │ │ │ └── compare_test.proto │ │ │ └── core │ │ │ │ ├── kernels │ │ │ │ └── reader_base.proto │ │ │ │ ├── framework │ │ │ │ ├── tensor_description.proto │ │ │ │ ├── allocation_description.proto │ │ │ │ ├── resource_handle.proto │ │ │ │ ├── variable.proto │ │ │ │ ├── versions.proto │ │ │ │ ├── device_attributes.proto │ │ │ │ ├── kernel_def.proto │ │ │ │ ├── tensor_slice.proto │ │ │ │ ├── tensor_shape.proto │ │ │ │ └── step_stats.proto │ │ │ │ ├── protobuf │ │ │ │ ├── named_tensor.proto │ │ │ │ ├── saved_model.proto │ │ │ │ └── queue_runner.proto │ │ │ │ ├── util │ │ │ │ └── memmapped_file_system.proto │ │ │ │ ├── example │ │ │ │ └── example_parser_configuration.proto │ │ │ │ └── debug │ │ │ │ └── debug_service.proto │ │ ├── prediction_service.proto │ │ ├── model.proto │ │ └── predict.proto │ │ └── scala │ │ └── com │ │ └── tobe │ │ └── client │ │ └── ScalaDensePredictClient.scala ├── run └── update_tensorflow_proto_files.sh ├── cpp_predict_client ├── generate_proto_files │ ├── tensorflow │ │ ├── go │ │ │ ├── op │ │ │ │ └── .gitignore │ │ │ └── genop │ │ │ │ └── .gitignore │ │ ├── tools │ │ │ ├── git │ │ │ │ └── .gitignore │ │ │ ├── swig │ │ │ │ └── .gitignore │ │ │ ├── tfprof │ │ │ │ ├── tfprof_log.proto │ │ │ │ ├── tfprof_options.proto │ │ │ │ └── tfprof_output.proto │ │ │ └── ci_build │ │ │ │ └── install │ │ │ │ └── .bazelrc │ │ ├── contrib │ │ │ ├── makefile │ │ │ │ └── .gitignore │ │ │ ├── ios_examples │ │ │ │ └── .gitignore │ │ │ ├── pi_examples │ │ │ │ └── .gitignore │ │ │ └── tensorboard │ │ │ │ └── plugins │ │ │ │ └── projector │ │ │ │ └── projector_config.proto │ │ ├── tensorboard │ │ │ ├── .bowerrc │ │ │ └── .gitignore │ │ ├── examples │ │ │ └── udacity │ │ │ │ └── .gitignore │ │ ├── python │ │ │ ├── framework │ │ │ │ └── cpp_shape_inference.proto │ │ │ ├── training │ │ │ │ └── checkpoint_state.proto │ │ │ └── util │ │ │ │ └── protobuf │ │ │ │ └── compare_test.proto │ │ └── core │ │ │ ├── kernels │ │ │ └── reader_base.proto │ │ │ ├── framework │ │ │ ├── tensor_description.proto │ │ │ ├── allocation_description.proto │ │ │ ├── resource_handle.proto │ │ │ ├── variable.proto │ │ │ ├── versions.proto │ │ │ ├── device_attributes.proto │ │ │ ├── kernel_def.proto │ │ │ ├── tensor_slice.proto │ │ │ ├── tensor_shape.proto │ │ │ └── step_stats.proto │ │ │ ├── protobuf │ │ │ ├── named_tensor.proto │ │ │ ├── saved_model.proto │ │ │ └── queue_runner.proto │ │ │ ├── util │ │ │ └── memmapped_file_system.proto │ │ │ ├── example │ │ │ └── example_parser_configuration.proto │ │ │ └── debug │ │ │ └── debug_service.proto │ ├── generate_proto_files.sh │ ├── prediction_service.proto │ ├── model.proto │ └── predict.proto └── README.md ├── python_predict_client ├── generate_python_files │ ├── tensorflow │ │ ├── tools │ │ │ ├── git │ │ │ │ └── .gitignore │ │ │ ├── swig │ │ │ │ └── .gitignore │ │ │ ├── tfprof │ │ │ │ ├── tfprof_log.proto │ │ │ │ ├── tfprof_options.proto │ │ │ │ └── tfprof_output.proto │ │ │ └── ci_build │ │ │ │ └── install │ │ │ │ └── .bazelrc │ │ ├── go │ │ │ ├── op │ │ │ │ └── .gitignore │ │ │ └── genop │ │ │ │ └── .gitignore │ │ ├── contrib │ │ │ ├── makefile │ │ │ │ └── .gitignore │ │ │ ├── ios_examples │ │ │ │ └── .gitignore │ │ │ └── pi_examples │ │ │ │ └── .gitignore │ │ ├── tensorboard │ │ │ ├── .bowerrc │ │ │ └── .gitignore │ │ ├── examples │ │ │ └── udacity │ │ │ │ └── .gitignore │ │ ├── python │ │ │ ├── framework │ │ │ │ └── cpp_shape_inference.proto │ │ │ ├── training │ │ │ │ └── checkpoint_state.proto │ │ │ └── util │ │ │ │ └── protobuf │ │ │ │ └── compare_test.proto │ │ └── core │ │ │ ├── kernels │ │ │ └── reader_base.proto │ │ │ ├── framework │ │ │ ├── tensor_description.proto │ │ │ ├── allocation_description.proto │ │ │ ├── resource_handle.proto │ │ │ ├── variable.proto │ │ │ ├── versions.proto │ │ │ ├── device_attributes.proto │ │ │ ├── kernel_def.proto │ │ │ ├── tensor_slice.proto │ │ │ ├── tensor_shape.proto │ │ │ └── step_stats.proto │ │ │ ├── protobuf │ │ │ ├── named_tensor.proto │ │ │ ├── saved_model.proto │ │ │ └── queue_runner.proto │ │ │ ├── util │ │ │ └── memmapped_file_system.proto │ │ │ ├── example │ │ │ └── example_parser_configuration.proto │ │ │ └── debug │ │ │ └── debug_service.proto │ ├── generate_proto_files.sh │ ├── prediction_service.proto │ ├── model.proto │ └── predict.proto ├── requirements.txt └── README.md ├── golang_predict_client ├── src │ ├── generate_golang_files │ │ ├── tensorflow │ │ │ ├── tools │ │ │ │ ├── git │ │ │ │ │ └── .gitignore │ │ │ │ ├── swig │ │ │ │ │ └── .gitignore │ │ │ │ ├── tfprof │ │ │ │ │ ├── tfprof_log.proto │ │ │ │ │ ├── tfprof_options.proto │ │ │ │ │ └── tfprof_output.proto │ │ │ │ └── ci_build │ │ │ │ │ └── install │ │ │ │ │ └── .bazelrc │ │ │ ├── go │ │ │ │ ├── op │ │ │ │ │ └── .gitignore │ │ │ │ └── genop │ │ │ │ │ └── .gitignore │ │ │ ├── contrib │ │ │ │ ├── makefile │ │ │ │ │ └── .gitignore │ │ │ │ ├── ios_examples │ │ │ │ │ └── .gitignore │ │ │ │ └── pi_examples │ │ │ │ │ └── .gitignore │ │ │ ├── tensorboard │ │ │ │ ├── .bowerrc │ │ │ │ └── .gitignore │ │ │ ├── examples │ │ │ │ └── udacity │ │ │ │ │ └── .gitignore │ │ │ ├── python │ │ │ │ ├── framework │ │ │ │ │ └── cpp_shape_inference.proto │ │ │ │ ├── training │ │ │ │ │ └── checkpoint_state.proto │ │ │ │ └── util │ │ │ │ │ └── protobuf │ │ │ │ │ └── compare_test.proto │ │ │ └── core │ │ │ │ ├── kernels │ │ │ │ └── reader_base.proto │ │ │ │ ├── framework │ │ │ │ ├── tensor_description.proto │ │ │ │ ├── allocation_description.proto │ │ │ │ ├── resource_handle.proto │ │ │ │ ├── variable.proto │ │ │ │ ├── versions.proto │ │ │ │ ├── device_attributes.proto │ │ │ │ ├── kernel_def.proto │ │ │ │ ├── tensor_slice.proto │ │ │ │ ├── tensor_shape.proto │ │ │ │ └── step_stats.proto │ │ │ │ ├── protobuf │ │ │ │ ├── saved_model.proto │ │ │ │ ├── named_tensor.proto │ │ │ │ └── queue_runner.proto │ │ │ │ ├── util │ │ │ │ └── memmapped_file_system.proto │ │ │ │ ├── example │ │ │ │ └── example_parser_configuration.proto │ │ │ │ └── debug │ │ │ │ └── debug_service.proto │ │ ├── prediction_service.proto │ │ ├── model.proto │ │ └── predict.proto │ └── generate_proto_files.sh └── README.md ├── requirements.txt ├── architecture.jpeg ├── setup.py ├── data ├── cancer_test.csv ├── boston_housing │ ├── README.md │ ├── train.csv.tfrecords │ ├── print_csv_tfrecords.py │ └── generate_csv_tfrecords.py ├── a8a │ ├── a8a_test.libsvm.tfrecords │ ├── a8a_train.libsvm.tfrecords │ ├── print_libsvm_tfrecords.py │ ├── generate_libsvm_tfrecord.py │ ├── print_tfrecords_files.py │ └── generate_tfrecords_from_libsvm.py ├── iris │ ├── iris_test.csv.tfrecords │ ├── iris_train.csv.tfrecords │ ├── iris_test.csv │ ├── print_csv_tfrecords.py │ ├── generate_csv_tfrecords.py │ └── download_iris.py ├── cancer │ ├── cancer_test.csv.tfrecords │ ├── cancer_train.csv.tfrecords │ ├── generate_tfrecords_from_csv.py │ └── print_tfrecords_files.py ├── a8a_test.libsvm ├── lung │ ├── fa7a21165ae152b13def786e6afc3edf.dcm │ ├── fa7a21165ae152b13def786e6afc3edf.dcm.csv.tfrecords │ ├── print_csv_tfrecords.py │ ├── generate_csv_tfrecords.py │ └── convert_dcm_to_csv.py └── README.md ├── minimal_model ├── model │ └── 00000001 │ │ ├── checkpoint │ │ ├── export.index │ │ ├── export.meta │ │ └── export.data-00000-of-00001 ├── data.json ├── README.md └── python_predict_client │ └── predict_client.py ├── model └── 1 │ ├── saved_model.pb │ └── variables │ ├── variables.index │ └── variables.data-00000-of-00001 ├── ios_client ├── Podfile ├── README.md ├── data │ └── tensorflow_template_application_model.pb ├── tf_simple_example.xcodeproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── tobe.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── tobe.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist ├── tf_simple_example.xcworkspace │ ├── xcuserdata │ │ └── tobe.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── contents.xcworkspacedata ├── AppDelegate.h ├── main.mm ├── RunModelViewController.h ├── ios_image_load.h ├── AppDelegate.mm └── RunModel-Info.plist ├── tensorboard_tools └── read_event_files.py ├── cpp_predict_server └── README.md └── .gitignore /__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /trainer/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /distributed/checkpoint/.gitkeeper: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /android_client/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /http_service/cancer_predict/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /http_service/restful_server/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /android_client/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /http_service/cancer_predict/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/go/op/.gitignore: -------------------------------------------------------------------------------- 1 | wrappers.go 2 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/tools/git/.gitignore: -------------------------------------------------------------------------------- 1 | gen 2 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/go/op/.gitignore: -------------------------------------------------------------------------------- 1 | wrappers.go 2 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/tools/git/.gitignore: -------------------------------------------------------------------------------- 1 | gen 2 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/tools/swig/.gitignore: -------------------------------------------------------------------------------- 1 | swig_path 2 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/tools/git/.gitignore: -------------------------------------------------------------------------------- 1 | gen 2 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/tools/swig/.gitignore: -------------------------------------------------------------------------------- 1 | swig_path 2 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/tools/git/.gitignore: -------------------------------------------------------------------------------- 1 | gen 2 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/go/op/.gitignore: -------------------------------------------------------------------------------- 1 | wrappers.go 2 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/go/op/.gitignore: -------------------------------------------------------------------------------- 1 | wrappers.go 2 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/tools/swig/.gitignore: -------------------------------------------------------------------------------- 1 | swig_path 2 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/tools/swig/.gitignore: -------------------------------------------------------------------------------- 1 | swig_path 2 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/contrib/makefile/.gitignore: -------------------------------------------------------------------------------- 1 | gen/ 2 | downloads/ 3 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | tensorflow>=1.0.0 2 | scipy 3 | scikit-learn>=0.17.1 4 | coloredlogs>=5.2 5 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/contrib/makefile/.gitignore: -------------------------------------------------------------------------------- 1 | gen/ 2 | downloads/ 3 | -------------------------------------------------------------------------------- /http_service/cancer_predict/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/tensorboard/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory" : "components" 3 | } -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/contrib/makefile/.gitignore: -------------------------------------------------------------------------------- 1 | gen/ 2 | downloads/ 3 | -------------------------------------------------------------------------------- /python_predict_client/requirements.txt: -------------------------------------------------------------------------------- 1 | grpcio>=0.15.0 2 | grpcio-tools>=0.15.0 3 | tensorflow-serving-api -------------------------------------------------------------------------------- /architecture.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/architecture.jpeg -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/tensorboard/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory" : "components" 3 | } -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/contrib/makefile/.gitignore: -------------------------------------------------------------------------------- 1 | gen/ 2 | downloads/ 3 | -------------------------------------------------------------------------------- /http_service/cancer_predict/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/examples/udacity/.gitignore: -------------------------------------------------------------------------------- 1 | notMNIST_large* 2 | notMNIST_small* 3 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | setuptools.setup(name='trainer', version='1.0', packages=['trainer']) 4 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/examples/udacity/.gitignore: -------------------------------------------------------------------------------- 1 | notMNIST_large* 2 | notMNIST_small* 3 | -------------------------------------------------------------------------------- /data/cancer_test.csv: -------------------------------------------------------------------------------- 1 | 1,2,3,4,5,6,7,8,9,1 2 | 1,1,1,1,1,1,1,1,1,1 3 | 9,8,7,6,5,4,3,2,1,1 4 | 9,9,9,9,9,9,9,9,9,1 5 | -------------------------------------------------------------------------------- /minimal_model/model/00000001/checkpoint: -------------------------------------------------------------------------------- 1 | model_checkpoint_path: "export" 2 | all_model_checkpoint_paths: "export" 3 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/tensorboard/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory" : "components" 3 | } -------------------------------------------------------------------------------- /data/boston_housing/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Data 3 | 4 | The files are from https://inclass.kaggle.com/c/boston-housing . 5 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/tensorboard/.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory" : "components" 3 | } -------------------------------------------------------------------------------- /minimal_model/data.json: -------------------------------------------------------------------------------- 1 | { 2 | "features_dtype": "float32", 3 | "features": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 4 | } 5 | -------------------------------------------------------------------------------- /model/1/saved_model.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/model/1/saved_model.pb -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/examples/udacity/.gitignore: -------------------------------------------------------------------------------- 1 | notMNIST_large* 2 | notMNIST_small* 3 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/examples/udacity/.gitignore: -------------------------------------------------------------------------------- 1 | notMNIST_large* 2 | notMNIST_small* 3 | -------------------------------------------------------------------------------- /http_service/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/http_service/db.sqlite3 -------------------------------------------------------------------------------- /http_service/predict.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | bat post http://127.0.0.1:8000/cancer_predict/predict/ < predict_examples.json 4 | -------------------------------------------------------------------------------- /http_service/predict_examples.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": [1.0, 2.0], 3 | "features": [[10,10,10,8,6,1,8,9,1], [6,2,1,1,1,1,7,1,1]] 4 | } 5 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/go/genop/.gitignore: -------------------------------------------------------------------------------- 1 | # .pb.go files generated by generate.sh 2 | internal/proto/* 3 | -------------------------------------------------------------------------------- /android_client/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AndroidClient 3 | 4 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/go/genop/.gitignore: -------------------------------------------------------------------------------- 1 | # .pb.go files generated by generate.sh 2 | internal/proto/* 3 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/go/genop/.gitignore: -------------------------------------------------------------------------------- 1 | # .pb.go files generated by generate.sh 2 | internal/proto/* 3 | -------------------------------------------------------------------------------- /http_service/images/predict.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/http_service/images/predict.png -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/go/genop/.gitignore: -------------------------------------------------------------------------------- 1 | # .pb.go files generated by generate.sh 2 | internal/proto/* 3 | -------------------------------------------------------------------------------- /data/a8a/a8a_test.libsvm.tfrecords: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/data/a8a/a8a_test.libsvm.tfrecords -------------------------------------------------------------------------------- /data/iris/iris_test.csv.tfrecords: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/data/iris/iris_test.csv.tfrecords -------------------------------------------------------------------------------- /data/iris/iris_train.csv.tfrecords: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/data/iris/iris_train.csv.tfrecords -------------------------------------------------------------------------------- /ios_client/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '8.0' 2 | inhibit_all_warnings! 3 | 4 | target 'tf_simple_example' 5 | pod 'TensorFlow-experimental' 6 | -------------------------------------------------------------------------------- /model/1/variables/variables.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/model/1/variables/variables.index -------------------------------------------------------------------------------- /data/a8a/a8a_train.libsvm.tfrecords: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/data/a8a/a8a_train.libsvm.tfrecords -------------------------------------------------------------------------------- /data/cancer/cancer_test.csv.tfrecords: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/data/cancer/cancer_test.csv.tfrecords -------------------------------------------------------------------------------- /http_service/images/online_train.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/http_service/images/online_train.png -------------------------------------------------------------------------------- /data/boston_housing/train.csv.tfrecords: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/data/boston_housing/train.csv.tfrecords -------------------------------------------------------------------------------- /data/cancer/cancer_train.csv.tfrecords: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/data/cancer/cancer_train.csv.tfrecords -------------------------------------------------------------------------------- /http_service/cancer_predict/models.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | from django.db import models 4 | 5 | # Create your models here. 6 | -------------------------------------------------------------------------------- /minimal_model/model/00000001/export.index: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/minimal_model/model/00000001/export.index -------------------------------------------------------------------------------- /minimal_model/model/00000001/export.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/minimal_model/model/00000001/export.meta -------------------------------------------------------------------------------- /data/a8a_test.libsvm: -------------------------------------------------------------------------------- 1 | 0 5:1 6:1 17:1 21:1 35:1 40:1 53:1 63:1 71:1 73:1 74:1 76:1 80:1 83:1 2 | 1 5:1 7:1 17:1 22:1 36:1 40:1 51:1 63:1 67:1 73:1 74:1 76:1 81:1 83:1 3 | -------------------------------------------------------------------------------- /ios_client/README.md: -------------------------------------------------------------------------------- 1 | # iOS Client 2 | 3 | ## Usage 4 | 5 | ``` 6 | pod install 7 | ``` 8 | 9 | ``` 10 | open tf_simple_example.xcworkspace 11 | ``` 12 | -------------------------------------------------------------------------------- /data/lung/fa7a21165ae152b13def786e6afc3edf.dcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/data/lung/fa7a21165ae152b13def786e6afc3edf.dcm -------------------------------------------------------------------------------- /model/1/variables/variables.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/model/1/variables/variables.data-00000-of-00001 -------------------------------------------------------------------------------- /android_client/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/android_client/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android_client/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /ios_client/data/tensorflow_template_application_model.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/ios_client/data/tensorflow_template_application_model.pb -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/contrib/ios_examples/.gitignore: -------------------------------------------------------------------------------- 1 | project.xcworkspace 2 | xcuserdata 3 | imagenet_comp_graph_label_strings.txt 4 | tensorflow_inception_graph.pb 5 | -------------------------------------------------------------------------------- /minimal_model/model/00000001/export.data-00000-of-00001: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/minimal_model/model/00000001/export.data-00000-of-00001 -------------------------------------------------------------------------------- /android_client/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/android_client/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android_client/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/android_client/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/contrib/ios_examples/.gitignore: -------------------------------------------------------------------------------- 1 | project.xcworkspace 2 | xcuserdata 3 | imagenet_comp_graph_label_strings.txt 4 | tensorflow_inception_graph.pb 5 | -------------------------------------------------------------------------------- /android_client/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/android_client/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android_client/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/android_client/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android_client/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/android_client/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /data/lung/fa7a21165ae152b13def786e6afc3edf.dcm.csv.tfrecords: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/data/lung/fa7a21165ae152b13def786e6afc3edf.dcm.csv.tfrecords -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/contrib/pi_examples/.gitignore: -------------------------------------------------------------------------------- 1 | tensorflow_inception_graph.pb 2 | imagenet_comp_graph_label_strings.txt 3 | tensorflow_inception_stripped.pb 4 | */gen/ 5 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/generate_proto_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | python -m grpc.tools.protoc -I./ --python_out=.. --grpc_python_out=.. ./*.proto 7 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/contrib/ios_examples/.gitignore: -------------------------------------------------------------------------------- 1 | project.xcworkspace 2 | xcuserdata 3 | imagenet_comp_graph_label_strings.txt 4 | tensorflow_inception_graph.pb 5 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/contrib/pi_examples/.gitignore: -------------------------------------------------------------------------------- 1 | tensorflow_inception_graph.pb 2 | imagenet_comp_graph_label_strings.txt 3 | tensorflow_inception_stripped.pb 4 | */gen/ 5 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/contrib/ios_examples/.gitignore: -------------------------------------------------------------------------------- 1 | project.xcworkspace 2 | xcuserdata 3 | imagenet_comp_graph_label_strings.txt 4 | tensorflow_inception_graph.pb 5 | -------------------------------------------------------------------------------- /http_service/cancer_predict/apps.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | from django.apps import AppConfig 4 | 5 | 6 | class CancerPredictConfig(AppConfig): 7 | name = 'cancer_predict' 8 | -------------------------------------------------------------------------------- /android_client/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/android_client/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android_client/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/android_client/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android_client/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/android_client/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android_client/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/android_client/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/contrib/pi_examples/.gitignore: -------------------------------------------------------------------------------- 1 | tensorflow_inception_graph.pb 2 | imagenet_comp_graph_label_strings.txt 3 | tensorflow_inception_stripped.pb 4 | */gen/ 5 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/contrib/pi_examples/.gitignore: -------------------------------------------------------------------------------- 1 | tensorflow_inception_graph.pb 2 | imagenet_comp_graph_label_strings.txt 3 | tensorflow_inception_stripped.pb 4 | */gen/ 5 | -------------------------------------------------------------------------------- /android_client/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/android_client/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android_client/app/src/main/assets/tensorflow_template_application_model.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/android_client/app/src/main/assets/tensorflow_template_application_model.pb -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/generate_proto_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | protoc -I ./ --cpp_out=.. **/*.proto 7 | protoc -I ./ --grpc_out=.. --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` **/*.proto 8 | -------------------------------------------------------------------------------- /http_service/cancer_predict/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | from . import views 3 | 4 | urlpatterns = [ 5 | url(r'^predict/', views.predict, 6 | name='predict'), 7 | url(r'^$', views.index, name='index'), 8 | ] 9 | -------------------------------------------------------------------------------- /ios_client/tf_simple_example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios_client/tf_simple_example.xcworkspace/xcuserdata/tobe.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/ios_client/tf_simple_example.xcworkspace/xcuserdata/tobe.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /android_client/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /android_client/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Feb 02 10:37:24 CST 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /ios_client/tf_simple_example.xcodeproj/project.xcworkspace/xcuserdata/tobe.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tobegit3hub/tensorflow_template_application/HEAD/ios_client/tf_simple_example.xcodeproj/project.xcworkspace/xcuserdata/tobe.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /java_predict_client/run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | mvn clean install -DskipTests 7 | 8 | mvn exec:java -Dexec.mainClass="com.tobe.PredictClient" -Dexec.args="127.0.0.1 9000 cancer 1" 9 | 10 | mvn compile exec:java -Dexec.mainClass="com.tobe.SparsePredictClient" -Dexec.args="127.0.0.1 9000 sparse 1" 11 | -------------------------------------------------------------------------------- /android_client/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ios_client/tf_simple_example.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /android_client/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /http_service/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", 7 | "restful_server.settings") 8 | 9 | from django.core.management import execute_from_command_line 10 | 11 | execute_from_command_line(sys.argv) 12 | -------------------------------------------------------------------------------- /data/iris/iris_test.csv: -------------------------------------------------------------------------------- 1 | 2,7.2,3.6,6.1,2.5 2 | 2,6.7,3.3,5.7,2.5 3 | 0,5.0,3.0,1.6,0.2 4 | 2,5.7,2.5,5.0,2.0 5 | 0,4.4,2.9,1.4,0.2 6 | 0,5.0,3.5,1.6,0.6 7 | 1,5.1,2.5,3.0,1.1 8 | 1,5.8,2.7,3.9,1.2 9 | 1,5.6,3.0,4.5,1.5 10 | 2,7.6,3.0,6.6,2.1 11 | 2,6.5,3.0,5.8,2.2 12 | 1,5.7,2.6,3.5,1.0 13 | 1,6.1,2.8,4.0,1.3 14 | 0,5.0,3.3,1.4,0.2 15 | 2,5.8,2.7,5.1,1.9 16 | -------------------------------------------------------------------------------- /android_client/app/src/main/cpp/native-lib.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" 5 | JNIEXPORT jstring 6 | 7 | JNICALL 8 | Java_com_tobe_androidclient_MainActivity_stringFromJNI( 9 | JNIEnv *env, 10 | jobject /* this */) { 11 | 12 | 13 | std::string hello = "Hello from C++"; 14 | return env->NewStringUTF(hello.c_str()); 15 | 16 | 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_proto_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | # install gRPC and protoc plugin for Go, see http://www.grpc.io/docs/quickstart/go.html#generate-grpc-code 5 | mkdir tensorflow tensorflow_serving 6 | protoc -I generate_golang_files/ generate_golang_files/*.proto --go_out=plugins=grpc:tensorflow_serving 7 | protoc -I generate_golang_files/ generate_golang_files/tensorflow/core/framework/* --go_out=plugins=grpc:. -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/python/framework/cpp_shape_inference.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | 6 | import "tensorflow/core/framework/types.proto"; 7 | import "tensorflow/core/framework/tensor_shape.proto"; 8 | 9 | message CppShapeInferenceResult { 10 | TensorShapeProto shape = 1; 11 | TensorShapeProto handle_shape = 2; 12 | DataType handle_dtype = 3; 13 | } -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/python/framework/cpp_shape_inference.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | 6 | import "tensorflow/core/framework/types.proto"; 7 | import "tensorflow/core/framework/tensor_shape.proto"; 8 | 9 | message CppShapeInferenceResult { 10 | TensorShapeProto shape = 1; 11 | TensorShapeProto handle_shape = 2; 12 | DataType handle_dtype = 3; 13 | } -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/python/framework/cpp_shape_inference.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | 6 | import "tensorflow/core/framework/types.proto"; 7 | import "tensorflow/core/framework/tensor_shape.proto"; 8 | 9 | message CppShapeInferenceResult { 10 | TensorShapeProto shape = 1; 11 | TensorShapeProto handle_shape = 2; 12 | DataType handle_dtype = 3; 13 | } -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/python/framework/cpp_shape_inference.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | 6 | import "tensorflow/core/framework/types.proto"; 7 | import "tensorflow/core/framework/tensor_shape.proto"; 8 | 9 | message CppShapeInferenceResult { 10 | TensorShapeProto shape = 1; 11 | TensorShapeProto handle_shape = 2; 12 | DataType handle_dtype = 3; 13 | } -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/prediction_service.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow.serving; 4 | option cc_enable_arenas = true; 5 | 6 | import "predict.proto"; 7 | 8 | // PredictionService provides access to machine-learned models loaded by 9 | // model_servers. 10 | service PredictionService { 11 | // Predict -- provides access to loaded TensorFlow model. 12 | rpc Predict(PredictRequest) returns (PredictResponse); 13 | } 14 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/prediction_service.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow.serving; 4 | option cc_enable_arenas = true; 5 | 6 | import "predict.proto"; 7 | 8 | // PredictionService provides access to machine-learned models loaded by 9 | // model_servers. 10 | service PredictionService { 11 | // Predict -- provides access to loaded TensorFlow model. 12 | rpc Predict(PredictRequest) returns (PredictResponse); 13 | } 14 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/prediction_service.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow.serving; 4 | option cc_enable_arenas = true; 5 | 6 | import "predict.proto"; 7 | 8 | // PredictionService provides access to machine-learned models loaded by 9 | // model_servers. 10 | service PredictionService { 11 | // Predict -- provides access to loaded TensorFlow model. 12 | rpc Predict(PredictRequest) returns (PredictResponse); 13 | } 14 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/prediction_service.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow.serving; 4 | option cc_enable_arenas = true; 5 | 6 | import "predict.proto"; 7 | 8 | // PredictionService provides access to machine-learned models loaded by 9 | // model_servers. 10 | service PredictionService { 11 | // Predict -- provides access to loaded TensorFlow model. 12 | rpc Predict(PredictRequest) returns (PredictResponse); 13 | } 14 | -------------------------------------------------------------------------------- /android_client/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ios_client/tf_simple_example.xcodeproj/xcuserdata/tobe.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | tf_simple_example.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /http_service/restful_server/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for restful_server project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", 15 | "restful_server.settings") 16 | 17 | application = get_wsgi_application() 18 | -------------------------------------------------------------------------------- /android_client/app/src/test/java/com/tobe/androidclient/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.tobe.androidclient; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/kernels/reader_base.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "ReaderBaseProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.kernels"; 8 | 9 | // For serializing and restoring the state of ReaderBase, see 10 | // reader_base.h for details. 11 | message ReaderBaseState { 12 | int64 work_started = 1; 13 | int64 work_finished = 2; 14 | int64 num_records_produced = 3; 15 | bytes current_work = 4; 16 | }; 17 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/kernels/reader_base.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "ReaderBaseProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.kernels"; 8 | 9 | // For serializing and restoring the state of ReaderBase, see 10 | // reader_base.h for details. 11 | message ReaderBaseState { 12 | int64 work_started = 1; 13 | int64 work_finished = 2; 14 | int64 num_records_produced = 3; 15 | bytes current_work = 4; 16 | }; 17 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/kernels/reader_base.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "ReaderBaseProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.kernels"; 8 | 9 | // For serializing and restoring the state of ReaderBase, see 10 | // reader_base.h for details. 11 | message ReaderBaseState { 12 | int64 work_started = 1; 13 | int64 work_finished = 2; 14 | int64 num_records_produced = 3; 15 | bytes current_work = 4; 16 | }; 17 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/kernels/reader_base.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "ReaderBaseProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.kernels"; 8 | 9 | // For serializing and restoring the state of ReaderBase, see 10 | // reader_base.h for details. 11 | message ReaderBaseState { 12 | int64 work_started = 1; 13 | int64 work_finished = 2; 14 | int64 num_records_produced = 3; 15 | bytes current_work = 4; 16 | }; 17 | -------------------------------------------------------------------------------- /java_predict_client/update_tensorflow_proto_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | set -e 5 | 6 | # Clone TensorFlow project in proto directory 7 | 8 | ls ./tensorflow/**/*[a-n] | xargs rm 9 | ls ./tensorflow/**/*[p-z] | xargs rm 10 | ls ./tensorflow/**/*[A-Z] | xargs rm 11 | ls ./tensorflow/**/*[0-9] | xargs rm 12 | ls ./tensorflow/**/*.go | xargs rm 13 | 14 | find . -type d -empty -print | xargs rmdir 15 | find . -type d -empty -print | xargs rmdir 16 | find . -type d -empty -print | xargs rmdir 17 | find . -type d -empty -print | xargs rmdir 18 | find . -type d -empty -print | xargs rmdir 19 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/python/training/checkpoint_state.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | 6 | // Protocol buffer representing the checkpoint state. 7 | // 8 | // TODO(touts): Add other attributes as needed. 9 | message CheckpointState { 10 | // Path to the most-recent model checkpoint. 11 | string model_checkpoint_path = 1; 12 | 13 | // Paths to all not-yet-deleted model checkpoints, sorted from oldest to 14 | // newest. 15 | // Note that the value of model_checkpoint_path should be the last item in 16 | // this list. 17 | repeated string all_model_checkpoint_paths = 2; 18 | } 19 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/python/training/checkpoint_state.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | 6 | // Protocol buffer representing the checkpoint state. 7 | // 8 | // TODO(touts): Add other attributes as needed. 9 | message CheckpointState { 10 | // Path to the most-recent model checkpoint. 11 | string model_checkpoint_path = 1; 12 | 13 | // Paths to all not-yet-deleted model checkpoints, sorted from oldest to 14 | // newest. 15 | // Note that the value of model_checkpoint_path should be the last item in 16 | // this list. 17 | repeated string all_model_checkpoint_paths = 2; 18 | } 19 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/python/training/checkpoint_state.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | 6 | // Protocol buffer representing the checkpoint state. 7 | // 8 | // TODO(touts): Add other attributes as needed. 9 | message CheckpointState { 10 | // Path to the most-recent model checkpoint. 11 | string model_checkpoint_path = 1; 12 | 13 | // Paths to all not-yet-deleted model checkpoints, sorted from oldest to 14 | // newest. 15 | // Note that the value of model_checkpoint_path should be the last item in 16 | // this list. 17 | repeated string all_model_checkpoint_paths = 2; 18 | } 19 | -------------------------------------------------------------------------------- /android_client/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.0.1' 11 | 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | jcenter() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/python/training/checkpoint_state.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | 6 | // Protocol buffer representing the checkpoint state. 7 | // 8 | // TODO(touts): Add other attributes as needed. 9 | message CheckpointState { 10 | // Path to the most-recent model checkpoint. 11 | string model_checkpoint_path = 1; 12 | 13 | // Paths to all not-yet-deleted model checkpoints, sorted from oldest to 14 | // newest. 15 | // Note that the value of model_checkpoint_path should be the last item in 16 | // this list. 17 | repeated string all_model_checkpoint_paths = 2; 18 | } 19 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/tools/tfprof/tfprof_log.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package tensorflow.tfprof; 4 | 5 | message OpLogEntry { 6 | // op name. 7 | optional string name = 1; 8 | // float_ops is filled by tfprof Python API when called. It requires the 9 | // op has RegisterStatistics defined. Currently, Conv2D, MatMul, etc, are 10 | // implemented. 11 | optional int64 float_ops = 2; 12 | // User can define extra op type information for an op. This allows the user 13 | // to select a group of ops precisely using op_type as a key. 14 | repeated string types = 3; 15 | } 16 | 17 | message OpLog { 18 | repeated OpLogEntry log_entries = 1; 19 | } -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/tools/tfprof/tfprof_log.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package tensorflow.tfprof; 4 | 5 | message OpLogEntry { 6 | // op name. 7 | optional string name = 1; 8 | // float_ops is filled by tfprof Python API when called. It requires the 9 | // op has RegisterStatistics defined. Currently, Conv2D, MatMul, etc, are 10 | // implemented. 11 | optional int64 float_ops = 2; 12 | // User can define extra op type information for an op. This allows the user 13 | // to select a group of ops precisely using op_type as a key. 14 | repeated string types = 3; 15 | } 16 | 17 | message OpLog { 18 | repeated OpLogEntry log_entries = 1; 19 | } -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/tools/tfprof/tfprof_log.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package tensorflow.tfprof; 4 | 5 | message OpLogEntry { 6 | // op name. 7 | optional string name = 1; 8 | // float_ops is filled by tfprof Python API when called. It requires the 9 | // op has RegisterStatistics defined. Currently, Conv2D, MatMul, etc, are 10 | // implemented. 11 | optional int64 float_ops = 2; 12 | // User can define extra op type information for an op. This allows the user 13 | // to select a group of ops precisely using op_type as a key. 14 | repeated string types = 3; 15 | } 16 | 17 | message OpLog { 18 | repeated OpLogEntry log_entries = 1; 19 | } -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/tools/tfprof/tfprof_log.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package tensorflow.tfprof; 4 | 5 | message OpLogEntry { 6 | // op name. 7 | optional string name = 1; 8 | // float_ops is filled by tfprof Python API when called. It requires the 9 | // op has RegisterStatistics defined. Currently, Conv2D, MatMul, etc, are 10 | // implemented. 11 | optional int64 float_ops = 2; 12 | // User can define extra op type information for an op. This allows the user 13 | // to select a group of ops precisely using op_type as a key. 14 | repeated string types = 3; 15 | } 16 | 17 | message OpLog { 18 | repeated OpLogEntry log_entries = 1; 19 | } -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/tools/ci_build/install/.bazelrc: -------------------------------------------------------------------------------- 1 | # Running bazel inside a `docker build` command causes trouble, cf: 2 | # https://github.com/bazelbuild/bazel/issues/134 3 | # The easiest solution is to set up a bazelrc file forcing --batch. 4 | startup --batch 5 | 6 | # Similarly, we need to workaround sandboxing issues: 7 | # https://github.com/bazelbuild/bazel/issues/418 8 | build --verbose_failures --spawn_strategy=standalone --genrule_strategy=standalone 9 | test --spawn_strategy=standalone 10 | 11 | # Force bazel output to use colors (good for jenkins) and print useful errors. 12 | common --color=yes 13 | 14 | # Configure tests - increase timeout, print errors and timeout warnings 15 | test --verbose_failures --test_output=errors --test_verbose_timeout_warnings 16 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/tools/ci_build/install/.bazelrc: -------------------------------------------------------------------------------- 1 | # Running bazel inside a `docker build` command causes trouble, cf: 2 | # https://github.com/bazelbuild/bazel/issues/134 3 | # The easiest solution is to set up a bazelrc file forcing --batch. 4 | startup --batch 5 | 6 | # Similarly, we need to workaround sandboxing issues: 7 | # https://github.com/bazelbuild/bazel/issues/418 8 | build --verbose_failures --spawn_strategy=standalone --genrule_strategy=standalone 9 | test --spawn_strategy=standalone 10 | 11 | # Force bazel output to use colors (good for jenkins) and print useful errors. 12 | common --color=yes 13 | 14 | # Configure tests - increase timeout, print errors and timeout warnings 15 | test --verbose_failures --test_output=errors --test_verbose_timeout_warnings 16 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/tools/ci_build/install/.bazelrc: -------------------------------------------------------------------------------- 1 | # Running bazel inside a `docker build` command causes trouble, cf: 2 | # https://github.com/bazelbuild/bazel/issues/134 3 | # The easiest solution is to set up a bazelrc file forcing --batch. 4 | startup --batch 5 | 6 | # Similarly, we need to workaround sandboxing issues: 7 | # https://github.com/bazelbuild/bazel/issues/418 8 | build --verbose_failures --spawn_strategy=standalone --genrule_strategy=standalone 9 | test --spawn_strategy=standalone 10 | 11 | # Force bazel output to use colors (good for jenkins) and print useful errors. 12 | common --color=yes 13 | 14 | # Configure tests - increase timeout, print errors and timeout warnings 15 | test --verbose_failures --test_output=errors --test_verbose_timeout_warnings 16 | -------------------------------------------------------------------------------- /golang_predict_client/README.md: -------------------------------------------------------------------------------- 1 | # Golang Predict Client 2 | 3 | ## Introduction 4 | 5 | It is the predict client in golang for TensorFlow Serving. 6 | 7 | You can compile the project easily and change the inference data for your TensorFlow models. 8 | 9 | ## Usage 10 | 11 | Install `protoc` and requirements. 12 | 13 | ``` 14 | go get -u github.com/golang/protobuf/{proto,protoc-gen-go} 15 | go get -u google.golang.org/grpc 16 | ``` 17 | 18 | Generate protobuf files. 19 | 20 | ``` 21 | cd ./src/ 22 | 23 | ./generate_proto_files.sh 24 | ``` 25 | 26 | Compile the project. 27 | 28 | ``` 29 | # Setup $GOPATH 30 | 31 | go build -x 32 | ``` 33 | 34 | Run the predict client. 35 | 36 | ``` 37 | # For dense model 38 | ./src --model_name dense 39 | 40 | # For sparse model 41 | ./src --model_name sparse 42 | ``` 43 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/tools/ci_build/install/.bazelrc: -------------------------------------------------------------------------------- 1 | # Running bazel inside a `docker build` command causes trouble, cf: 2 | # https://github.com/bazelbuild/bazel/issues/134 3 | # The easiest solution is to set up a bazelrc file forcing --batch. 4 | startup --batch 5 | 6 | # Similarly, we need to workaround sandboxing issues: 7 | # https://github.com/bazelbuild/bazel/issues/418 8 | build --verbose_failures --spawn_strategy=standalone --genrule_strategy=standalone 9 | test --spawn_strategy=standalone 10 | 11 | # Force bazel output to use colors (good for jenkins) and print useful errors. 12 | common --color=yes 13 | 14 | # Configure tests - increase timeout, print errors and timeout warnings 15 | test --verbose_failures --test_output=errors --test_verbose_timeout_warnings 16 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/framework/tensor_description.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "TensorDescriptionProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/types.proto"; 10 | import "tensorflow/core/framework/tensor_shape.proto"; 11 | import "tensorflow/core/framework/allocation_description.proto"; 12 | 13 | message TensorDescription { 14 | // Data type of tensor elements 15 | DataType dtype = 1; 16 | 17 | // Shape of the tensor. 18 | TensorShapeProto shape = 2; 19 | 20 | // Information about the size and allocator used for the data 21 | AllocationDescription allocation_description = 4; 22 | }; 23 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/framework/tensor_description.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "TensorDescriptionProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/types.proto"; 10 | import "tensorflow/core/framework/tensor_shape.proto"; 11 | import "tensorflow/core/framework/allocation_description.proto"; 12 | 13 | message TensorDescription { 14 | // Data type of tensor elements 15 | DataType dtype = 1; 16 | 17 | // Shape of the tensor. 18 | TensorShapeProto shape = 2; 19 | 20 | // Information about the size and allocator used for the data 21 | AllocationDescription allocation_description = 4; 22 | }; 23 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/framework/tensor_description.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "TensorDescriptionProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/types.proto"; 10 | import "tensorflow/core/framework/tensor_shape.proto"; 11 | import "tensorflow/core/framework/allocation_description.proto"; 12 | 13 | message TensorDescription { 14 | // Data type of tensor elements 15 | DataType dtype = 1; 16 | 17 | // Shape of the tensor. 18 | TensorShapeProto shape = 2; 19 | 20 | // Information about the size and allocator used for the data 21 | AllocationDescription allocation_description = 4; 22 | }; 23 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/framework/tensor_description.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "TensorDescriptionProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/types.proto"; 10 | import "tensorflow/core/framework/tensor_shape.proto"; 11 | import "tensorflow/core/framework/allocation_description.proto"; 12 | 13 | message TensorDescription { 14 | // Data type of tensor elements 15 | DataType dtype = 1; 16 | 17 | // Shape of the tensor. 18 | TensorShapeProto shape = 2; 19 | 20 | // Information about the size and allocator used for the data 21 | AllocationDescription allocation_description = 4; 22 | }; 23 | -------------------------------------------------------------------------------- /android_client/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /minimal_model/README.md: -------------------------------------------------------------------------------- 1 | ## Introduction 2 | 3 | The minimal TensorFlow application for benchmarking. 4 | 5 | ## Start predict server 6 | 7 | ``` 8 | ./tensorflow_model_server --port=9000 --model_name=minimal --model_base_path=./model 9 | ``` 10 | 11 | ## Start predict client 12 | 13 | ``` 14 | ./predict_client.py --host 127.0.0.1 --port 9000 --model_name minial --model_version 1 15 | ``` 16 | 17 | ``` 18 | cloudml models predict -n minial -s 127.0.0.1:9000 -f ./data.json 19 | ``` 20 | 21 | ## Benchmark 22 | 23 | ### Test local predict 24 | 25 | ``` 26 | ./benchmark_predict.py --benchmark_test_number 10 --benchmark_batch_size 1 27 | ``` 28 | 29 | ### Test python gRPC client 30 | 31 | ``` 32 | ./benchmark_qps.py --host 127.0.0.1 --port 9000 --model_name minial --model_version 1 --benchmark_batch_size 100 --benchmark_test_number 10000 33 | ``` 34 | -------------------------------------------------------------------------------- /ios_client/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #import 16 | 17 | @interface AppDelegate : UIResponder 18 | 19 | @property (strong, nonatomic) UIWindow *window; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /android_client/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/model.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow.serving; 4 | option cc_enable_arenas = true; 5 | 6 | import "google/protobuf/wrappers.proto"; 7 | 8 | // Metadata for an inference request such as the model name and version. 9 | message ModelSpec { 10 | // Required servable name. 11 | string name = 1; 12 | 13 | // Optional version. If unspecified, will use the latest (numerical) version. 14 | // Typically not needed unless coordinating across multiple models that were 15 | // co-trained and/or have inter-dependencies on the versions used at inference 16 | // time. 17 | google.protobuf.Int64Value version = 2; 18 | 19 | // A named signature to evaluate. If unspecified, the default signature will 20 | // be used. Note that only MultiInference will initially support this. 21 | string signature_name = 3; 22 | } 23 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/framework/allocation_description.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "AllocationDescriptionProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | message AllocationDescription { 10 | // Total number of bytes requested 11 | int64 requested_bytes = 1; 12 | 13 | // Total number of bytes allocated if known 14 | int64 allocated_bytes = 2; 15 | 16 | // Name of the allocator used 17 | string allocator_name = 3; 18 | 19 | // Identifier of the allocated buffer if known 20 | int64 allocation_id = 4; 21 | 22 | // Set if this tensor only has one remaining reference 23 | bool has_single_reference = 5; 24 | 25 | // Address of the allocation. 26 | uint64 ptr = 6; 27 | }; 28 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/model.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow.serving; 4 | option cc_enable_arenas = true; 5 | 6 | import "google/protobuf/wrappers.proto"; 7 | 8 | // Metadata for an inference request such as the model name and version. 9 | message ModelSpec { 10 | // Required servable name. 11 | string name = 1; 12 | 13 | // Optional version. If unspecified, will use the latest (numerical) version. 14 | // Typically not needed unless coordinating across multiple models that were 15 | // co-trained and/or have inter-dependencies on the versions used at inference 16 | // time. 17 | google.protobuf.Int64Value version = 2; 18 | 19 | // A named signature to evaluate. If unspecified, the default signature will 20 | // be used. Note that only MultiInference will initially support this. 21 | string signature_name = 3; 22 | } 23 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/framework/allocation_description.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "AllocationDescriptionProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | message AllocationDescription { 10 | // Total number of bytes requested 11 | int64 requested_bytes = 1; 12 | 13 | // Total number of bytes allocated if known 14 | int64 allocated_bytes = 2; 15 | 16 | // Name of the allocator used 17 | string allocator_name = 3; 18 | 19 | // Identifier of the allocated buffer if known 20 | int64 allocation_id = 4; 21 | 22 | // Set if this tensor only has one remaining reference 23 | bool has_single_reference = 5; 24 | 25 | // Address of the allocation. 26 | uint64 ptr = 6; 27 | }; 28 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/model.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow.serving; 4 | option cc_enable_arenas = true; 5 | 6 | import "google/protobuf/wrappers.proto"; 7 | 8 | // Metadata for an inference request such as the model name and version. 9 | message ModelSpec { 10 | // Required servable name. 11 | string name = 1; 12 | 13 | // Optional version. If unspecified, will use the latest (numerical) version. 14 | // Typically not needed unless coordinating across multiple models that were 15 | // co-trained and/or have inter-dependencies on the versions used at inference 16 | // time. 17 | google.protobuf.Int64Value version = 2; 18 | 19 | // A named signature to evaluate. If unspecified, the default signature will 20 | // be used. Note that only MultiInference will initially support this. 21 | string signature_name = 3; 22 | } 23 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/model.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow.serving; 4 | option cc_enable_arenas = true; 5 | 6 | import "google/protobuf/wrappers.proto"; 7 | 8 | // Metadata for an inference request such as the model name and version. 9 | message ModelSpec { 10 | // Required servable name. 11 | string name = 1; 12 | 13 | // Optional version. If unspecified, will use the latest (numerical) version. 14 | // Typically not needed unless coordinating across multiple models that were 15 | // co-trained and/or have inter-dependencies on the versions used at inference 16 | // time. 17 | google.protobuf.Int64Value version = 2; 18 | 19 | // A named signature to evaluate. If unspecified, the default signature will 20 | // be used. Note that only MultiInference will initially support this. 21 | string signature_name = 3; 22 | } 23 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/protobuf/named_tensor.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "NamedTensorProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/tensor.proto"; 10 | 11 | // A pair of tensor name and tensor values. 12 | message NamedTensorProto { 13 | // Name of the tensor. 14 | string name = 1; 15 | 16 | // The client can populate a TensorProto using a tensorflow::Tensor`, or 17 | // directly using the protobuf field accessors. 18 | // 19 | // The client specifies whether the returned tensor values should be 20 | // filled tensor fields (float_val, int_val, etc.) or encoded in a 21 | // compact form in tensor.tensor_content. 22 | TensorProto tensor = 2; 23 | } 24 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/protobuf/saved_model.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "SavedModelProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/protobuf/meta_graph.proto"; 10 | 11 | // SavedModel is the high level serialization format for TensorFlow Models. 12 | // See [todo: doc links, similar to session_bundle] for more information. 13 | message SavedModel { 14 | // The schema version of the SavedModel instance. Used for versioning when 15 | // making future changes to the specification/implementation. Initial value 16 | // at release will be 1. 17 | int64 saved_model_schema_version = 1; 18 | 19 | // One or more MetaGraphs. 20 | repeated MetaGraphDef meta_graphs = 2; 21 | } 22 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/framework/allocation_description.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "AllocationDescriptionProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | message AllocationDescription { 10 | // Total number of bytes requested 11 | int64 requested_bytes = 1; 12 | 13 | // Total number of bytes allocated if known 14 | int64 allocated_bytes = 2; 15 | 16 | // Name of the allocator used 17 | string allocator_name = 3; 18 | 19 | // Identifier of the allocated buffer if known 20 | int64 allocation_id = 4; 21 | 22 | // Set if this tensor only has one remaining reference 23 | bool has_single_reference = 5; 24 | 25 | // Address of the allocation. 26 | uint64 ptr = 6; 27 | }; 28 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/protobuf/named_tensor.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "NamedTensorProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/tensor.proto"; 10 | 11 | // A pair of tensor name and tensor values. 12 | message NamedTensorProto { 13 | // Name of the tensor. 14 | string name = 1; 15 | 16 | // The client can populate a TensorProto using a tensorflow::Tensor`, or 17 | // directly using the protobuf field accessors. 18 | // 19 | // The client specifies whether the returned tensor values should be 20 | // filled tensor fields (float_val, int_val, etc.) or encoded in a 21 | // compact form in tensor.tensor_content. 22 | TensorProto tensor = 2; 23 | } 24 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/protobuf/saved_model.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "SavedModelProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/protobuf/meta_graph.proto"; 10 | 11 | // SavedModel is the high level serialization format for TensorFlow Models. 12 | // See [todo: doc links, similar to session_bundle] for more information. 13 | message SavedModel { 14 | // The schema version of the SavedModel instance. Used for versioning when 15 | // making future changes to the specification/implementation. Initial value 16 | // at release will be 1. 17 | int64 saved_model_schema_version = 1; 18 | 19 | // One or more MetaGraphs. 20 | repeated MetaGraphDef meta_graphs = 2; 21 | } 22 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/framework/allocation_description.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "AllocationDescriptionProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | message AllocationDescription { 10 | // Total number of bytes requested 11 | int64 requested_bytes = 1; 12 | 13 | // Total number of bytes allocated if known 14 | int64 allocated_bytes = 2; 15 | 16 | // Name of the allocator used 17 | string allocator_name = 3; 18 | 19 | // Identifier of the allocated buffer if known 20 | int64 allocation_id = 4; 21 | 22 | // Set if this tensor only has one remaining reference 23 | bool has_single_reference = 5; 24 | 25 | // Address of the allocation. 26 | uint64 ptr = 6; 27 | }; 28 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/protobuf/saved_model.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "SavedModelProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/protobuf/meta_graph.proto"; 10 | 11 | // SavedModel is the high level serialization format for TensorFlow Models. 12 | // See [todo: doc links, similar to session_bundle] for more information. 13 | message SavedModel { 14 | // The schema version of the SavedModel instance. Used for versioning when 15 | // making future changes to the specification/implementation. Initial value 16 | // at release will be 1. 17 | int64 saved_model_schema_version = 1; 18 | 19 | // One or more MetaGraphs. 20 | repeated MetaGraphDef meta_graphs = 2; 21 | } 22 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/protobuf/named_tensor.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "NamedTensorProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/tensor.proto"; 10 | 11 | // A pair of tensor name and tensor values. 12 | message NamedTensorProto { 13 | // Name of the tensor. 14 | string name = 1; 15 | 16 | // The client can populate a TensorProto using a tensorflow::Tensor`, or 17 | // directly using the protobuf field accessors. 18 | // 19 | // The client specifies whether the returned tensor values should be 20 | // filled tensor fields (float_val, int_val, etc.) or encoded in a 21 | // compact form in tensor.tensor_content. 22 | TensorProto tensor = 2; 23 | } 24 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/protobuf/saved_model.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "SavedModelProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/protobuf/meta_graph.proto"; 10 | 11 | // SavedModel is the high level serialization format for TensorFlow Models. 12 | // See [todo: doc links, similar to session_bundle] for more information. 13 | message SavedModel { 14 | // The schema version of the SavedModel instance. Used for versioning when 15 | // making future changes to the specification/implementation. Initial value 16 | // at release will be 1. 17 | int64 saved_model_schema_version = 1; 18 | 19 | // One or more MetaGraphs. 20 | repeated MetaGraphDef meta_graphs = 2; 21 | } 22 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/protobuf/named_tensor.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "NamedTensorProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/tensor.proto"; 10 | 11 | // A pair of tensor name and tensor values. 12 | message NamedTensorProto { 13 | // Name of the tensor. 14 | string name = 1; 15 | 16 | // The client can populate a TensorProto using a tensorflow::Tensor`, or 17 | // directly using the protobuf field accessors. 18 | // 19 | // The client specifies whether the returned tensor values should be 20 | // filled tensor fields (float_val, int_val, etc.) or encoded in a 21 | // compact form in tensor.tensor_content. 22 | TensorProto tensor = 2; 23 | } 24 | -------------------------------------------------------------------------------- /ios_client/main.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #import 16 | 17 | int main(int argc, char * argv[]) { 18 | @autoreleasepool { 19 | NSString *delegateClassName = @"AppDelegate"; 20 | return UIApplicationMain(argc, argv, nil, delegateClassName); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /android_client/app/src/androidTest/java/com/tobe/androidclient/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.tobe.androidclient; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.tobe.androidclient", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/tools/tfprof/tfprof_options.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package tensorflow.tfprof; 4 | 5 | // Refers to tfprof_options.h/cc for documentation. 6 | // Only used to pass tfprof options from Python to C++. 7 | message OptionsProto { 8 | optional int64 max_depth = 1; 9 | optional int64 min_bytes = 2; 10 | optional int64 min_micros = 3; 11 | optional int64 min_params = 4; 12 | optional int64 min_float_ops = 5; 13 | repeated string device_regexes = 6; 14 | optional string order_by = 7; 15 | repeated string account_type_regexes = 8; 16 | repeated string start_name_regexes = 9; 17 | repeated string trim_name_regexes = 10; 18 | repeated string show_name_regexes = 11; 19 | repeated string hide_name_regexes = 12; 20 | optional bool account_displayed_op_only = 13; 21 | repeated string select = 14; 22 | optional bool viz = 15; 23 | optional string dump_to_file = 16; 24 | } -------------------------------------------------------------------------------- /android_client/gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Fri Feb 02 10:37:26 CST 2018 16 | systemProp.http.proxyHost=127.0.0.1 17 | org.gradle.jvmargs=-Xmx1536m 18 | systemProp.http.proxyPort=1086 19 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/tools/tfprof/tfprof_options.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package tensorflow.tfprof; 4 | 5 | // Refers to tfprof_options.h/cc for documentation. 6 | // Only used to pass tfprof options from Python to C++. 7 | message OptionsProto { 8 | optional int64 max_depth = 1; 9 | optional int64 min_bytes = 2; 10 | optional int64 min_micros = 3; 11 | optional int64 min_params = 4; 12 | optional int64 min_float_ops = 5; 13 | repeated string device_regexes = 6; 14 | optional string order_by = 7; 15 | repeated string account_type_regexes = 8; 16 | repeated string start_name_regexes = 9; 17 | repeated string trim_name_regexes = 10; 18 | repeated string show_name_regexes = 11; 19 | repeated string hide_name_regexes = 12; 20 | optional bool account_displayed_op_only = 13; 21 | repeated string select = 14; 22 | optional bool viz = 15; 23 | optional string dump_to_file = 16; 24 | } -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/tools/tfprof/tfprof_options.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package tensorflow.tfprof; 4 | 5 | // Refers to tfprof_options.h/cc for documentation. 6 | // Only used to pass tfprof options from Python to C++. 7 | message OptionsProto { 8 | optional int64 max_depth = 1; 9 | optional int64 min_bytes = 2; 10 | optional int64 min_micros = 3; 11 | optional int64 min_params = 4; 12 | optional int64 min_float_ops = 5; 13 | repeated string device_regexes = 6; 14 | optional string order_by = 7; 15 | repeated string account_type_regexes = 8; 16 | repeated string start_name_regexes = 9; 17 | repeated string trim_name_regexes = 10; 18 | repeated string show_name_regexes = 11; 19 | repeated string hide_name_regexes = 12; 20 | optional bool account_displayed_op_only = 13; 21 | repeated string select = 14; 22 | optional bool viz = 15; 23 | optional string dump_to_file = 16; 24 | } -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/tools/tfprof/tfprof_options.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package tensorflow.tfprof; 4 | 5 | // Refers to tfprof_options.h/cc for documentation. 6 | // Only used to pass tfprof options from Python to C++. 7 | message OptionsProto { 8 | optional int64 max_depth = 1; 9 | optional int64 min_bytes = 2; 10 | optional int64 min_micros = 3; 11 | optional int64 min_params = 4; 12 | optional int64 min_float_ops = 5; 13 | repeated string device_regexes = 6; 14 | optional string order_by = 7; 15 | repeated string account_type_regexes = 8; 16 | repeated string start_name_regexes = 9; 17 | repeated string trim_name_regexes = 10; 18 | repeated string show_name_regexes = 11; 19 | repeated string hide_name_regexes = 12; 20 | optional bool account_displayed_op_only = 13; 21 | repeated string select = 14; 22 | optional bool viz = 15; 23 | optional string dump_to_file = 16; 24 | } -------------------------------------------------------------------------------- /android_client/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/protobuf/queue_runner.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "QueueRunnerProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/lib/core/error_codes.proto"; 10 | 11 | // Protocol buffer representing a QueueRunner. 12 | message QueueRunnerDef { 13 | // Queue name. 14 | string queue_name = 1; 15 | 16 | // A list of enqueue operations. 17 | repeated string enqueue_op_name = 2; 18 | 19 | // The operation to run to close the queue. 20 | string close_op_name = 3; 21 | 22 | // The operation to run to cancel the queue. 23 | string cancel_op_name = 4; 24 | 25 | // A list of exception types considered to signal a safely closed queue 26 | // if raised during enqueue operations. 27 | repeated error.Code queue_closed_exception_types = 5; 28 | } 29 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/protobuf/queue_runner.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "QueueRunnerProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/lib/core/error_codes.proto"; 10 | 11 | // Protocol buffer representing a QueueRunner. 12 | message QueueRunnerDef { 13 | // Queue name. 14 | string queue_name = 1; 15 | 16 | // A list of enqueue operations. 17 | repeated string enqueue_op_name = 2; 18 | 19 | // The operation to run to close the queue. 20 | string close_op_name = 3; 21 | 22 | // The operation to run to cancel the queue. 23 | string cancel_op_name = 4; 24 | 25 | // A list of exception types considered to signal a safely closed queue 26 | // if raised during enqueue operations. 27 | repeated error.Code queue_closed_exception_types = 5; 28 | } 29 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/tensorboard/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | typings/* 3 | build/* 4 | dist/tf-tensorboard-demo.html 5 | 6 | # Since bower components are stored in the same directory as 7 | # tensorboard components, we ignore everything under components 8 | # except our own components which start with tf-. 9 | components/* 10 | # This rule should always be in sync with TF_COMPONENTS_TYPESCRIPT_GLOB 11 | # in gulpfile.js 12 | !components/tf-* 13 | !components/tf_* 14 | !components/vz-* 15 | !components/vz_* 16 | !components/index.html 17 | !components/BUILD 18 | # Ignore the sample graph files since they are too large to 19 | # be in the repo. 20 | components/tf-graph/demo/tf_model_zoo/* 21 | 22 | # All standalone code for TensorBoard components should be written in 23 | # typescript, and the compiled javascript code should be ignored. 24 | components/tf-*/**/*.js 25 | components/tf_*/**/*.js 26 | components/vz-*/**/*.js 27 | components/vz_*/**/*.js 28 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/protobuf/queue_runner.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "QueueRunnerProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/lib/core/error_codes.proto"; 10 | 11 | // Protocol buffer representing a QueueRunner. 12 | message QueueRunnerDef { 13 | // Queue name. 14 | string queue_name = 1; 15 | 16 | // A list of enqueue operations. 17 | repeated string enqueue_op_name = 2; 18 | 19 | // The operation to run to close the queue. 20 | string close_op_name = 3; 21 | 22 | // The operation to run to cancel the queue. 23 | string cancel_op_name = 4; 24 | 25 | // A list of exception types considered to signal a safely closed queue 26 | // if raised during enqueue operations. 27 | repeated error.Code queue_closed_exception_types = 5; 28 | } 29 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/tensorboard/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | typings/* 3 | build/* 4 | dist/tf-tensorboard-demo.html 5 | 6 | # Since bower components are stored in the same directory as 7 | # tensorboard components, we ignore everything under components 8 | # except our own components which start with tf-. 9 | components/* 10 | # This rule should always be in sync with TF_COMPONENTS_TYPESCRIPT_GLOB 11 | # in gulpfile.js 12 | !components/tf-* 13 | !components/tf_* 14 | !components/vz-* 15 | !components/vz_* 16 | !components/index.html 17 | !components/BUILD 18 | # Ignore the sample graph files since they are too large to 19 | # be in the repo. 20 | components/tf-graph/demo/tf_model_zoo/* 21 | 22 | # All standalone code for TensorBoard components should be written in 23 | # typescript, and the compiled javascript code should be ignored. 24 | components/tf-*/**/*.js 25 | components/tf_*/**/*.js 26 | components/vz-*/**/*.js 27 | components/vz_*/**/*.js 28 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/protobuf/queue_runner.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "QueueRunnerProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/lib/core/error_codes.proto"; 10 | 11 | // Protocol buffer representing a QueueRunner. 12 | message QueueRunnerDef { 13 | // Queue name. 14 | string queue_name = 1; 15 | 16 | // A list of enqueue operations. 17 | repeated string enqueue_op_name = 2; 18 | 19 | // The operation to run to close the queue. 20 | string close_op_name = 3; 21 | 22 | // The operation to run to cancel the queue. 23 | string cancel_op_name = 4; 24 | 25 | // A list of exception types considered to signal a safely closed queue 26 | // if raised during enqueue operations. 27 | repeated error.Code queue_closed_exception_types = 5; 28 | } 29 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/tensorboard/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | typings/* 3 | build/* 4 | dist/tf-tensorboard-demo.html 5 | 6 | # Since bower components are stored in the same directory as 7 | # tensorboard components, we ignore everything under components 8 | # except our own components which start with tf-. 9 | components/* 10 | # This rule should always be in sync with TF_COMPONENTS_TYPESCRIPT_GLOB 11 | # in gulpfile.js 12 | !components/tf-* 13 | !components/tf_* 14 | !components/vz-* 15 | !components/vz_* 16 | !components/index.html 17 | !components/BUILD 18 | # Ignore the sample graph files since they are too large to 19 | # be in the repo. 20 | components/tf-graph/demo/tf_model_zoo/* 21 | 22 | # All standalone code for TensorBoard components should be written in 23 | # typescript, and the compiled javascript code should be ignored. 24 | components/tf-*/**/*.js 25 | components/tf_*/**/*.js 26 | components/vz-*/**/*.js 27 | components/vz_*/**/*.js 28 | -------------------------------------------------------------------------------- /ios_client/RunModelViewController.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #import 16 | 17 | @interface RunModelViewController : UIViewController 18 | 19 | - (IBAction)getUrl:(id)sender; 20 | 21 | @property (weak, nonatomic) IBOutlet UITextView *urlContentTextView; 22 | @property (weak, nonatomic) IBOutlet UITextField *urlTextField; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/tensorboard/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | typings/* 3 | build/* 4 | dist/tf-tensorboard-demo.html 5 | 6 | # Since bower components are stored in the same directory as 7 | # tensorboard components, we ignore everything under components 8 | # except our own components which start with tf-. 9 | components/* 10 | # This rule should always be in sync with TF_COMPONENTS_TYPESCRIPT_GLOB 11 | # in gulpfile.js 12 | !components/tf-* 13 | !components/tf_* 14 | !components/vz-* 15 | !components/vz_* 16 | !components/index.html 17 | !components/BUILD 18 | # Ignore the sample graph files since they are too large to 19 | # be in the repo. 20 | components/tf-graph/demo/tf_model_zoo/* 21 | 22 | # All standalone code for TensorBoard components should be written in 23 | # typescript, and the compiled javascript code should be ignored. 24 | components/tf-*/**/*.js 25 | components/tf_*/**/*.js 26 | components/vz-*/**/*.js 27 | components/vz_*/**/*.js 28 | -------------------------------------------------------------------------------- /cpp_predict_client/README.md: -------------------------------------------------------------------------------- 1 | # Cpp Predict Client 2 | 3 | ## Introduction 4 | 5 | TensorFlow serving is the gRPC service for general TensorFlow models. We can implement the C++ gRPC client to predict. 6 | 7 | Now you need to use `bazel` and just refer to to [inception_client.cc](https://github.com/tensorflow/serving/pull/300). 8 | 9 | ## Usage 10 | 11 | Add the build rule in `tensorflow_serving/example/BUILD` and copy [sparse_predict_client.cc](./sparse_predict_client.cc) in example directory. 12 | 13 | ``` 14 | cc_binary( 15 | name = "sparse_predict_client", 16 | srcs = [ 17 | "sparse_predict_client.cc", 18 | ], 19 | deps = [ 20 | "//tensorflow_serving/apis:prediction_service_proto", 21 | ], 22 | ) 23 | ``` 24 | 25 | Compile the gRPC client. 26 | 27 | ``` 28 | bazel build //tensorflow_serving/example:sparse_predict_client 29 | ``` 30 | 31 | Run the predict client. 32 | 33 | ``` 34 | bazel-bin/tensorflow_serving/example/sparse_predict_client 35 | ``` 36 | -------------------------------------------------------------------------------- /http_service/README.md: -------------------------------------------------------------------------------- 1 | # Cancer Predictiton Service 2 | 3 | This is the HTTP service to load TensorFlow model and inference to predict cancer. 4 | 5 | ## Usage 6 | 7 | 8 | Run HTTP server with [Django] and use HTTP client with curl, postman or [bat](https://github.com/astaxie/bat) for test. 9 | 10 | ``` 11 | ./manage.py runserver 0.0.0.0:8000 12 | ``` 13 | 14 | ### Inference to predict cancer 15 | 16 | ``` 17 | bat post http://127.0.0.1:8000/cancer_predict/predict/ cancer_features="10,10,10,8,6,1,8,9,1;6,2,1,1,1,1,7,1,1" 18 | ``` 19 | 20 | ![](./images/predict.png) 21 | 22 | ### Online learning to train 23 | 24 | ``` 25 | bat post http://127.0.0.1:8000/cancer_predict/online_train/ cancer_features_and_labels="10,10,10,8,6,1,8,9,1,1;6,2,1,1,1,1,7,1,1,0" 26 | ``` 27 | 28 | ![](./images/online_train.png) 29 | 30 | ## Implementation 31 | 32 | ``` 33 | django-admin startproject restful_server 34 | 35 | python manage.py startapp cancer_predict 36 | 37 | # Add customized urls and views. 38 | ``` 39 | -------------------------------------------------------------------------------- /http_service/restful_server/urls.py: -------------------------------------------------------------------------------- 1 | """restful_server URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/1.9/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.conf.urls import url, include 14 | 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 15 | """ 16 | from django.conf.urls import url 17 | from django.contrib import admin 18 | 19 | from django.conf.urls import include, url 20 | 21 | urlpatterns = [ 22 | url(r'^cancer_predict/', include('cancer_predict.urls')), 23 | url(r'^admin/', admin.site.urls), 24 | ] 25 | -------------------------------------------------------------------------------- /tensorboard_tools/read_event_files.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import tensorflow as tf 4 | 5 | 6 | def main(): 7 | event_file_path = "/Users/tobe/code/tensorflow_template_application/tensorboard/events.out.tfevents.1527218992.mbp-2.local" 8 | for event in tf.train.summary_iterator(event_file_path): 9 | 10 | print("--------------------") 11 | print("Time: {}".format(event.wall_time)) 12 | 13 | for v in event.summary.value: 14 | if v.tag == "loss_1": 15 | print("Loss: {}".format(v.simple_value)) 16 | elif v.tag == "train_accuracy": 17 | print("Train accuracy: {}".format(v.simple_value)) 18 | elif v.tag == "train_auc": 19 | print("Train auc: {}".format(v.simple_value)) 20 | elif v.tag == "validate_accuracy": 21 | print("Validate accuracy: {}".format(v.simple_value)) 22 | elif v.tag == "validate_auc": 23 | print("Validate auc: {}".format(v.simple_value)) 24 | 25 | 26 | if __name__ == "__main__": 27 | main() 28 | -------------------------------------------------------------------------------- /java_predict_client/src/main/scala/com/tobe/client/ScalaDensePredictClient.scala: -------------------------------------------------------------------------------- 1 | package com.tobe.client 2 | 3 | object ScalaDensePredictClient { 4 | 5 | def main(args: Array[String]): Unit = { 6 | 7 | System.out.println("Start scala project") 8 | 9 | var host: String = "127.0.0.1" 10 | var port: Int = 9000 11 | var modelName: String = "dense" 12 | var modelVersion: Long = 1 13 | 14 | // TODO: String to int doesn't work 15 | // Parse command-line arguments 16 | if (args.length == 4) { 17 | host = args(0) 18 | //port = args(1).toInt 19 | modelName = args(2) 20 | //modelVersion = args(3).toLong 21 | } 22 | 23 | // Create dense predict client 24 | val client: DensePredictClient = new DensePredictClient(host, port) 25 | 26 | // Run predict client to send request 27 | client.predict_example(modelName, modelVersion) 28 | 29 | System.out.println("End of predict client") 30 | // TODO: Exit the project well 31 | System.exit(0) 32 | 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/framework/resource_handle.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "ResourceHandleProto"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Protocol buffer representing a handle to a tensorflow resource. Handles are 10 | // not valid across executions, but can be serialized back and forth from within 11 | // a single run. 12 | message ResourceHandle { 13 | // Unique name for the device containing the resource. 14 | string device = 1; 15 | 16 | // Container in which this resource is placed. 17 | string container = 2; 18 | 19 | // Unique name of this resource. 20 | string name = 3; 21 | 22 | // Hash code for the type of the resource. Is only valid in the same device 23 | // and in the same execution. 24 | uint64 hash_code = 4; 25 | 26 | // For debug-only, the name of the type pointed to by this handle, if 27 | // available. 28 | string maybe_type_name = 5; 29 | }; 30 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/framework/resource_handle.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "ResourceHandleProto"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Protocol buffer representing a handle to a tensorflow resource. Handles are 10 | // not valid across executions, but can be serialized back and forth from within 11 | // a single run. 12 | message ResourceHandle { 13 | // Unique name for the device containing the resource. 14 | string device = 1; 15 | 16 | // Container in which this resource is placed. 17 | string container = 2; 18 | 19 | // Unique name of this resource. 20 | string name = 3; 21 | 22 | // Hash code for the type of the resource. Is only valid in the same device 23 | // and in the same execution. 24 | uint64 hash_code = 4; 25 | 26 | // For debug-only, the name of the type pointed to by this handle, if 27 | // available. 28 | string maybe_type_name = 5; 29 | }; 30 | -------------------------------------------------------------------------------- /cpp_predict_server/README.md: -------------------------------------------------------------------------------- 1 | # Cpp Predict Server 2 | 3 | ## Introduction 4 | 5 | TensorFlow serving is the gRPC server for general TensorFlow models. 6 | 7 | ## Installation 8 | 9 | Follow the official documents to build with `bazel build //tensorflow_serving/model_servers:tensorflow_model_server`. 10 | 11 | Or use the binary [tensorflow_model_server](./tensorflow_model_server/) with TensorFlow 0.11.0 in Linux. 12 | 13 | ``` 14 | Usage: tensorflow_model_server [--port=8500] [--enable_batching] [--model_name=my_name] --model_base_path=/path/to/export 15 | ``` 16 | 17 | ## Usage 18 | 19 | 1. Export the TensorFlow models in local host. 20 | 2. Run server with `./tensorflow_model_server --port=9000 --model_name=cancer --model_base_path=/tmp/cancer_model`. 21 | 22 | It is possible to run with docker container. Notice that the docker image is not public yet but easy to implement. 23 | 24 | ``` 25 | sudo docker run -d -p 9000:9000 -v /tmp/cancer_model:/tmp/cancer_model docker.d.xiaomi.net/cloud-ml/model-tensorflow-cpu:0.11.0 /model_service.py cancer /tmp/cancer_model 26 | ``` 27 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/framework/resource_handle.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "ResourceHandleProto"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Protocol buffer representing a handle to a tensorflow resource. Handles are 10 | // not valid across executions, but can be serialized back and forth from within 11 | // a single run. 12 | message ResourceHandle { 13 | // Unique name for the device containing the resource. 14 | string device = 1; 15 | 16 | // Container in which this resource is placed. 17 | string container = 2; 18 | 19 | // Unique name of this resource. 20 | string name = 3; 21 | 22 | // Hash code for the type of the resource. Is only valid in the same device 23 | // and in the same execution. 24 | uint64 hash_code = 4; 25 | 26 | // For debug-only, the name of the type pointed to by this handle, if 27 | // available. 28 | string maybe_type_name = 5; 29 | }; 30 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/framework/resource_handle.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "ResourceHandleProto"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Protocol buffer representing a handle to a tensorflow resource. Handles are 10 | // not valid across executions, but can be serialized back and forth from within 11 | // a single run. 12 | message ResourceHandle { 13 | // Unique name for the device containing the resource. 14 | string device = 1; 15 | 16 | // Container in which this resource is placed. 17 | string container = 2; 18 | 19 | // Unique name of this resource. 20 | string name = 3; 21 | 22 | // Hash code for the type of the resource. Is only valid in the same device 23 | // and in the same execution. 24 | uint64 hash_code = 4; 25 | 26 | // For debug-only, the name of the type pointed to by this handle, if 27 | // available. 28 | string maybe_type_name = 5; 29 | }; 30 | -------------------------------------------------------------------------------- /ios_client/ios_image_load.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef TENSORFLOW_EXAMPLES_IOS_IOS_IMAGE_LOAD_H_ 16 | #define TENSORFLOW_EXAMPLES_IOS_IOS_IMAGE_LOAD_H_ 17 | 18 | #include 19 | 20 | #include "tensorflow/core/framework/types.h" 21 | 22 | std::vector LoadImageFromFile(const char* file_name, 23 | int* out_width, 24 | int* out_height, 25 | int* out_channels); 26 | 27 | #endif // TENSORFLOW_EXAMPLES_IOS_IOS_IMAGE_LOAD_H_ 28 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/framework/variable.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "VariableProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Protocol buffer representing a Variable. 10 | message VariableDef { 11 | // Name of the variable tensor. 12 | string variable_name = 1; 13 | 14 | // Name of the initializer op. 15 | string initializer_name = 2; 16 | 17 | // Name of the snapshot tensor. 18 | string snapshot_name = 3; 19 | 20 | // Support for saving variables as slices of a larger variable. 21 | SaveSliceInfoDef save_slice_info_def = 4; 22 | } 23 | 24 | message SaveSliceInfoDef { 25 | // Name of the full variable of which this is a slice. 26 | string full_name = 1; 27 | // Shape of the full variable. 28 | repeated int32 full_shape = 2; 29 | // Offset of this variable into the full variable. 30 | repeated int32 var_offset = 3; 31 | // Shape of this variable. 32 | repeated int32 var_shape = 4; 33 | } 34 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/framework/variable.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "VariableProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Protocol buffer representing a Variable. 10 | message VariableDef { 11 | // Name of the variable tensor. 12 | string variable_name = 1; 13 | 14 | // Name of the initializer op. 15 | string initializer_name = 2; 16 | 17 | // Name of the snapshot tensor. 18 | string snapshot_name = 3; 19 | 20 | // Support for saving variables as slices of a larger variable. 21 | SaveSliceInfoDef save_slice_info_def = 4; 22 | } 23 | 24 | message SaveSliceInfoDef { 25 | // Name of the full variable of which this is a slice. 26 | string full_name = 1; 27 | // Shape of the full variable. 28 | repeated int32 full_shape = 2; 29 | // Offset of this variable into the full variable. 30 | repeated int32 var_offset = 3; 31 | // Shape of this variable. 32 | repeated int32 var_shape = 4; 33 | } 34 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/framework/variable.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "VariableProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Protocol buffer representing a Variable. 10 | message VariableDef { 11 | // Name of the variable tensor. 12 | string variable_name = 1; 13 | 14 | // Name of the initializer op. 15 | string initializer_name = 2; 16 | 17 | // Name of the snapshot tensor. 18 | string snapshot_name = 3; 19 | 20 | // Support for saving variables as slices of a larger variable. 21 | SaveSliceInfoDef save_slice_info_def = 4; 22 | } 23 | 24 | message SaveSliceInfoDef { 25 | // Name of the full variable of which this is a slice. 26 | string full_name = 1; 27 | // Shape of the full variable. 28 | repeated int32 full_shape = 2; 29 | // Offset of this variable into the full variable. 30 | repeated int32 var_offset = 3; 31 | // Shape of this variable. 32 | repeated int32 var_shape = 4; 33 | } 34 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/framework/variable.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "VariableProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Protocol buffer representing a Variable. 10 | message VariableDef { 11 | // Name of the variable tensor. 12 | string variable_name = 1; 13 | 14 | // Name of the initializer op. 15 | string initializer_name = 2; 16 | 17 | // Name of the snapshot tensor. 18 | string snapshot_name = 3; 19 | 20 | // Support for saving variables as slices of a larger variable. 21 | SaveSliceInfoDef save_slice_info_def = 4; 22 | } 23 | 24 | message SaveSliceInfoDef { 25 | // Name of the full variable of which this is a slice. 26 | string full_name = 1; 27 | // Shape of the full variable. 28 | repeated int32 full_shape = 2; 29 | // Offset of this variable into the full variable. 30 | repeated int32 var_offset = 3; 31 | // Shape of this variable. 32 | repeated int32 var_shape = 4; 33 | } 34 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/framework/versions.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "VersionsProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Version information for a piece of serialized data 10 | // 11 | // There are different types of versions for each type of data 12 | // (GraphDef, etc.), but they all have the same common shape 13 | // described here. 14 | // 15 | // Each consumer has "consumer" and "min_producer" versions (specified 16 | // elsewhere). A consumer is allowed to consume this data if 17 | // 18 | // producer >= min_producer 19 | // consumer >= min_consumer 20 | // consumer not in bad_consumers 21 | // 22 | message VersionDef { 23 | // The version of the code that produced this data. 24 | int32 producer = 1; 25 | 26 | // Any consumer below this version is not allowed to consume this data. 27 | int32 min_consumer = 2; 28 | 29 | // Specific consumer versions which are disallowed (e.g. due to bugs). 30 | repeated int32 bad_consumers = 3; 31 | }; 32 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/framework/versions.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "VersionsProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Version information for a piece of serialized data 10 | // 11 | // There are different types of versions for each type of data 12 | // (GraphDef, etc.), but they all have the same common shape 13 | // described here. 14 | // 15 | // Each consumer has "consumer" and "min_producer" versions (specified 16 | // elsewhere). A consumer is allowed to consume this data if 17 | // 18 | // producer >= min_producer 19 | // consumer >= min_consumer 20 | // consumer not in bad_consumers 21 | // 22 | message VersionDef { 23 | // The version of the code that produced this data. 24 | int32 producer = 1; 25 | 26 | // Any consumer below this version is not allowed to consume this data. 27 | int32 min_consumer = 2; 28 | 29 | // Specific consumer versions which are disallowed (e.g. due to bugs). 30 | repeated int32 bad_consumers = 3; 31 | }; 32 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/framework/versions.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "VersionsProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Version information for a piece of serialized data 10 | // 11 | // There are different types of versions for each type of data 12 | // (GraphDef, etc.), but they all have the same common shape 13 | // described here. 14 | // 15 | // Each consumer has "consumer" and "min_producer" versions (specified 16 | // elsewhere). A consumer is allowed to consume this data if 17 | // 18 | // producer >= min_producer 19 | // consumer >= min_consumer 20 | // consumer not in bad_consumers 21 | // 22 | message VersionDef { 23 | // The version of the code that produced this data. 24 | int32 producer = 1; 25 | 26 | // Any consumer below this version is not allowed to consume this data. 27 | int32 min_consumer = 2; 28 | 29 | // Specific consumer versions which are disallowed (e.g. due to bugs). 30 | repeated int32 bad_consumers = 3; 31 | }; 32 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/framework/versions.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "VersionsProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Version information for a piece of serialized data 10 | // 11 | // There are different types of versions for each type of data 12 | // (GraphDef, etc.), but they all have the same common shape 13 | // described here. 14 | // 15 | // Each consumer has "consumer" and "min_producer" versions (specified 16 | // elsewhere). A consumer is allowed to consume this data if 17 | // 18 | // producer >= min_producer 19 | // consumer >= min_consumer 20 | // consumer not in bad_consumers 21 | // 22 | message VersionDef { 23 | // The version of the code that produced this data. 24 | int32 producer = 1; 25 | 26 | // Any consumer below this version is not allowed to consume this data. 27 | int32 min_consumer = 2; 28 | 29 | // Specific consumer versions which are disallowed (e.g. due to bugs). 30 | repeated int32 bad_consumers = 3; 31 | }; 32 | -------------------------------------------------------------------------------- /data/iris/print_csv_tfrecords.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import tensorflow as tf 4 | import os 5 | 6 | 7 | def print_tfrecords(input_filename): 8 | max_print_number = 100 9 | current_print_number = 0 10 | 11 | for serialized_example in tf.python_io.tf_record_iterator(input_filename): 12 | # Get serialized example from file 13 | example = tf.train.Example() 14 | example.ParseFromString(serialized_example) 15 | label = example.features.feature["label"].float_list.value 16 | features = example.features.feature["features"].float_list.value 17 | print("Number: {}, label: {}, features: {}".format(current_print_number, 18 | label, features)) 19 | 20 | # Return when reaching max print number 21 | current_print_number += 1 22 | if current_print_number > max_print_number: 23 | exit() 24 | 25 | 26 | def main(): 27 | current_path = os.getcwd() 28 | tfrecords_file_name = "iris_train.csv.tfrecords" 29 | input_filename = os.path.join(current_path, tfrecords_file_name) 30 | print_tfrecords(input_filename) 31 | 32 | 33 | if __name__ == "__main__": 34 | main() 35 | -------------------------------------------------------------------------------- /data/boston_housing/print_csv_tfrecords.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import tensorflow as tf 4 | import os 5 | 6 | 7 | def print_tfrecords(input_filename): 8 | max_print_number = 100 9 | current_print_number = 0 10 | 11 | for serialized_example in tf.python_io.tf_record_iterator(input_filename): 12 | # Get serialized example from file 13 | example = tf.train.Example() 14 | example.ParseFromString(serialized_example) 15 | label = example.features.feature["label"].float_list.value 16 | features = example.features.feature["features"].float_list.value 17 | print("Number: {}, label: {}, features: {}".format(current_print_number, 18 | label, features)) 19 | 20 | # Return when reaching max print number 21 | current_print_number += 1 22 | if current_print_number > max_print_number: 23 | exit() 24 | 25 | 26 | def main(): 27 | current_path = os.getcwd() 28 | tfrecords_file_name = "train.csv.tfrecords" 29 | input_filename = os.path.join(current_path, tfrecords_file_name) 30 | print_tfrecords(input_filename) 31 | 32 | 33 | if __name__ == "__main__": 34 | main() 35 | -------------------------------------------------------------------------------- /data/lung/print_csv_tfrecords.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import tensorflow as tf 4 | import os 5 | 6 | 7 | def print_tfrecords(input_filename): 8 | max_print_number = 100 9 | current_print_number = 0 10 | 11 | for serialized_example in tf.python_io.tf_record_iterator(input_filename): 12 | # Get serialized example from file 13 | example = tf.train.Example() 14 | example.ParseFromString(serialized_example) 15 | label = example.features.feature["label"].float_list.value 16 | features = example.features.feature["features"].float_list.value 17 | print("Number: {}, label: {}, features: {}".format(current_print_number, 18 | label, features)) 19 | 20 | # Return when reaching max print number 21 | current_print_number += 1 22 | if current_print_number > max_print_number: 23 | exit() 24 | 25 | 26 | def main(): 27 | current_path = os.getcwd() 28 | tfrecords_file_name = "fa7a21165ae152b13def786e6afc3edf.dcm.csv.tfrecords" 29 | input_filename = os.path.join(current_path, tfrecords_file_name) 30 | print_tfrecords(input_filename) 31 | 32 | 33 | if __name__ == "__main__": 34 | main() 35 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/python/util/protobuf/compare_test.proto: -------------------------------------------------------------------------------- 1 | // Test messages used in compare_test.py. 2 | syntax = "proto2"; 3 | 4 | package compare_test; 5 | option cc_enable_arenas = true; 6 | 7 | enum Enum { 8 | A = 0; 9 | B = 1; 10 | C = 2; 11 | } 12 | 13 | message Small { 14 | repeated string strings = 1; 15 | }; 16 | 17 | message Medium { 18 | repeated int32 int32s = 1; 19 | repeated Small smalls = 2; 20 | repeated group GroupA = 3 { 21 | repeated group GroupB = 4 { 22 | required string strings = 5; 23 | } 24 | } 25 | repeated float floats = 6; 26 | }; 27 | 28 | message Large { 29 | optional string string_ = 1; 30 | optional int64 int64_ = 2; 31 | optional float float_ = 3; 32 | optional bool bool_ = 4; 33 | optional Enum enum_ = 5; 34 | repeated int64 int64s = 6; 35 | optional Medium medium = 7; 36 | optional Small small = 8; 37 | optional double double_ = 9; 38 | optional WithMap with_map = 10; 39 | }; 40 | 41 | message Labeled { 42 | required int32 required = 1; 43 | optional int32 optional = 2; 44 | } 45 | 46 | message WithMap { 47 | map value_message = 1; 48 | map value_string = 2; 49 | } 50 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/python/util/protobuf/compare_test.proto: -------------------------------------------------------------------------------- 1 | // Test messages used in compare_test.py. 2 | syntax = "proto2"; 3 | 4 | package compare_test; 5 | option cc_enable_arenas = true; 6 | 7 | enum Enum { 8 | A = 0; 9 | B = 1; 10 | C = 2; 11 | } 12 | 13 | message Small { 14 | repeated string strings = 1; 15 | }; 16 | 17 | message Medium { 18 | repeated int32 int32s = 1; 19 | repeated Small smalls = 2; 20 | repeated group GroupA = 3 { 21 | repeated group GroupB = 4 { 22 | required string strings = 5; 23 | } 24 | } 25 | repeated float floats = 6; 26 | }; 27 | 28 | message Large { 29 | optional string string_ = 1; 30 | optional int64 int64_ = 2; 31 | optional float float_ = 3; 32 | optional bool bool_ = 4; 33 | optional Enum enum_ = 5; 34 | repeated int64 int64s = 6; 35 | optional Medium medium = 7; 36 | optional Small small = 8; 37 | optional double double_ = 9; 38 | optional WithMap with_map = 10; 39 | }; 40 | 41 | message Labeled { 42 | required int32 required = 1; 43 | optional int32 optional = 2; 44 | } 45 | 46 | message WithMap { 47 | map value_message = 1; 48 | map value_string = 2; 49 | } 50 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/python/util/protobuf/compare_test.proto: -------------------------------------------------------------------------------- 1 | // Test messages used in compare_test.py. 2 | syntax = "proto2"; 3 | 4 | package compare_test; 5 | option cc_enable_arenas = true; 6 | 7 | enum Enum { 8 | A = 0; 9 | B = 1; 10 | C = 2; 11 | } 12 | 13 | message Small { 14 | repeated string strings = 1; 15 | }; 16 | 17 | message Medium { 18 | repeated int32 int32s = 1; 19 | repeated Small smalls = 2; 20 | repeated group GroupA = 3 { 21 | repeated group GroupB = 4 { 22 | required string strings = 5; 23 | } 24 | } 25 | repeated float floats = 6; 26 | }; 27 | 28 | message Large { 29 | optional string string_ = 1; 30 | optional int64 int64_ = 2; 31 | optional float float_ = 3; 32 | optional bool bool_ = 4; 33 | optional Enum enum_ = 5; 34 | repeated int64 int64s = 6; 35 | optional Medium medium = 7; 36 | optional Small small = 8; 37 | optional double double_ = 9; 38 | optional WithMap with_map = 10; 39 | }; 40 | 41 | message Labeled { 42 | required int32 required = 1; 43 | optional int32 optional = 2; 44 | } 45 | 46 | message WithMap { 47 | map value_message = 1; 48 | map value_string = 2; 49 | } 50 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/python/util/protobuf/compare_test.proto: -------------------------------------------------------------------------------- 1 | // Test messages used in compare_test.py. 2 | syntax = "proto2"; 3 | 4 | package compare_test; 5 | option cc_enable_arenas = true; 6 | 7 | enum Enum { 8 | A = 0; 9 | B = 1; 10 | C = 2; 11 | } 12 | 13 | message Small { 14 | repeated string strings = 1; 15 | }; 16 | 17 | message Medium { 18 | repeated int32 int32s = 1; 19 | repeated Small smalls = 2; 20 | repeated group GroupA = 3 { 21 | repeated group GroupB = 4 { 22 | required string strings = 5; 23 | } 24 | } 25 | repeated float floats = 6; 26 | }; 27 | 28 | message Large { 29 | optional string string_ = 1; 30 | optional int64 int64_ = 2; 31 | optional float float_ = 3; 32 | optional bool bool_ = 4; 33 | optional Enum enum_ = 5; 34 | repeated int64 int64s = 6; 35 | optional Medium medium = 7; 36 | optional Small small = 8; 37 | optional double double_ = 9; 38 | optional WithMap with_map = 10; 39 | }; 40 | 41 | message Labeled { 42 | required int32 required = 1; 43 | optional int32 optional = 2; 44 | } 45 | 46 | message WithMap { 47 | map value_message = 1; 48 | map value_string = 2; 49 | } 50 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/util/memmapped_file_system.proto: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | ==============================================================================*/ 15 | syntax = "proto3"; 16 | 17 | package tensorflow; 18 | option cc_enable_arenas = true; 19 | 20 | // A message that describes one region of memmapped file. 21 | message MemmappedFileSystemDirectoryElement { 22 | uint64 offset = 1; 23 | string name = 2; 24 | } 25 | 26 | // A directory of regions in a memmapped file. 27 | message MemmappedFileSystemDirectory { 28 | repeated MemmappedFileSystemDirectoryElement element = 1; 29 | } 30 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/util/memmapped_file_system.proto: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | ==============================================================================*/ 15 | syntax = "proto3"; 16 | 17 | package tensorflow; 18 | option cc_enable_arenas = true; 19 | 20 | // A message that describes one region of memmapped file. 21 | message MemmappedFileSystemDirectoryElement { 22 | uint64 offset = 1; 23 | string name = 2; 24 | } 25 | 26 | // A directory of regions in a memmapped file. 27 | message MemmappedFileSystemDirectory { 28 | repeated MemmappedFileSystemDirectoryElement element = 1; 29 | } 30 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/util/memmapped_file_system.proto: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | ==============================================================================*/ 15 | syntax = "proto3"; 16 | 17 | package tensorflow; 18 | option cc_enable_arenas = true; 19 | 20 | // A message that describes one region of memmapped file. 21 | message MemmappedFileSystemDirectoryElement { 22 | uint64 offset = 1; 23 | string name = 2; 24 | } 25 | 26 | // A directory of regions in a memmapped file. 27 | message MemmappedFileSystemDirectory { 28 | repeated MemmappedFileSystemDirectoryElement element = 1; 29 | } 30 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/util/memmapped_file_system.proto: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | ==============================================================================*/ 15 | syntax = "proto3"; 16 | 17 | package tensorflow; 18 | option cc_enable_arenas = true; 19 | 20 | // A message that describes one region of memmapped file. 21 | message MemmappedFileSystemDirectoryElement { 22 | uint64 offset = 1; 23 | string name = 2; 24 | } 25 | 26 | // A directory of regions in a memmapped file. 27 | message MemmappedFileSystemDirectory { 28 | repeated MemmappedFileSystemDirectoryElement element = 1; 29 | } 30 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/framework/device_attributes.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "DeviceAttributesProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | message DeviceLocality { 10 | // Optional bus locality of device. Default value of 0 means 11 | // no specific locality. Specific localities are indexed from 1. 12 | int32 bus_id = 1; 13 | }; 14 | 15 | message DeviceAttributes { 16 | // Fully specified name of the device within a cluster. 17 | string name = 1; 18 | 19 | // String representation of device_type. 20 | string device_type = 2; 21 | 22 | // Memory capacity of device in bytes. 23 | int64 memory_limit = 4; 24 | 25 | // Platform-specific data about device that may be useful 26 | // for supporting efficient data transfers. 27 | DeviceLocality locality = 5; 28 | 29 | // A device is assigned a global unique number each time it is 30 | // initialized. "incarnation" should never be 0. 31 | fixed64 incarnation = 6; 32 | 33 | // String representation of the physical device that this device maps to. 34 | string physical_device_desc = 7; 35 | } 36 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/framework/kernel_def.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "KernelDefProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/attr_value.proto"; 10 | 11 | message KernelDef { 12 | // Must match the name of an Op. 13 | string op = 1; 14 | 15 | // Type of device this kernel runs on. 16 | string device_type = 2; 17 | 18 | message AttrConstraint { 19 | // Name of an attr from the Op. 20 | string name = 1; 21 | 22 | // A list of values that this kernel supports for this attr. 23 | // Like OpDef.AttrDef.allowed_values, except for kernels instead of Ops. 24 | AttrValue allowed_values = 2; 25 | } 26 | repeated AttrConstraint constraint = 3; 27 | 28 | // Names of the Op's input_/output_args that reside in host memory 29 | // instead of device memory. 30 | repeated string host_memory_arg = 4; 31 | 32 | // This allows experimental kernels to be registered for an op that 33 | // won't be used unless the user specifies a "_kernel" attr with 34 | // value matching this. 35 | string label = 5; 36 | } 37 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/framework/device_attributes.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "DeviceAttributesProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | message DeviceLocality { 10 | // Optional bus locality of device. Default value of 0 means 11 | // no specific locality. Specific localities are indexed from 1. 12 | int32 bus_id = 1; 13 | }; 14 | 15 | message DeviceAttributes { 16 | // Fully specified name of the device within a cluster. 17 | string name = 1; 18 | 19 | // String representation of device_type. 20 | string device_type = 2; 21 | 22 | // Memory capacity of device in bytes. 23 | int64 memory_limit = 4; 24 | 25 | // Platform-specific data about device that may be useful 26 | // for supporting efficient data transfers. 27 | DeviceLocality locality = 5; 28 | 29 | // A device is assigned a global unique number each time it is 30 | // initialized. "incarnation" should never be 0. 31 | fixed64 incarnation = 6; 32 | 33 | // String representation of the physical device that this device maps to. 34 | string physical_device_desc = 7; 35 | } 36 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/framework/kernel_def.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "KernelDefProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/attr_value.proto"; 10 | 11 | message KernelDef { 12 | // Must match the name of an Op. 13 | string op = 1; 14 | 15 | // Type of device this kernel runs on. 16 | string device_type = 2; 17 | 18 | message AttrConstraint { 19 | // Name of an attr from the Op. 20 | string name = 1; 21 | 22 | // A list of values that this kernel supports for this attr. 23 | // Like OpDef.AttrDef.allowed_values, except for kernels instead of Ops. 24 | AttrValue allowed_values = 2; 25 | } 26 | repeated AttrConstraint constraint = 3; 27 | 28 | // Names of the Op's input_/output_args that reside in host memory 29 | // instead of device memory. 30 | repeated string host_memory_arg = 4; 31 | 32 | // This allows experimental kernels to be registered for an op that 33 | // won't be used unless the user specifies a "_kernel" attr with 34 | // value matching this. 35 | string label = 5; 36 | } 37 | -------------------------------------------------------------------------------- /data/README.md: -------------------------------------------------------------------------------- 1 | ## Introduction 2 | 3 | This is the general tool to convert CSV file to TFRecords file. 4 | 5 | ## Cancer 6 | 7 | The example data in [cancer.csv](cancer.csv) looks like these. 8 | 9 | From [](https://github.com/mark-watson/cancer-deep-learning-model) 10 | 11 | ``` 12 | 3,7,7,4,4,9,4,8,1,1 13 | 1,1,1,1,2,1,2,1,1,0 14 | 4,1,1,3,2,1,3,1,1,0 15 | 7,8,7,2,4,8,3,8,2,1 16 | 9,5,8,1,2,3,2,1,5,1 17 | ``` 18 | 19 | The first 9th data are features and the last one is label. 20 | 21 | ``` 22 | - 0 Clump Thickness 1 - 10 23 | - 1 Uniformity of Cell Size 1 - 10 24 | - 2 Uniformity of Cell Shape 1 - 10 25 | - 3 Marginal Adhesion 1 - 10 26 | - 4 Single Epithelial Cell Size 1 - 10 27 | - 5 Bare Nuclei 1 - 10 28 | - 6 Bland Chromatin 1 - 10 29 | - 7 Normal Nucleoli 1 - 10 30 | - 8 Mitoses 1 - 10 31 | - 9 Class (0 for benign, 1 for malignant) 32 | ``` 33 | 34 | ## Usage 35 | 36 | Convert CSV file to TFRecords file with this script. 37 | 38 | ``` 39 | python convert_cancer_to_tfrecords.py 40 | ``` 41 | 42 | To verify the TFRecords, you can iterate and print each example with this script. 43 | 44 | ``` 45 | python print_cancer_tfrecords.py 46 | ``` 47 | -------------------------------------------------------------------------------- /data/a8a/print_libsvm_tfrecords.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import tensorflow as tf 4 | import os 5 | 6 | 7 | def print_tfrecords(input_filename): 8 | max_print_number = 100 9 | current_print_number = 0 10 | 11 | for serialized_example in tf.python_io.tf_record_iterator(input_filename): 12 | # Get serialized example from file 13 | example = tf.train.Example() 14 | example.ParseFromString(serialized_example) 15 | label = example.features.feature["label"].float_list.value 16 | ids = example.features.feature["ids"].int64_list.value 17 | values = example.features.feature["values"].float_list.value 18 | print("Number: {}, label: {}, features: {}".format( 19 | current_print_number, label, " ".join([str(id) + ":" + str( 20 | value) for id, value in zip(ids, values)]))) 21 | 22 | # Return when reaching max print number 23 | current_print_number += 1 24 | if current_print_number > max_print_number: 25 | exit() 26 | 27 | 28 | def main(): 29 | current_path = os.getcwd() 30 | tfrecords_file_name = "a8a_train.libsvm.tfrecords" 31 | input_filename = os.path.join(current_path, tfrecords_file_name) 32 | print_tfrecords(input_filename) 33 | 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/framework/device_attributes.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "DeviceAttributesProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | message DeviceLocality { 10 | // Optional bus locality of device. Default value of 0 means 11 | // no specific locality. Specific localities are indexed from 1. 12 | int32 bus_id = 1; 13 | }; 14 | 15 | message DeviceAttributes { 16 | // Fully specified name of the device within a cluster. 17 | string name = 1; 18 | 19 | // String representation of device_type. 20 | string device_type = 2; 21 | 22 | // Memory capacity of device in bytes. 23 | int64 memory_limit = 4; 24 | 25 | // Platform-specific data about device that may be useful 26 | // for supporting efficient data transfers. 27 | DeviceLocality locality = 5; 28 | 29 | // A device is assigned a global unique number each time it is 30 | // initialized. "incarnation" should never be 0. 31 | fixed64 incarnation = 6; 32 | 33 | // String representation of the physical device that this device maps to. 34 | string physical_device_desc = 7; 35 | } 36 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/framework/kernel_def.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "KernelDefProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/attr_value.proto"; 10 | 11 | message KernelDef { 12 | // Must match the name of an Op. 13 | string op = 1; 14 | 15 | // Type of device this kernel runs on. 16 | string device_type = 2; 17 | 18 | message AttrConstraint { 19 | // Name of an attr from the Op. 20 | string name = 1; 21 | 22 | // A list of values that this kernel supports for this attr. 23 | // Like OpDef.AttrDef.allowed_values, except for kernels instead of Ops. 24 | AttrValue allowed_values = 2; 25 | } 26 | repeated AttrConstraint constraint = 3; 27 | 28 | // Names of the Op's input_/output_args that reside in host memory 29 | // instead of device memory. 30 | repeated string host_memory_arg = 4; 31 | 32 | // This allows experimental kernels to be registered for an op that 33 | // won't be used unless the user specifies a "_kernel" attr with 34 | // value matching this. 35 | string label = 5; 36 | } 37 | -------------------------------------------------------------------------------- /data/iris/generate_csv_tfrecords.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import tensorflow as tf 4 | import os 5 | 6 | 7 | def generate_tfrecords(input_filename, output_filename): 8 | print("Start to convert {} to {}".format(input_filename, output_filename)) 9 | writer = tf.python_io.TFRecordWriter(output_filename) 10 | 11 | for line in open(input_filename, "r"): 12 | data = line.split(",") 13 | label = float(data[0]) 14 | features = [float(i) for i in data[1:]] 15 | 16 | example = tf.train.Example(features=tf.train.Features(feature={ 17 | "label": 18 | tf.train.Feature(float_list=tf.train.FloatList(value=[label])), 19 | "features": 20 | tf.train.Feature(float_list=tf.train.FloatList(value=features)), 21 | })) 22 | writer.write(example.SerializeToString()) 23 | 24 | writer.close() 25 | print("Successfully convert {} to {}".format(input_filename, 26 | output_filename)) 27 | 28 | 29 | def main(): 30 | current_path = os.getcwd() 31 | for filename in os.listdir(current_path): 32 | if filename.startswith("") and filename.endswith(".csv"): 33 | generate_tfrecords(filename, filename + ".tfrecords") 34 | 35 | 36 | if __name__ == "__main__": 37 | main() 38 | -------------------------------------------------------------------------------- /data/lung/generate_csv_tfrecords.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import tensorflow as tf 4 | import os 5 | 6 | 7 | def generate_tfrecords(input_filename, output_filename): 8 | print("Start to convert {} to {}".format(input_filename, output_filename)) 9 | writer = tf.python_io.TFRecordWriter(output_filename) 10 | 11 | for line in open(input_filename, "r"): 12 | data = line.split(",") 13 | label = float(data[0]) 14 | features = [float(i) for i in data[1:]] 15 | 16 | example = tf.train.Example(features=tf.train.Features(feature={ 17 | "label": 18 | tf.train.Feature(float_list=tf.train.FloatList(value=[label])), 19 | "features": 20 | tf.train.Feature(float_list=tf.train.FloatList(value=features)), 21 | })) 22 | writer.write(example.SerializeToString()) 23 | 24 | writer.close() 25 | print("Successfully convert {} to {}".format(input_filename, 26 | output_filename)) 27 | 28 | 29 | def main(): 30 | current_path = os.getcwd() 31 | for filename in os.listdir(current_path): 32 | if filename.startswith("") and filename.endswith(".csv"): 33 | generate_tfrecords(filename, filename + ".tfrecords") 34 | 35 | 36 | if __name__ == "__main__": 37 | main() 38 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/framework/device_attributes.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "DeviceAttributesProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | message DeviceLocality { 10 | // Optional bus locality of device. Default value of 0 means 11 | // no specific locality. Specific localities are indexed from 1. 12 | int32 bus_id = 1; 13 | }; 14 | 15 | message DeviceAttributes { 16 | // Fully specified name of the device within a cluster. 17 | string name = 1; 18 | 19 | // String representation of device_type. 20 | string device_type = 2; 21 | 22 | // Memory capacity of device in bytes. 23 | int64 memory_limit = 4; 24 | 25 | // Platform-specific data about device that may be useful 26 | // for supporting efficient data transfers. 27 | DeviceLocality locality = 5; 28 | 29 | // A device is assigned a global unique number each time it is 30 | // initialized. "incarnation" should never be 0. 31 | fixed64 incarnation = 6; 32 | 33 | // String representation of the physical device that this device maps to. 34 | string physical_device_desc = 7; 35 | } 36 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/framework/kernel_def.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "KernelDefProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/attr_value.proto"; 10 | 11 | message KernelDef { 12 | // Must match the name of an Op. 13 | string op = 1; 14 | 15 | // Type of device this kernel runs on. 16 | string device_type = 2; 17 | 18 | message AttrConstraint { 19 | // Name of an attr from the Op. 20 | string name = 1; 21 | 22 | // A list of values that this kernel supports for this attr. 23 | // Like OpDef.AttrDef.allowed_values, except for kernels instead of Ops. 24 | AttrValue allowed_values = 2; 25 | } 26 | repeated AttrConstraint constraint = 3; 27 | 28 | // Names of the Op's input_/output_args that reside in host memory 29 | // instead of device memory. 30 | repeated string host_memory_arg = 4; 31 | 32 | // This allows experimental kernels to be registered for an op that 33 | // won't be used unless the user specifies a "_kernel" attr with 34 | // value matching this. 35 | string label = 5; 36 | } 37 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/example/example_parser_configuration.proto: -------------------------------------------------------------------------------- 1 | // Protocol messages for describing the configuration of the ExampleParserOp. 2 | 3 | syntax = "proto3"; 4 | 5 | option cc_enable_arenas = true; 6 | option java_outer_classname = "ExampleParserConfigurationProtos"; 7 | option java_multiple_files = true; 8 | option java_package = "org.tensorflow.example"; 9 | package tensorflow; 10 | 11 | import "tensorflow/core/framework/tensor_shape.proto"; 12 | import "tensorflow/core/framework/tensor.proto"; 13 | import "tensorflow/core/framework/types.proto"; 14 | 15 | message VarLenFeatureProto { 16 | tensorflow.DataType dtype = 1; 17 | string values_output_tensor_name = 2; 18 | string indices_output_tensor_name = 3; 19 | string shapes_output_tensor_name = 4; 20 | }; 21 | 22 | message FixedLenFeatureProto { 23 | tensorflow.DataType dtype = 1; 24 | tensorflow.TensorShapeProto shape = 2; 25 | tensorflow.TensorProto default_value = 3; 26 | string values_output_tensor_name = 4; 27 | }; 28 | 29 | message FeatureConfiguration { 30 | oneof config { 31 | FixedLenFeatureProto fixed_len_feature = 1; 32 | VarLenFeatureProto var_len_feature = 2; 33 | } 34 | }; 35 | 36 | message ExampleParserConfiguration { 37 | map feature_map = 1; 38 | }; 39 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/example/example_parser_configuration.proto: -------------------------------------------------------------------------------- 1 | // Protocol messages for describing the configuration of the ExampleParserOp. 2 | 3 | syntax = "proto3"; 4 | 5 | option cc_enable_arenas = true; 6 | option java_outer_classname = "ExampleParserConfigurationProtos"; 7 | option java_multiple_files = true; 8 | option java_package = "org.tensorflow.example"; 9 | package tensorflow; 10 | 11 | import "tensorflow/core/framework/tensor_shape.proto"; 12 | import "tensorflow/core/framework/tensor.proto"; 13 | import "tensorflow/core/framework/types.proto"; 14 | 15 | message VarLenFeatureProto { 16 | tensorflow.DataType dtype = 1; 17 | string values_output_tensor_name = 2; 18 | string indices_output_tensor_name = 3; 19 | string shapes_output_tensor_name = 4; 20 | }; 21 | 22 | message FixedLenFeatureProto { 23 | tensorflow.DataType dtype = 1; 24 | tensorflow.TensorShapeProto shape = 2; 25 | tensorflow.TensorProto default_value = 3; 26 | string values_output_tensor_name = 4; 27 | }; 28 | 29 | message FeatureConfiguration { 30 | oneof config { 31 | FixedLenFeatureProto fixed_len_feature = 1; 32 | VarLenFeatureProto var_len_feature = 2; 33 | } 34 | }; 35 | 36 | message ExampleParserConfiguration { 37 | map feature_map = 1; 38 | }; 39 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/example/example_parser_configuration.proto: -------------------------------------------------------------------------------- 1 | // Protocol messages for describing the configuration of the ExampleParserOp. 2 | 3 | syntax = "proto3"; 4 | 5 | option cc_enable_arenas = true; 6 | option java_outer_classname = "ExampleParserConfigurationProtos"; 7 | option java_multiple_files = true; 8 | option java_package = "org.tensorflow.example"; 9 | package tensorflow; 10 | 11 | import "tensorflow/core/framework/tensor_shape.proto"; 12 | import "tensorflow/core/framework/tensor.proto"; 13 | import "tensorflow/core/framework/types.proto"; 14 | 15 | message VarLenFeatureProto { 16 | tensorflow.DataType dtype = 1; 17 | string values_output_tensor_name = 2; 18 | string indices_output_tensor_name = 3; 19 | string shapes_output_tensor_name = 4; 20 | }; 21 | 22 | message FixedLenFeatureProto { 23 | tensorflow.DataType dtype = 1; 24 | tensorflow.TensorShapeProto shape = 2; 25 | tensorflow.TensorProto default_value = 3; 26 | string values_output_tensor_name = 4; 27 | }; 28 | 29 | message FeatureConfiguration { 30 | oneof config { 31 | FixedLenFeatureProto fixed_len_feature = 1; 32 | VarLenFeatureProto var_len_feature = 2; 33 | } 34 | }; 35 | 36 | message ExampleParserConfiguration { 37 | map feature_map = 1; 38 | }; 39 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/example/example_parser_configuration.proto: -------------------------------------------------------------------------------- 1 | // Protocol messages for describing the configuration of the ExampleParserOp. 2 | 3 | syntax = "proto3"; 4 | 5 | option cc_enable_arenas = true; 6 | option java_outer_classname = "ExampleParserConfigurationProtos"; 7 | option java_multiple_files = true; 8 | option java_package = "org.tensorflow.example"; 9 | package tensorflow; 10 | 11 | import "tensorflow/core/framework/tensor_shape.proto"; 12 | import "tensorflow/core/framework/tensor.proto"; 13 | import "tensorflow/core/framework/types.proto"; 14 | 15 | message VarLenFeatureProto { 16 | tensorflow.DataType dtype = 1; 17 | string values_output_tensor_name = 2; 18 | string indices_output_tensor_name = 3; 19 | string shapes_output_tensor_name = 4; 20 | }; 21 | 22 | message FixedLenFeatureProto { 23 | tensorflow.DataType dtype = 1; 24 | tensorflow.TensorShapeProto shape = 2; 25 | tensorflow.TensorProto default_value = 3; 26 | string values_output_tensor_name = 4; 27 | }; 28 | 29 | message FeatureConfiguration { 30 | oneof config { 31 | FixedLenFeatureProto fixed_len_feature = 1; 32 | VarLenFeatureProto var_len_feature = 2; 33 | } 34 | }; 35 | 36 | message ExampleParserConfiguration { 37 | map feature_map = 1; 38 | }; 39 | -------------------------------------------------------------------------------- /distributed/README.md: -------------------------------------------------------------------------------- 1 | ## Introduction 2 | 3 | It's the distributed version of `dense_classifier.py` which runs in distributed TensorFlow cluster. 4 | 5 | All the weights of the model are stored in ps cluster. The ps should use CPUs only and the worker can be accelerated with GPUs which are controlled by `CUDA_VISIBLE_DEVICES`. It reads data from `TFRecords` files and use `tf.train.Supervisor` to manage checkpoint and summary files. It implements the two layer's neural network and feel free to extend to complicated models. 6 | 7 | ## Usage 8 | 9 | If you're using GPUs, please specify `CUDA_VISIBLE_DEVICES` for ps and worker. 10 | 11 | ``` 12 | CUDA_VISIBLE_DEVICES='' python dense_classifier.py --ps_hosts=127.0.0.1:2222,127.0.0.1:2223 --worker_hosts=127.0.0.1:2224,127.0.0.1:2225 --job_name=ps --task_index=0 13 | 14 | CUDA_VISIBLE_DEVICES='' python dense_classifier.py --ps_hosts=127.0.0.1:2222,127.0.0.1:2223 --worker_hosts=127.0.0.1:2224,127.0.0.1:2225 --job_name=ps --task_index=1 15 | 16 | CUDA_VISIBLE_DEVICES='0' python dense_classifier.py --ps_hosts=127.0.0.1:2222,127.0.0.1:2223 --worker_hosts=127.0.0.1:2224,127.0.0.1:2225 --job_name=worker --task_index=0 17 | 18 | CUDA_VISIBLE_DEVICES='1' python dense_classifier.py --ps_hosts=127.0.0.1:2222,127.0.0.1:2223 --worker_hosts=127.0.0.1:2224,127.0.0.1:2225 --job_name=worker --task_index=1 19 | ``` 20 | -------------------------------------------------------------------------------- /android_client/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "com.tobe.androidclient" 7 | minSdkVersion 23 8 | targetSdkVersion 26 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | externalNativeBuild { 13 | cmake { 14 | cppFlags "" 15 | } 16 | } 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | externalNativeBuild { 25 | cmake { 26 | path "CMakeLists.txt" 27 | } 28 | } 29 | } 30 | 31 | dependencies { 32 | implementation fileTree(dir: 'libs', include: ['*.jar']) 33 | implementation 'com.android.support:appcompat-v7:26.1.0' 34 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 35 | testImplementation 'junit:junit:4.12' 36 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 37 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 38 | 39 | 40 | compile 'org.tensorflow:tensorflow-android:+' 41 | } 42 | -------------------------------------------------------------------------------- /data/boston_housing/generate_csv_tfrecords.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import tensorflow as tf 4 | import os 5 | 6 | 7 | def generate_tfrecords(input_filename, output_filename): 8 | print("Start to convert {} to {}".format(input_filename, output_filename)) 9 | writer = tf.python_io.TFRecordWriter(output_filename) 10 | 11 | index = 0 12 | for line in open(input_filename, "r"): 13 | index += 1 14 | 15 | # Ignore the first line 16 | if index == 1: 17 | continue 18 | 19 | data = line.split(",") 20 | label = float(data[14]) 21 | features = [float(i) for i in data[1:14]] 22 | 23 | example = tf.train.Example(features=tf.train.Features( 24 | feature={ 25 | "label": 26 | tf.train.Feature(float_list=tf.train.FloatList(value=[label])), 27 | "features": 28 | tf.train.Feature(float_list=tf.train.FloatList(value=features)), 29 | })) 30 | writer.write(example.SerializeToString()) 31 | 32 | writer.close() 33 | print( 34 | "Successfully convert {} to {}".format(input_filename, output_filename)) 35 | 36 | 37 | def main(): 38 | current_path = os.getcwd() 39 | for filename in os.listdir(current_path): 40 | if filename.startswith("") and filename.endswith(".csv"): 41 | generate_tfrecords(filename, filename + ".tfrecords") 42 | 43 | 44 | if __name__ == "__main__": 45 | main() 46 | -------------------------------------------------------------------------------- /data/iris/download_iris.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import numpy as np 4 | import random 5 | from sklearn import datasets 6 | 7 | 8 | def main(): 9 | # Load data set 10 | print("Download the iris dataset") 11 | iris = datasets.load_iris() 12 | 13 | # Split into train and test 14 | TRAIN_FILE_NAME = "iris_train.csv" 15 | TEST_FILE_NAME = "iris_test.csv" 16 | file_content_array = [] 17 | train_file_content = "" 18 | test_file_content = "" 19 | total_number = len(iris.data) 20 | train_number = int(total_number * 0.9) 21 | test_number = total_number - train_number 22 | 23 | # Generate text content 24 | for i in range(total_number): 25 | line_content = str(iris.target[i]) + "," 26 | for j in iris.data[i]: 27 | line_content += str(j) + "," 28 | file_content_array.append(line_content[:-1] + "\n") 29 | 30 | random.shuffle(file_content_array) 31 | for i in file_content_array[:train_number]: 32 | train_file_content += i 33 | for i in file_content_array[train_number:]: 34 | test_file_content += i 35 | 36 | # Write into files 37 | print("Write content into files: {} and {}".format(TRAIN_FILE_NAME, 38 | TEST_FILE_NAME)) 39 | with open(TRAIN_FILE_NAME, "w") as f: 40 | f.write(train_file_content) 41 | with open(TEST_FILE_NAME, "w") as f: 42 | f.write(test_file_content) 43 | 44 | 45 | if __name__ == "__main__": 46 | main() 47 | -------------------------------------------------------------------------------- /data/cancer/generate_tfrecords_from_csv.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | 4 | from __future__ import absolute_import 5 | from __future__ import division 6 | from __future__ import print_function 7 | 8 | import os 9 | import tensorflow as tf 10 | 11 | 12 | def generate_tfrecords_file(input_filename, output_filename): 13 | print("Start to convert {} to {}".format(input_filename, output_filename)) 14 | 15 | writer = tf.python_io.TFRecordWriter(output_filename) 16 | 17 | for line in open(input_filename, "r"): 18 | data = line.split(",") 19 | label = int(data[-1]) 20 | features = [float(i) for i in data[:-1]] 21 | 22 | example = tf.train.Example(features=tf.train.Features( 23 | feature={ 24 | "label": 25 | tf.train.Feature(int64_list=tf.train.Int64List(value=[label])), 26 | "features": 27 | tf.train.Feature(float_list=tf.train.FloatList(value=features)), 28 | })) 29 | writer.write(example.SerializeToString()) 30 | 31 | writer.close() 32 | 33 | print( 34 | "Successfully convert {} to {}".format(input_filename, output_filename)) 35 | 36 | 37 | def main(): 38 | current_path = os.getcwd() 39 | for filename in os.listdir(current_path): 40 | if filename.startswith("") and filename.endswith(".csv"): 41 | generate_tfrecords_file(filename, filename + ".tfrecords") 42 | 43 | 44 | if __name__ == "__main__": 45 | main() 46 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/framework/tensor_slice.proto: -------------------------------------------------------------------------------- 1 | // Protocol buffer representing slices of a tensor 2 | 3 | syntax = "proto3"; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "TensorSliceProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | package tensorflow; 10 | 11 | // Can only be interpreted if you know the corresponding TensorShape. 12 | message TensorSliceProto { 13 | // Extent of the slice in one dimension. 14 | message Extent { 15 | // Either both or no attributes must be set. When no attribute is set 16 | // means: All data in that dimension. 17 | 18 | // Start index of the slice, starting at 0. 19 | int64 start = 1; 20 | 21 | // Length of the slice: if the length is missing or -1 we will 22 | // interpret this as "everything in this dimension". We use 23 | // "oneof" to preserve information about whether the length is 24 | // present without changing the serialization format from the 25 | // prior proto2 version of this proto. 26 | oneof has_length { 27 | int64 length = 2; 28 | } 29 | }; 30 | 31 | // Extent of the slice in all tensor dimensions. 32 | // 33 | // Must have one entry for each of the dimension of the tensor that this 34 | // slice belongs to. The order of sizes is the same as the order of 35 | // dimensions in the TensorShape. 36 | repeated Extent extent = 1; 37 | }; 38 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/framework/tensor_slice.proto: -------------------------------------------------------------------------------- 1 | // Protocol buffer representing slices of a tensor 2 | 3 | syntax = "proto3"; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "TensorSliceProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | package tensorflow; 10 | 11 | // Can only be interpreted if you know the corresponding TensorShape. 12 | message TensorSliceProto { 13 | // Extent of the slice in one dimension. 14 | message Extent { 15 | // Either both or no attributes must be set. When no attribute is set 16 | // means: All data in that dimension. 17 | 18 | // Start index of the slice, starting at 0. 19 | int64 start = 1; 20 | 21 | // Length of the slice: if the length is missing or -1 we will 22 | // interpret this as "everything in this dimension". We use 23 | // "oneof" to preserve information about whether the length is 24 | // present without changing the serialization format from the 25 | // prior proto2 version of this proto. 26 | oneof has_length { 27 | int64 length = 2; 28 | } 29 | }; 30 | 31 | // Extent of the slice in all tensor dimensions. 32 | // 33 | // Must have one entry for each of the dimension of the tensor that this 34 | // slice belongs to. The order of sizes is the same as the order of 35 | // dimensions in the TensorShape. 36 | repeated Extent extent = 1; 37 | }; 38 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/framework/tensor_slice.proto: -------------------------------------------------------------------------------- 1 | // Protocol buffer representing slices of a tensor 2 | 3 | syntax = "proto3"; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "TensorSliceProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | package tensorflow; 10 | 11 | // Can only be interpreted if you know the corresponding TensorShape. 12 | message TensorSliceProto { 13 | // Extent of the slice in one dimension. 14 | message Extent { 15 | // Either both or no attributes must be set. When no attribute is set 16 | // means: All data in that dimension. 17 | 18 | // Start index of the slice, starting at 0. 19 | int64 start = 1; 20 | 21 | // Length of the slice: if the length is missing or -1 we will 22 | // interpret this as "everything in this dimension". We use 23 | // "oneof" to preserve information about whether the length is 24 | // present without changing the serialization format from the 25 | // prior proto2 version of this proto. 26 | oneof has_length { 27 | int64 length = 2; 28 | } 29 | }; 30 | 31 | // Extent of the slice in all tensor dimensions. 32 | // 33 | // Must have one entry for each of the dimension of the tensor that this 34 | // slice belongs to. The order of sizes is the same as the order of 35 | // dimensions in the TensorShape. 36 | repeated Extent extent = 1; 37 | }; 38 | -------------------------------------------------------------------------------- /data/cancer/print_tfrecords_files.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | 4 | from __future__ import absolute_import 5 | from __future__ import division 6 | from __future__ import print_function 7 | 8 | import os 9 | import tensorflow as tf 10 | 11 | 12 | def print_tfrecords_file(input_filename): 13 | print("Try to print the tfrecords file: {}".format(input_filename)) 14 | 15 | max_print_number = 10 16 | current_print_index = 0 17 | 18 | for serialized_example in tf.python_io.tf_record_iterator(input_filename): 19 | # Get serialized example from file 20 | example = tf.train.Example() 21 | example.ParseFromString(serialized_example) 22 | label = example.features.feature["label"].int64_list.value 23 | features = example.features.feature["features"].float_list.value 24 | print("Index: {}, label: {}, features: {}".format(current_print_index, 25 | label, features)) 26 | 27 | # Return when reaching max print number 28 | current_print_index += 1 29 | if current_print_index > max_print_number - 1: 30 | return 31 | 32 | 33 | def main(): 34 | current_path = os.getcwd() 35 | for filename in os.listdir(current_path): 36 | if filename.startswith("") and filename.endswith(".tfrecords"): 37 | tfrecords_file_path = os.path.join(current_path, filename) 38 | print_tfrecords_file(tfrecords_file_path) 39 | 40 | 41 | if __name__ == "__main__": 42 | main() 43 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/framework/tensor_slice.proto: -------------------------------------------------------------------------------- 1 | // Protocol buffer representing slices of a tensor 2 | 3 | syntax = "proto3"; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "TensorSliceProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | package tensorflow; 10 | 11 | // Can only be interpreted if you know the corresponding TensorShape. 12 | message TensorSliceProto { 13 | // Extent of the slice in one dimension. 14 | message Extent { 15 | // Either both or no attributes must be set. When no attribute is set 16 | // means: All data in that dimension. 17 | 18 | // Start index of the slice, starting at 0. 19 | int64 start = 1; 20 | 21 | // Length of the slice: if the length is missing or -1 we will 22 | // interpret this as "everything in this dimension". We use 23 | // "oneof" to preserve information about whether the length is 24 | // present without changing the serialization format from the 25 | // prior proto2 version of this proto. 26 | oneof has_length { 27 | int64 length = 2; 28 | } 29 | }; 30 | 31 | // Extent of the slice in all tensor dimensions. 32 | // 33 | // Must have one entry for each of the dimension of the tensor that this 34 | // slice belongs to. The order of sizes is the same as the order of 35 | // dimensions in the TensorShape. 36 | repeated Extent extent = 1; 37 | }; 38 | -------------------------------------------------------------------------------- /data/a8a/generate_libsvm_tfrecord.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import tensorflow as tf 4 | import os 5 | 6 | 7 | def generate_tfrecords(input_filename, output_filename): 8 | print("Start to convert {} to {}".format(input_filename, output_filename)) 9 | writer = tf.python_io.TFRecordWriter(output_filename) 10 | 11 | for line in open(input_filename, "r"): 12 | data = line.split(" ") 13 | label = float(data[0]) 14 | ids = [] 15 | values = [] 16 | for fea in data[1:]: 17 | id, value = fea.split(":") 18 | ids.append(int(id)) 19 | values.append(float(value)) 20 | 21 | # Write each example one by one 22 | example = tf.train.Example(features=tf.train.Features(feature={ 23 | "label": 24 | tf.train.Feature(float_list=tf.train.FloatList(value=[label])), 25 | "ids": tf.train.Feature(int64_list=tf.train.Int64List(value=ids)), 26 | "values": tf.train.Feature(float_list=tf.train.FloatList(value=values)) 27 | })) 28 | 29 | writer.write(example.SerializeToString()) 30 | 31 | writer.close() 32 | print("Successfully convert {} to {}".format(input_filename, 33 | output_filename)) 34 | 35 | 36 | def main(): 37 | current_path = os.getcwd() 38 | for filename in os.listdir(current_path): 39 | if filename.startswith("") and filename.endswith(".libsvm"): 40 | generate_tfrecords(filename, filename + ".tfrecords") 41 | 42 | 43 | if __name__ == "__main__": 44 | main() 45 | -------------------------------------------------------------------------------- /data/lung/convert_dcm_to_csv.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from pydicom import dicomio 4 | import numpy as np 5 | 6 | 7 | def main(): 8 | # Read label file 9 | label_filename = "./raw_data/stage1_labels.csv" 10 | id_label_map = {} 11 | for i in open(label_filename, "r"): 12 | if i.startswith("id,cancer"): 13 | continue 14 | id_label_pair = i.split(",") 15 | id_label_map[id_label_pair[0]] = int(id_label_pair[1].rstrip()) 16 | 17 | # Read dcm file 18 | input_filename = "fa7a21165ae152b13def786e6afc3edf.dcm" 19 | output_filename = input_filename + ".csv" 20 | convert_dcm_to_csv(id_label_map, input_filename, output_filename) 21 | 22 | 23 | def convert_dcm_to_csv(id_label_map, input_filename, output_filename): 24 | print("Start to convert dcm: {} to csv: {}".format(input_filename, 25 | output_filename)) 26 | 27 | ds = dicomio.read_file(input_filename) 28 | image_ndarray = ds.pixel_array 29 | label = id_label_map[ds.PatientID] 30 | csv_content = "{},".format(label) 31 | 32 | # Example: 512 * 512 33 | for i in image_ndarray: 34 | for j in i: 35 | csv_content += "{},".format(j) 36 | csv_content = csv_content[:-1] + "\n" 37 | 38 | with open(output_filename, "w") as f: 39 | f.write(csv_content) 40 | 41 | print("Successfully convert dcm: {} to csv: {}".format(input_filename, 42 | output_filename)) 43 | 44 | 45 | if __name__ == "__main__": 46 | main() 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.swp 3 | *~ 4 | checkpoint/* 5 | tensorboard/* 6 | 7 | # Byte-compiled / optimized / DLL files 8 | __pycache__/ 9 | *.py[cod] 10 | *$py.class 11 | 12 | # C extensions 13 | *.so 14 | 15 | # Distribution / packaging 16 | .Python 17 | env/ 18 | build/ 19 | develop-eggs/ 20 | dist/ 21 | downloads/ 22 | eggs/ 23 | .eggs/ 24 | lib/ 25 | lib64/ 26 | parts/ 27 | sdist/ 28 | var/ 29 | *.egg-info/ 30 | .installed.cfg 31 | *.egg 32 | 33 | # PyInstaller 34 | # Usually these files are written by a python script from a template 35 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 36 | *.manifest 37 | *.spec 38 | 39 | # Installer logs 40 | pip-log.txt 41 | pip-delete-this-directory.txt 42 | 43 | # Unit test / coverage reports 44 | htmlcov/ 45 | .tox/ 46 | .coverage 47 | .coverage.* 48 | .cache 49 | nosetests.xml 50 | coverage.xml 51 | *,cover 52 | .hypothesis/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | 62 | # Flask stuff: 63 | instance/ 64 | .webassets-cache 65 | 66 | # Scrapy stuff: 67 | .scrapy 68 | 69 | # Sphinx documentation 70 | docs/_build/ 71 | 72 | # PyBuilder 73 | target/ 74 | 75 | # IPython Notebook 76 | .ipynb_checkpoints 77 | 78 | # pyenv 79 | .python-version 80 | 81 | # celery beat schedule file 82 | celerybeat-schedule 83 | 84 | # dotenv 85 | .env 86 | 87 | # virtualenv 88 | venv/ 89 | ENV/ 90 | 91 | # Spyder project settings 92 | .spyderproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # IDEA 98 | .idea/ 99 | -------------------------------------------------------------------------------- /data/a8a/print_tfrecords_files.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | 4 | from __future__ import absolute_import 5 | from __future__ import division 6 | from __future__ import print_function 7 | 8 | import os 9 | import tensorflow as tf 10 | 11 | 12 | def print_tfrecords_file(input_filename): 13 | print("Try to print the tfrecords file: {}".format(input_filename)) 14 | 15 | max_print_number = 10 16 | current_print_index = 0 17 | 18 | for serialized_example in tf.python_io.tf_record_iterator(input_filename): 19 | # Get serialized example from file 20 | example = tf.train.Example() 21 | example.ParseFromString(serialized_example) 22 | label = example.features.feature["label"].int64_list.value 23 | ids = example.features.feature["ids"].int64_list.value 24 | values = example.features.feature["values"].float_list.value 25 | print("Index: {}, label: {}, features: {}".format( 26 | current_print_index, label, " ".join( 27 | [str(id) + ":" + str(value) for id, value in zip(ids, values)]))) 28 | 29 | # Return when reaching max print number 30 | current_print_index += 1 31 | if current_print_index > max_print_number - 1: 32 | return 33 | 34 | 35 | def main(): 36 | current_path = os.getcwd() 37 | for filename in os.listdir(current_path): 38 | if filename.startswith("") and filename.endswith(".tfrecords"): 39 | tfrecords_file_path = os.path.join(current_path, filename) 40 | print_tfrecords_file(tfrecords_file_path) 41 | 42 | 43 | if __name__ == "__main__": 44 | main() 45 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/predict.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow.serving; 4 | option cc_enable_arenas = true; 5 | 6 | import "tensorflow/core/framework/tensor.proto"; 7 | import "model.proto"; 8 | 9 | // PredictRequest specifies which TensorFlow model to run, as well as 10 | // how inputs are mapped to tensors and how outputs are filtered before 11 | // returning to user. 12 | message PredictRequest { 13 | // Model Specification. 14 | ModelSpec model_spec = 1; 15 | 16 | // Input tensors. 17 | // Names of input tensor are alias names. The mapping from aliases to real 18 | // input tensor names is expected to be stored as named generic signature 19 | // under the key "inputs" in the model export. 20 | // Each alias listed in a generic signature named "inputs" should be provided 21 | // exactly once in order to run the prediction. 22 | map inputs = 2; 23 | 24 | // Output filter. 25 | // Names specified are alias names. The mapping from aliases to real output 26 | // tensor names is expected to be stored as named generic signature under 27 | // the key "outputs" in the model export. 28 | // Only tensors specified here will be run/fetched and returned, with the 29 | // exception that when none is specified, all tensors specified in the 30 | // named signature will be run/fetched and returned. 31 | repeated string output_filter = 3; 32 | } 33 | 34 | // Response for PredictRequest on successful run. 35 | message PredictResponse { 36 | // Output tensors. 37 | map outputs = 1; 38 | } 39 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/predict.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow.serving; 4 | option cc_enable_arenas = true; 5 | 6 | import "tensorflow/core/framework/tensor.proto"; 7 | import "model.proto"; 8 | 9 | // PredictRequest specifies which TensorFlow model to run, as well as 10 | // how inputs are mapped to tensors and how outputs are filtered before 11 | // returning to user. 12 | message PredictRequest { 13 | // Model Specification. 14 | ModelSpec model_spec = 1; 15 | 16 | // Input tensors. 17 | // Names of input tensor are alias names. The mapping from aliases to real 18 | // input tensor names is expected to be stored as named generic signature 19 | // under the key "inputs" in the model export. 20 | // Each alias listed in a generic signature named "inputs" should be provided 21 | // exactly once in order to run the prediction. 22 | map inputs = 2; 23 | 24 | // Output filter. 25 | // Names specified are alias names. The mapping from aliases to real output 26 | // tensor names is expected to be stored as named generic signature under 27 | // the key "outputs" in the model export. 28 | // Only tensors specified here will be run/fetched and returned, with the 29 | // exception that when none is specified, all tensors specified in the 30 | // named signature will be run/fetched and returned. 31 | repeated string output_filter = 3; 32 | } 33 | 34 | // Response for PredictRequest on successful run. 35 | message PredictResponse { 36 | // Output tensors. 37 | map outputs = 1; 38 | } 39 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/predict.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow.serving; 4 | option cc_enable_arenas = true; 5 | 6 | import "tensorflow/core/framework/tensor.proto"; 7 | import "model.proto"; 8 | 9 | // PredictRequest specifies which TensorFlow model to run, as well as 10 | // how inputs are mapped to tensors and how outputs are filtered before 11 | // returning to user. 12 | message PredictRequest { 13 | // Model Specification. 14 | ModelSpec model_spec = 1; 15 | 16 | // Input tensors. 17 | // Names of input tensor are alias names. The mapping from aliases to real 18 | // input tensor names is expected to be stored as named generic signature 19 | // under the key "inputs" in the model export. 20 | // Each alias listed in a generic signature named "inputs" should be provided 21 | // exactly once in order to run the prediction. 22 | map inputs = 2; 23 | 24 | // Output filter. 25 | // Names specified are alias names. The mapping from aliases to real output 26 | // tensor names is expected to be stored as named generic signature under 27 | // the key "outputs" in the model export. 28 | // Only tensors specified here will be run/fetched and returned, with the 29 | // exception that when none is specified, all tensors specified in the 30 | // named signature will be run/fetched and returned. 31 | repeated string output_filter = 3; 32 | } 33 | 34 | // Response for PredictRequest on successful run. 35 | message PredictResponse { 36 | // Output tensors. 37 | map outputs = 1; 38 | } 39 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/predict.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow.serving; 4 | option cc_enable_arenas = true; 5 | 6 | import "tensorflow/core/framework/tensor.proto"; 7 | import "model.proto"; 8 | 9 | // PredictRequest specifies which TensorFlow model to run, as well as 10 | // how inputs are mapped to tensors and how outputs are filtered before 11 | // returning to user. 12 | message PredictRequest { 13 | // Model Specification. 14 | ModelSpec model_spec = 1; 15 | 16 | // Input tensors. 17 | // Names of input tensor are alias names. The mapping from aliases to real 18 | // input tensor names is expected to be stored as named generic signature 19 | // under the key "inputs" in the model export. 20 | // Each alias listed in a generic signature named "inputs" should be provided 21 | // exactly once in order to run the prediction. 22 | map inputs = 2; 23 | 24 | // Output filter. 25 | // Names specified are alias names. The mapping from aliases to real output 26 | // tensor names is expected to be stored as named generic signature under 27 | // the key "outputs" in the model export. 28 | // Only tensors specified here will be run/fetched and returned, with the 29 | // exception that when none is specified, all tensors specified in the 30 | // named signature will be run/fetched and returned. 31 | repeated string output_filter = 3; 32 | } 33 | 34 | // Response for PredictRequest on successful run. 35 | message PredictResponse { 36 | // Output tensors. 37 | map outputs = 1; 38 | } 39 | -------------------------------------------------------------------------------- /minimal_model/python_predict_client/predict_client.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import numpy 4 | 5 | from grpc.beta import implementations 6 | import tensorflow as tf 7 | 8 | import predict_pb2 9 | import prediction_service_pb2 10 | 11 | tf.app.flags.DEFINE_string("host", "127.0.0.1", "gRPC server host") 12 | tf.app.flags.DEFINE_integer("port", 9000, "gRPC server port") 13 | tf.app.flags.DEFINE_string("model_name", "cancer", "TensorFlow model name") 14 | tf.app.flags.DEFINE_integer("model_version", 1, "TensorFlow model version") 15 | tf.app.flags.DEFINE_float("request_timeout", 10.0, "Timeout of gRPC request") 16 | FLAGS = tf.app.flags.FLAGS 17 | 18 | 19 | def main(): 20 | host = FLAGS.host 21 | port = FLAGS.port 22 | model_name = FLAGS.model_name 23 | model_version = FLAGS.model_version 24 | request_timeout = FLAGS.request_timeout 25 | 26 | # Generate inference data 27 | features = numpy.asarray( 28 | [1, 2, 3, 4, 5, 6, 7, 8, 9]) 29 | features_tensor_proto = tf.contrib.util.make_tensor_proto(features, 30 | dtype=tf.float32) 31 | 32 | # Create gRPC client and request 33 | channel = implementations.insecure_channel(host, port) 34 | stub = prediction_service_pb2.beta_create_PredictionService_stub(channel) 35 | request = predict_pb2.PredictRequest() 36 | request.model_spec.name = model_name 37 | request.model_spec.version.value = model_version 38 | request.inputs['features'].CopyFrom(features_tensor_proto) 39 | 40 | # Send request 41 | result = stub.Predict(request, request_timeout) 42 | print(result) 43 | 44 | 45 | if __name__ == '__main__': 46 | main() 47 | -------------------------------------------------------------------------------- /data/a8a/generate_tfrecords_from_libsvm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- encoding: utf-8 -*- 3 | 4 | from __future__ import absolute_import 5 | from __future__ import division 6 | from __future__ import print_function 7 | 8 | import os 9 | import tensorflow as tf 10 | 11 | 12 | def generate_tfrecords(input_filename, output_filename): 13 | print("Start to convert {} to {}".format(input_filename, output_filename)) 14 | 15 | writer = tf.python_io.TFRecordWriter(output_filename) 16 | 17 | for line in open(input_filename, "r"): 18 | data = line.split(" ") 19 | label = int(data[0]) 20 | ids = [] 21 | values = [] 22 | for fea in data[1:]: 23 | id, value = fea.split(":") 24 | ids.append(int(id)) 25 | values.append(float(value)) 26 | 27 | # Write each example one by one 28 | example = tf.train.Example(features=tf.train.Features( 29 | feature={ 30 | "label": 31 | tf.train.Feature(int64_list=tf.train.Int64List(value=[label])), 32 | "ids": 33 | tf.train.Feature(int64_list=tf.train.Int64List(value=ids)), 34 | "values": 35 | tf.train.Feature(float_list=tf.train.FloatList(value=values)) 36 | })) 37 | 38 | writer.write(example.SerializeToString()) 39 | 40 | writer.close() 41 | print( 42 | "Successfully convert {} to {}".format(input_filename, output_filename)) 43 | 44 | 45 | def main(): 46 | current_path = os.getcwd() 47 | for filename in os.listdir(current_path): 48 | if filename.startswith("") and filename.endswith(".libsvm"): 49 | generate_tfrecords(filename, filename + ".tfrecords") 50 | 51 | 52 | if __name__ == "__main__": 53 | main() 54 | -------------------------------------------------------------------------------- /ios_client/AppDelegate.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #import "AppDelegate.h" 16 | 17 | #import "RunModelViewController.h" 18 | 19 | @implementation AppDelegate 20 | 21 | - (BOOL)application:(UIApplication *)application 22 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 23 | 24 | UITabBarController *bar = [[UITabBarController alloc] init]; 25 | [bar setViewControllers: 26 | @[[[RunModelViewController alloc] init]]]; 27 | bar.selectedIndex = 0; 28 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 29 | self.window.rootViewController = bar; 30 | [self.window makeKeyAndVisible]; 31 | return YES; 32 | } 33 | 34 | - (void)applicationWillResignActive:(UIApplication *)application {} 35 | 36 | - (void)applicationDidEnterBackground:(UIApplication *)application {} 37 | 38 | - (void)applicationWillEnterForeground:(UIApplication *)application {} 39 | 40 | - (void)applicationDidBecomeActive:(UIApplication *)application {} 41 | 42 | - (void)applicationWillTerminate:(UIApplication *)application {} 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /ios_client/RunModel-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | tf_simple_example 9 | CFBundleExecutable 10 | tf_simple_example 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ios-app 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | RunModelViewController 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /python_predict_client/README.md: -------------------------------------------------------------------------------- 1 | # Python Predict Client 2 | 3 | ## Introduction 4 | 5 | TensorFlow serving is the gRPC service for general TensorFlow models. We can implement the Python gRPC client to predict. 6 | 7 | ## Usage 8 | 9 | ``` 10 | ./predict_client.py --host 127.0.0.1 --port 8500 --model_name default --model_version 1 11 | ``` 12 | 13 | For sparse data, you can run with this command. 14 | 15 | ``` 16 | ./sparse_predict_client.py --host 127.0.0.1 --port 9000 --model_name sparse --model_version 1 17 | ``` 18 | 19 | You can use `cloudml` to predict with json file. Notice that `cloudml` is not public yet. 20 | 21 | ``` 22 | { 23 | "keys_dtype": "int32", 24 | "keys": [[1], [2]], 25 | "features_dtype": "float32", 26 | "features": [[1,2,3,4,5,6,7,8,9], [1,2,3,4,5,6,7,8,9]] 27 | } 28 | ``` 29 | 30 | ``` 31 | cloudml models predict cancer v1 -d ./data.json 32 | ``` 33 | 34 | ## Development 35 | 36 | The gPRC client relies on the generated Python files from Protobuf. You should not generate by `bazel build //tensorflow_serving/example:mnist_client` from TensorFlow serving's documents. Because it relies on bazel and you can not run without bazel. 37 | 38 | We provide the proto files and script to generate the Python files in [./generate_python_files/](./generate_python_files/). The proto files are from [serving](https://github.com/tensorflow/serving/tree/master/tensorflow_serving/apis) and most source files are from [tensorflow](https://github.com/tensorflow/tensorflow/tree/master/tensorflow). We edit the import paths in `predict.proto` and `prediction_service.proto`. Notice that if the gRPC server upgrades, you need to update the source code and rebuild again. 39 | 40 | ``` 41 | cd ./generate_python_files/ && ./generate_python_files.sh 42 | ``` 43 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/framework/tensor_shape.proto: -------------------------------------------------------------------------------- 1 | // Protocol buffer representing the shape of tensors. 2 | 3 | syntax = "proto3"; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "TensorShapeProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | package tensorflow; 10 | 11 | // Dimensions of a tensor. 12 | message TensorShapeProto { 13 | // One dimension of the tensor. 14 | message Dim { 15 | // Size of the tensor in that dimension. 16 | // This value must be >= -1, but values of -1 are reserved for "unknown" 17 | // shapes (values of -1 mean "unknown" dimension). Certain wrappers 18 | // that work with TensorShapeProto may fail at runtime when deserializing 19 | // a TensorShapeProto containing a dim value of -1. 20 | int64 size = 1; 21 | 22 | // Optional name of the tensor dimension. 23 | string name = 2; 24 | }; 25 | 26 | // Dimensions of the tensor, such as {"input", 30}, {"output", 40} 27 | // for a 30 x 40 2D tensor. If an entry has size -1, this 28 | // corresponds to a dimension of unknown size. The names are 29 | // optional. 30 | // 31 | // The order of entries in "dim" matters: It indicates the layout of the 32 | // values in the tensor in-memory representation. 33 | // 34 | // The first entry in "dim" is the outermost dimension used to layout the 35 | // values, the last entry is the innermost dimension. This matches the 36 | // in-memory layout of RowMajor Eigen tensors. 37 | // 38 | // If "dim.size()" > 0, "unknown_rank" must be false. 39 | repeated Dim dim = 2; 40 | 41 | // If true, the number of dimensions in the shape is unknown. 42 | // 43 | // If true, "dim.size()" must be 0. 44 | bool unknown_rank = 3; 45 | }; 46 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/framework/tensor_shape.proto: -------------------------------------------------------------------------------- 1 | // Protocol buffer representing the shape of tensors. 2 | 3 | syntax = "proto3"; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "TensorShapeProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | package tensorflow; 10 | 11 | // Dimensions of a tensor. 12 | message TensorShapeProto { 13 | // One dimension of the tensor. 14 | message Dim { 15 | // Size of the tensor in that dimension. 16 | // This value must be >= -1, but values of -1 are reserved for "unknown" 17 | // shapes (values of -1 mean "unknown" dimension). Certain wrappers 18 | // that work with TensorShapeProto may fail at runtime when deserializing 19 | // a TensorShapeProto containing a dim value of -1. 20 | int64 size = 1; 21 | 22 | // Optional name of the tensor dimension. 23 | string name = 2; 24 | }; 25 | 26 | // Dimensions of the tensor, such as {"input", 30}, {"output", 40} 27 | // for a 30 x 40 2D tensor. If an entry has size -1, this 28 | // corresponds to a dimension of unknown size. The names are 29 | // optional. 30 | // 31 | // The order of entries in "dim" matters: It indicates the layout of the 32 | // values in the tensor in-memory representation. 33 | // 34 | // The first entry in "dim" is the outermost dimension used to layout the 35 | // values, the last entry is the innermost dimension. This matches the 36 | // in-memory layout of RowMajor Eigen tensors. 37 | // 38 | // If "dim.size()" > 0, "unknown_rank" must be false. 39 | repeated Dim dim = 2; 40 | 41 | // If true, the number of dimensions in the shape is unknown. 42 | // 43 | // If true, "dim.size()" must be 0. 44 | bool unknown_rank = 3; 45 | }; 46 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/debug/debug_service.proto: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | ==============================================================================*/ 15 | 16 | syntax = "proto3"; 17 | 18 | package tensorflow; 19 | 20 | import "tensorflow/core/util/event.proto"; 21 | 22 | // Reply message from EventListener to the client, i.e., to the source of the 23 | // Event protocal buffers, e.g., debug ops inserted by a debugged runtime to a 24 | // TensorFlow graph being executed. 25 | message EventReply { 26 | } 27 | 28 | // EventListener: Receives Event protos, e.g., from debugged TensorFlow 29 | // runtime(s). 30 | service EventListener { 31 | // Client(s) can use this RPC method to send the EventListener Event protos. 32 | // The Event protos can hold information such as: 33 | // 1) intermediate tensors from a debugged graph being executed, which can 34 | // be sent from DebugIdentity ops configured with grpc URLs. 35 | // 2) GraphDefs of partition graphs, which can be sent from special debug 36 | // ops that get executed immediately after the beginning of the graph 37 | // execution. 38 | rpc SendEvents(stream Event) returns (stream EventReply); 39 | } 40 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/tools/tfprof/tfprof_output.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "tensorflow/core/framework/tensor_shape.proto"; 4 | import "tensorflow/core/framework/types.proto"; 5 | 6 | package tensorflow.tfprof; 7 | 8 | message TFProfTensorProto { 9 | optional DataType dtype = 1; 10 | // Flatten tensor in row-major. 11 | // Only one of the following array is set. 12 | repeated double value_double = 2; 13 | repeated int64 value_int64 = 3; 14 | repeated string value_str = 4; 15 | } 16 | 17 | message TFProfNode { 18 | // op name. 19 | optional string name = 1; 20 | // tensor value restored from checkpoint. 21 | optional TFProfTensorProto tensor_value = 15; 22 | // op execution time. 23 | optional int64 exec_micros = 2; 24 | // Total requested bytes by the op. 25 | optional int64 requested_bytes = 3; 26 | // Number of parameters if available. 27 | optional int64 parameters = 4; 28 | // Number of float operations. 29 | optional int64 float_ops = 13; 30 | // Number of inputs to the op. 31 | optional int64 inputs = 5; 32 | // Device the op is assigned to. 33 | optional string device = 10; 34 | 35 | // The following are the aggregated stats from all accounted descendants and 36 | // the op itself. The actual descendants depend on the data structure used 37 | // (scope, graph). 38 | optional int64 total_exec_micros = 6; 39 | optional int64 total_requested_bytes = 7; 40 | optional int64 total_parameters = 8; 41 | optional int64 total_float_ops = 14; 42 | optional int64 total_inputs = 9; 43 | 44 | // shape information, if available. 45 | repeated TensorShapeProto shapes = 11; 46 | // Descendants of the graph. The actual descendants depend on the data 47 | // structure used (scope, graph). 48 | repeated TFProfNode children = 12; 49 | } -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/framework/tensor_shape.proto: -------------------------------------------------------------------------------- 1 | // Protocol buffer representing the shape of tensors. 2 | 3 | syntax = "proto3"; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "TensorShapeProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | package tensorflow; 10 | 11 | // Dimensions of a tensor. 12 | message TensorShapeProto { 13 | // One dimension of the tensor. 14 | message Dim { 15 | // Size of the tensor in that dimension. 16 | // This value must be >= -1, but values of -1 are reserved for "unknown" 17 | // shapes (values of -1 mean "unknown" dimension). Certain wrappers 18 | // that work with TensorShapeProto may fail at runtime when deserializing 19 | // a TensorShapeProto containing a dim value of -1. 20 | int64 size = 1; 21 | 22 | // Optional name of the tensor dimension. 23 | string name = 2; 24 | }; 25 | 26 | // Dimensions of the tensor, such as {"input", 30}, {"output", 40} 27 | // for a 30 x 40 2D tensor. If an entry has size -1, this 28 | // corresponds to a dimension of unknown size. The names are 29 | // optional. 30 | // 31 | // The order of entries in "dim" matters: It indicates the layout of the 32 | // values in the tensor in-memory representation. 33 | // 34 | // The first entry in "dim" is the outermost dimension used to layout the 35 | // values, the last entry is the innermost dimension. This matches the 36 | // in-memory layout of RowMajor Eigen tensors. 37 | // 38 | // If "dim.size()" > 0, "unknown_rank" must be false. 39 | repeated Dim dim = 2; 40 | 41 | // If true, the number of dimensions in the shape is unknown. 42 | // 43 | // If true, "dim.size()" must be 0. 44 | bool unknown_rank = 3; 45 | }; 46 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/debug/debug_service.proto: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | ==============================================================================*/ 15 | 16 | syntax = "proto3"; 17 | 18 | package tensorflow; 19 | 20 | import "tensorflow/core/util/event.proto"; 21 | 22 | // Reply message from EventListener to the client, i.e., to the source of the 23 | // Event protocal buffers, e.g., debug ops inserted by a debugged runtime to a 24 | // TensorFlow graph being executed. 25 | message EventReply { 26 | } 27 | 28 | // EventListener: Receives Event protos, e.g., from debugged TensorFlow 29 | // runtime(s). 30 | service EventListener { 31 | // Client(s) can use this RPC method to send the EventListener Event protos. 32 | // The Event protos can hold information such as: 33 | // 1) intermediate tensors from a debugged graph being executed, which can 34 | // be sent from DebugIdentity ops configured with grpc URLs. 35 | // 2) GraphDefs of partition graphs, which can be sent from special debug 36 | // ops that get executed immediately after the beginning of the graph 37 | // execution. 38 | rpc SendEvents(stream Event) returns (stream EventReply); 39 | } 40 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/tools/tfprof/tfprof_output.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "tensorflow/core/framework/tensor_shape.proto"; 4 | import "tensorflow/core/framework/types.proto"; 5 | 6 | package tensorflow.tfprof; 7 | 8 | message TFProfTensorProto { 9 | optional DataType dtype = 1; 10 | // Flatten tensor in row-major. 11 | // Only one of the following array is set. 12 | repeated double value_double = 2; 13 | repeated int64 value_int64 = 3; 14 | repeated string value_str = 4; 15 | } 16 | 17 | message TFProfNode { 18 | // op name. 19 | optional string name = 1; 20 | // tensor value restored from checkpoint. 21 | optional TFProfTensorProto tensor_value = 15; 22 | // op execution time. 23 | optional int64 exec_micros = 2; 24 | // Total requested bytes by the op. 25 | optional int64 requested_bytes = 3; 26 | // Number of parameters if available. 27 | optional int64 parameters = 4; 28 | // Number of float operations. 29 | optional int64 float_ops = 13; 30 | // Number of inputs to the op. 31 | optional int64 inputs = 5; 32 | // Device the op is assigned to. 33 | optional string device = 10; 34 | 35 | // The following are the aggregated stats from all accounted descendants and 36 | // the op itself. The actual descendants depend on the data structure used 37 | // (scope, graph). 38 | optional int64 total_exec_micros = 6; 39 | optional int64 total_requested_bytes = 7; 40 | optional int64 total_parameters = 8; 41 | optional int64 total_float_ops = 14; 42 | optional int64 total_inputs = 9; 43 | 44 | // shape information, if available. 45 | repeated TensorShapeProto shapes = 11; 46 | // Descendants of the graph. The actual descendants depend on the data 47 | // structure used (scope, graph). 48 | repeated TFProfNode children = 12; 49 | } -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/framework/tensor_shape.proto: -------------------------------------------------------------------------------- 1 | // Protocol buffer representing the shape of tensors. 2 | 3 | syntax = "proto3"; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "TensorShapeProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | package tensorflow; 10 | 11 | // Dimensions of a tensor. 12 | message TensorShapeProto { 13 | // One dimension of the tensor. 14 | message Dim { 15 | // Size of the tensor in that dimension. 16 | // This value must be >= -1, but values of -1 are reserved for "unknown" 17 | // shapes (values of -1 mean "unknown" dimension). Certain wrappers 18 | // that work with TensorShapeProto may fail at runtime when deserializing 19 | // a TensorShapeProto containing a dim value of -1. 20 | int64 size = 1; 21 | 22 | // Optional name of the tensor dimension. 23 | string name = 2; 24 | }; 25 | 26 | // Dimensions of the tensor, such as {"input", 30}, {"output", 40} 27 | // for a 30 x 40 2D tensor. If an entry has size -1, this 28 | // corresponds to a dimension of unknown size. The names are 29 | // optional. 30 | // 31 | // The order of entries in "dim" matters: It indicates the layout of the 32 | // values in the tensor in-memory representation. 33 | // 34 | // The first entry in "dim" is the outermost dimension used to layout the 35 | // values, the last entry is the innermost dimension. This matches the 36 | // in-memory layout of RowMajor Eigen tensors. 37 | // 38 | // If "dim.size()" > 0, "unknown_rank" must be false. 39 | repeated Dim dim = 2; 40 | 41 | // If true, the number of dimensions in the shape is unknown. 42 | // 43 | // If true, "dim.size()" must be 0. 44 | bool unknown_rank = 3; 45 | }; 46 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/debug/debug_service.proto: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | ==============================================================================*/ 15 | 16 | syntax = "proto3"; 17 | 18 | package tensorflow; 19 | 20 | import "tensorflow/core/util/event.proto"; 21 | 22 | // Reply message from EventListener to the client, i.e., to the source of the 23 | // Event protocal buffers, e.g., debug ops inserted by a debugged runtime to a 24 | // TensorFlow graph being executed. 25 | message EventReply { 26 | } 27 | 28 | // EventListener: Receives Event protos, e.g., from debugged TensorFlow 29 | // runtime(s). 30 | service EventListener { 31 | // Client(s) can use this RPC method to send the EventListener Event protos. 32 | // The Event protos can hold information such as: 33 | // 1) intermediate tensors from a debugged graph being executed, which can 34 | // be sent from DebugIdentity ops configured with grpc URLs. 35 | // 2) GraphDefs of partition graphs, which can be sent from special debug 36 | // ops that get executed immediately after the beginning of the graph 37 | // execution. 38 | rpc SendEvents(stream Event) returns (stream EventReply); 39 | } 40 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/tools/tfprof/tfprof_output.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "tensorflow/core/framework/tensor_shape.proto"; 4 | import "tensorflow/core/framework/types.proto"; 5 | 6 | package tensorflow.tfprof; 7 | 8 | message TFProfTensorProto { 9 | optional DataType dtype = 1; 10 | // Flatten tensor in row-major. 11 | // Only one of the following array is set. 12 | repeated double value_double = 2; 13 | repeated int64 value_int64 = 3; 14 | repeated string value_str = 4; 15 | } 16 | 17 | message TFProfNode { 18 | // op name. 19 | optional string name = 1; 20 | // tensor value restored from checkpoint. 21 | optional TFProfTensorProto tensor_value = 15; 22 | // op execution time. 23 | optional int64 exec_micros = 2; 24 | // Total requested bytes by the op. 25 | optional int64 requested_bytes = 3; 26 | // Number of parameters if available. 27 | optional int64 parameters = 4; 28 | // Number of float operations. 29 | optional int64 float_ops = 13; 30 | // Number of inputs to the op. 31 | optional int64 inputs = 5; 32 | // Device the op is assigned to. 33 | optional string device = 10; 34 | 35 | // The following are the aggregated stats from all accounted descendants and 36 | // the op itself. The actual descendants depend on the data structure used 37 | // (scope, graph). 38 | optional int64 total_exec_micros = 6; 39 | optional int64 total_requested_bytes = 7; 40 | optional int64 total_parameters = 8; 41 | optional int64 total_float_ops = 14; 42 | optional int64 total_inputs = 9; 43 | 44 | // shape information, if available. 45 | repeated TensorShapeProto shapes = 11; 46 | // Descendants of the graph. The actual descendants depend on the data 47 | // structure used (scope, graph). 48 | repeated TFProfNode children = 12; 49 | } -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/debug/debug_service.proto: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | ==============================================================================*/ 15 | 16 | syntax = "proto3"; 17 | 18 | package tensorflow; 19 | 20 | import "tensorflow/core/util/event.proto"; 21 | 22 | // Reply message from EventListener to the client, i.e., to the source of the 23 | // Event protocal buffers, e.g., debug ops inserted by a debugged runtime to a 24 | // TensorFlow graph being executed. 25 | message EventReply { 26 | } 27 | 28 | // EventListener: Receives Event protos, e.g., from debugged TensorFlow 29 | // runtime(s). 30 | service EventListener { 31 | // Client(s) can use this RPC method to send the EventListener Event protos. 32 | // The Event protos can hold information such as: 33 | // 1) intermediate tensors from a debugged graph being executed, which can 34 | // be sent from DebugIdentity ops configured with grpc URLs. 35 | // 2) GraphDefs of partition graphs, which can be sent from special debug 36 | // ops that get executed immediately after the beginning of the graph 37 | // execution. 38 | rpc SendEvents(stream Event) returns (stream EventReply); 39 | } 40 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/tools/tfprof/tfprof_output.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | import "tensorflow/core/framework/tensor_shape.proto"; 4 | import "tensorflow/core/framework/types.proto"; 5 | 6 | package tensorflow.tfprof; 7 | 8 | message TFProfTensorProto { 9 | optional DataType dtype = 1; 10 | // Flatten tensor in row-major. 11 | // Only one of the following array is set. 12 | repeated double value_double = 2; 13 | repeated int64 value_int64 = 3; 14 | repeated string value_str = 4; 15 | } 16 | 17 | message TFProfNode { 18 | // op name. 19 | optional string name = 1; 20 | // tensor value restored from checkpoint. 21 | optional TFProfTensorProto tensor_value = 15; 22 | // op execution time. 23 | optional int64 exec_micros = 2; 24 | // Total requested bytes by the op. 25 | optional int64 requested_bytes = 3; 26 | // Number of parameters if available. 27 | optional int64 parameters = 4; 28 | // Number of float operations. 29 | optional int64 float_ops = 13; 30 | // Number of inputs to the op. 31 | optional int64 inputs = 5; 32 | // Device the op is assigned to. 33 | optional string device = 10; 34 | 35 | // The following are the aggregated stats from all accounted descendants and 36 | // the op itself. The actual descendants depend on the data structure used 37 | // (scope, graph). 38 | optional int64 total_exec_micros = 6; 39 | optional int64 total_requested_bytes = 7; 40 | optional int64 total_parameters = 8; 41 | optional int64 total_float_ops = 14; 42 | optional int64 total_inputs = 9; 43 | 44 | // shape information, if available. 45 | repeated TensorShapeProto shapes = 11; 46 | // Descendants of the graph. The actual descendants depend on the data 47 | // structure used (scope, graph). 48 | repeated TFProfNode children = 12; 49 | } -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/core/framework/step_stats.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "StepStatsProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/allocation_description.proto"; 10 | import "tensorflow/core/framework/tensor_description.proto"; 11 | 12 | // TODO(tucker): The next 4 message defs are very similar to 13 | // the *LogEntry messages in profile.proto. They should be 14 | // unified in one place. 15 | 16 | message AllocatorMemoryUsed { 17 | string allocator_name = 1; 18 | int64 total_bytes = 2; 19 | int64 peak_bytes = 3; 20 | } 21 | 22 | // Output sizes recorded for a single execution of a graph node. 23 | message NodeOutput { 24 | int32 slot = 1; 25 | TensorDescription tensor_description = 3; 26 | }; 27 | 28 | // Time/size stats recorded for a single execution of a graph node. 29 | message NodeExecStats { 30 | // TODO(tucker): Use some more compact form of node identity than 31 | // the full string name. Either all processes should agree on a 32 | // global id (cost_id?) for each node, or we should use a hash of 33 | // the name. 34 | string node_name = 1; 35 | int64 all_start_micros = 2; 36 | int64 op_start_rel_micros = 3; 37 | int64 op_end_rel_micros = 4; 38 | int64 all_end_rel_micros = 5; 39 | repeated AllocatorMemoryUsed memory = 6; 40 | repeated NodeOutput output = 7; 41 | string timeline_label = 8; 42 | int64 scheduled_micros = 9; 43 | uint32 thread_id = 10; 44 | repeated AllocationDescription referenced_tensor = 11; 45 | }; 46 | 47 | message DeviceStepStats { 48 | string device = 1; 49 | repeated NodeExecStats node_stats = 2; 50 | } 51 | 52 | message StepStats { 53 | repeated DeviceStepStats dev_stats = 1; 54 | }; 55 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/core/framework/step_stats.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "StepStatsProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/allocation_description.proto"; 10 | import "tensorflow/core/framework/tensor_description.proto"; 11 | 12 | // TODO(tucker): The next 4 message defs are very similar to 13 | // the *LogEntry messages in profile.proto. They should be 14 | // unified in one place. 15 | 16 | message AllocatorMemoryUsed { 17 | string allocator_name = 1; 18 | int64 total_bytes = 2; 19 | int64 peak_bytes = 3; 20 | } 21 | 22 | // Output sizes recorded for a single execution of a graph node. 23 | message NodeOutput { 24 | int32 slot = 1; 25 | TensorDescription tensor_description = 3; 26 | }; 27 | 28 | // Time/size stats recorded for a single execution of a graph node. 29 | message NodeExecStats { 30 | // TODO(tucker): Use some more compact form of node identity than 31 | // the full string name. Either all processes should agree on a 32 | // global id (cost_id?) for each node, or we should use a hash of 33 | // the name. 34 | string node_name = 1; 35 | int64 all_start_micros = 2; 36 | int64 op_start_rel_micros = 3; 37 | int64 op_end_rel_micros = 4; 38 | int64 all_end_rel_micros = 5; 39 | repeated AllocatorMemoryUsed memory = 6; 40 | repeated NodeOutput output = 7; 41 | string timeline_label = 8; 42 | int64 scheduled_micros = 9; 43 | uint32 thread_id = 10; 44 | repeated AllocationDescription referenced_tensor = 11; 45 | }; 46 | 47 | message DeviceStepStats { 48 | string device = 1; 49 | repeated NodeExecStats node_stats = 2; 50 | } 51 | 52 | message StepStats { 53 | repeated DeviceStepStats dev_stats = 1; 54 | }; 55 | -------------------------------------------------------------------------------- /golang_predict_client/src/generate_golang_files/tensorflow/core/framework/step_stats.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "StepStatsProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/allocation_description.proto"; 10 | import "tensorflow/core/framework/tensor_description.proto"; 11 | 12 | // TODO(tucker): The next 4 message defs are very similar to 13 | // the *LogEntry messages in profile.proto. They should be 14 | // unified in one place. 15 | 16 | message AllocatorMemoryUsed { 17 | string allocator_name = 1; 18 | int64 total_bytes = 2; 19 | int64 peak_bytes = 3; 20 | } 21 | 22 | // Output sizes recorded for a single execution of a graph node. 23 | message NodeOutput { 24 | int32 slot = 1; 25 | TensorDescription tensor_description = 3; 26 | }; 27 | 28 | // Time/size stats recorded for a single execution of a graph node. 29 | message NodeExecStats { 30 | // TODO(tucker): Use some more compact form of node identity than 31 | // the full string name. Either all processes should agree on a 32 | // global id (cost_id?) for each node, or we should use a hash of 33 | // the name. 34 | string node_name = 1; 35 | int64 all_start_micros = 2; 36 | int64 op_start_rel_micros = 3; 37 | int64 op_end_rel_micros = 4; 38 | int64 all_end_rel_micros = 5; 39 | repeated AllocatorMemoryUsed memory = 6; 40 | repeated NodeOutput output = 7; 41 | string timeline_label = 8; 42 | int64 scheduled_micros = 9; 43 | uint32 thread_id = 10; 44 | repeated AllocationDescription referenced_tensor = 11; 45 | }; 46 | 47 | message DeviceStepStats { 48 | string device = 1; 49 | repeated NodeExecStats node_stats = 2; 50 | } 51 | 52 | message StepStats { 53 | repeated DeviceStepStats dev_stats = 1; 54 | }; 55 | -------------------------------------------------------------------------------- /python_predict_client/generate_python_files/tensorflow/core/framework/step_stats.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "StepStatsProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | import "tensorflow/core/framework/allocation_description.proto"; 10 | import "tensorflow/core/framework/tensor_description.proto"; 11 | 12 | // TODO(tucker): The next 4 message defs are very similar to 13 | // the *LogEntry messages in profile.proto. They should be 14 | // unified in one place. 15 | 16 | message AllocatorMemoryUsed { 17 | string allocator_name = 1; 18 | int64 total_bytes = 2; 19 | int64 peak_bytes = 3; 20 | } 21 | 22 | // Output sizes recorded for a single execution of a graph node. 23 | message NodeOutput { 24 | int32 slot = 1; 25 | TensorDescription tensor_description = 3; 26 | }; 27 | 28 | // Time/size stats recorded for a single execution of a graph node. 29 | message NodeExecStats { 30 | // TODO(tucker): Use some more compact form of node identity than 31 | // the full string name. Either all processes should agree on a 32 | // global id (cost_id?) for each node, or we should use a hash of 33 | // the name. 34 | string node_name = 1; 35 | int64 all_start_micros = 2; 36 | int64 op_start_rel_micros = 3; 37 | int64 op_end_rel_micros = 4; 38 | int64 all_end_rel_micros = 5; 39 | repeated AllocatorMemoryUsed memory = 6; 40 | repeated NodeOutput output = 7; 41 | string timeline_label = 8; 42 | int64 scheduled_micros = 9; 43 | uint32 thread_id = 10; 44 | repeated AllocationDescription referenced_tensor = 11; 45 | }; 46 | 47 | message DeviceStepStats { 48 | string device = 1; 49 | repeated NodeExecStats node_stats = 2; 50 | } 51 | 52 | message StepStats { 53 | repeated DeviceStepStats dev_stats = 1; 54 | }; 55 | -------------------------------------------------------------------------------- /java_predict_client/src/main/proto/tensorflow/contrib/tensorboard/plugins/projector/projector_config.proto: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | ==============================================================================*/ 15 | 16 | syntax = "proto3"; 17 | 18 | package tensorflow; 19 | 20 | message SpriteMetadata { 21 | string image_path = 1; 22 | // [width, height] of a single image in the sprite. 23 | repeated uint32 single_image_dim = 2; 24 | } 25 | 26 | message EmbeddingInfo { 27 | string tensor_name = 1; 28 | string metadata_path = 2; 29 | string bookmarks_path = 3; 30 | // Shape of the 2D tensor [N x D]. If missing, it will be inferred from the 31 | // model checkpoint. 32 | repeated uint32 tensor_shape = 4; 33 | SpriteMetadata sprite = 5; 34 | // Path to the TSV file holding the tensor values. If missing, the tensor 35 | // is assumed to be stored in the model checkpoint. 36 | string tensor_path = 6; 37 | } 38 | 39 | message ProjectorConfig { 40 | // Path to the checkpoint file. Use either this or model_checkpoint_dir. 41 | string model_checkpoint_path = 1; 42 | repeated EmbeddingInfo embeddings = 2; 43 | // Path to the checkpoint directory. The directory will be scanned for the 44 | // latest checkpoint file. 45 | string model_checkpoint_dir = 3; 46 | } 47 | -------------------------------------------------------------------------------- /cpp_predict_client/generate_proto_files/tensorflow/contrib/tensorboard/plugins/projector/projector_config.proto: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | ==============================================================================*/ 15 | 16 | syntax = "proto3"; 17 | 18 | package tensorflow; 19 | 20 | message SpriteMetadata { 21 | string image_path = 1; 22 | // [width, height] of a single image in the sprite. 23 | repeated uint32 single_image_dim = 2; 24 | } 25 | 26 | message EmbeddingInfo { 27 | string tensor_name = 1; 28 | string metadata_path = 2; 29 | string bookmarks_path = 3; 30 | // Shape of the 2D tensor [N x D]. If missing, it will be inferred from the 31 | // model checkpoint. 32 | repeated uint32 tensor_shape = 4; 33 | SpriteMetadata sprite = 5; 34 | // Path to the TSV file holding the tensor values. If missing, the tensor 35 | // is assumed to be stored in the model checkpoint. 36 | string tensor_path = 6; 37 | } 38 | 39 | message ProjectorConfig { 40 | // Path to the checkpoint file. Use either this or model_checkpoint_dir. 41 | string model_checkpoint_path = 1; 42 | repeated EmbeddingInfo embeddings = 2; 43 | // Path to the checkpoint directory. The directory will be scanned for the 44 | // latest checkpoint file. 45 | string model_checkpoint_dir = 3; 46 | } 47 | --------------------------------------------------------------------------------