Skip to content

Commit ec70d93

Browse files
andrewharptensorflower-gardener
authored andcommitted
Port TensorFlow demo to TFLite with three activities: MobileNet Classification, MobileNet SSD Object Detection, and Speech hotword classification
PiperOrigin-RevId: 191015617
1 parent 16fb9b6 commit ec70d93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+7140
-1
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2016 The TensorFlow Authors. All Rights Reserved.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
19+
package="org.tensorflow.lite.demo">
20+
21+
<uses-permission android:name="android.permission.CAMERA" />
22+
<uses-feature android:name="android.hardware.camera" />
23+
<uses-feature android:name="android.hardware.camera.autofocus" />
24+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
25+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
26+
27+
<uses-sdk
28+
android:minSdkVersion="21"
29+
android:targetSdkVersion="23" />
30+
31+
<application android:allowBackup="true"
32+
android:debuggable="true"
33+
android:label="@string/app_name"
34+
android:icon="@drawable/ic_launcher"
35+
android:theme="@style/MaterialTheme">
36+
37+
<activity android:name="org.tensorflow.demo.ClassifierActivity"
38+
android:screenOrientation="portrait"
39+
android:label="@string/activity_name_classification">
40+
<intent-filter>
41+
<action android:name="android.intent.action.MAIN" />
42+
<category android:name="android.intent.category.LAUNCHER" />
43+
</intent-filter>
44+
</activity>
45+
46+
<activity android:name="org.tensorflow.demo.DetectorActivity"
47+
android:screenOrientation="portrait"
48+
android:label="@string/activity_name_detection">
49+
<intent-filter>
50+
<action android:name="android.intent.action.MAIN" />
51+
<category android:name="android.intent.category.LAUNCHER" />
52+
</intent-filter>
53+
</activity>
54+
55+
<activity android:name="org.tensorflow.demo.SpeechActivity"
56+
android:screenOrientation="portrait"
57+
android:label="@string/activity_name_speech">
58+
<intent-filter>
59+
<action android:name="android.intent.action.MAIN" />
60+
<category android:name="android.intent.category.LAUNCHER" />
61+
</intent-filter>
62+
</activity>
63+
</application>
64+
65+
</manifest>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Description:
2+
# TensorFlow camera demo app for Android.
3+
4+
package(default_visibility = ["//visibility:public"])
5+
6+
licenses(["notice"]) # Apache 2.0
7+
8+
exports_files(["LICENSE"])
9+
10+
# Build the demo native demo lib from the original directory to reduce code
11+
# reuse. Note that the Java counterparts (ObjectTracker.java and
12+
# ImageUtils.java) are still duplicated.
13+
cc_library(
14+
name = "tensorflow_native_libs",
15+
srcs = [
16+
"//tensorflow/examples/android:libtensorflow_demo.so",
17+
],
18+
tags = [
19+
"manual",
20+
"notap",
21+
],
22+
)
23+
24+
android_binary(
25+
name = "tflite_demo",
26+
srcs = glob([
27+
"src/**/*.java",
28+
]),
29+
# Package assets from assets dir as well as all model targets.
30+
# Remove undesired models (and corresponding Activities in source)
31+
# to reduce APK size.
32+
assets = [
33+
"//tensorflow/contrib/lite/examples/android/assets:labels_mobilenet_quant_v1_224.txt",
34+
"@tflite_mobilenet//:mobilenet_quant_v1_224.tflite",
35+
"@tflite_conv_actions_frozen//:conv_actions_frozen.tflite",
36+
"//tensorflow/contrib/lite/examples/android/assets:conv_actions_labels.txt",
37+
"@tflite_mobilenet_ssd//:mobilenet_ssd.tflite",
38+
"//tensorflow/contrib/lite/examples/android/assets:box_priors.txt",
39+
"//tensorflow/contrib/lite/examples/android/assets:coco_labels_list.txt",
40+
],
41+
assets_dir = "",
42+
custom_package = "org.tensorflow.lite.demo",
43+
inline_constants = 1,
44+
manifest = "AndroidManifest.xml",
45+
manifest_merger = "android",
46+
nocompress_extensions = [
47+
".tflite",
48+
],
49+
resource_files = glob(["res/**"]),
50+
tags = [
51+
"manual",
52+
"notap",
53+
],
54+
deps = [
55+
":tensorflow_native_libs",
56+
"//tensorflow/contrib/lite/java:tensorflowlite",
57+
],
58+
)
59+
60+
filegroup(
61+
name = "all_files",
62+
srcs = glob(
63+
["**/*"],
64+
exclude = [
65+
"**/METADATA",
66+
"**/OWNERS",
67+
"bin/**",
68+
"gen/**",
69+
"gradleBuild/**",
70+
"libs/**",
71+
],
72+
),
73+
visibility = ["//tensorflow:__subpackages__"],
74+
)
75+
76+
filegroup(
77+
name = "java_files",
78+
srcs = glob(["src/**/*.java"]),
79+
)
80+
81+
filegroup(
82+
name = "resource_files",
83+
srcs = glob(["res/**"]),
84+
)
85+
86+
exports_files(["AndroidManifest.xml"])
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package(default_visibility = ["//visibility:private"])
2+
3+
licenses(["notice"]) # Apache 2.0
4+
5+
exports_files(
6+
glob(
7+
["**/*"],
8+
exclude = [
9+
"BUILD",
10+
],
11+
),
12+
)
13+
14+
filegroup(
15+
name = "all_files",
16+
srcs = glob(
17+
["**/*"],
18+
exclude = [
19+
"**/METADATA",
20+
"**/OWNERS",
21+
],
22+
),
23+
visibility = ["//tensorflow:__subpackages__"],
24+
)

tensorflow/contrib/lite/examples/android/assets/box_priors.txt

Lines changed: 5 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
???
2+
person
3+
bicycle
4+
car
5+
motorcycle
6+
airplane
7+
bus
8+
train
9+
truck
10+
boat
11+
traffic light
12+
fire hydrant
13+
???
14+
stop sign
15+
parking meter
16+
bench
17+
bird
18+
cat
19+
dog
20+
horse
21+
sheep
22+
cow
23+
elephant
24+
bear
25+
zebra
26+
giraffe
27+
???
28+
backpack
29+
umbrella
30+
???
31+
???
32+
handbag
33+
tie
34+
suitcase
35+
frisbee
36+
skis
37+
snowboard
38+
sports ball
39+
kite
40+
baseball bat
41+
baseball glove
42+
skateboard
43+
surfboard
44+
tennis racket
45+
bottle
46+
???
47+
wine glass
48+
cup
49+
fork
50+
knife
51+
spoon
52+
bowl
53+
banana
54+
apple
55+
sandwich
56+
orange
57+
broccoli
58+
carrot
59+
hot dog
60+
pizza
61+
donut
62+
cake
63+
chair
64+
couch
65+
potted plant
66+
bed
67+
???
68+
dining table
69+
???
70+
???
71+
toilet
72+
???
73+
tv
74+
laptop
75+
mouse
76+
remote
77+
keyboard
78+
cell phone
79+
microwave
80+
oven
81+
toaster
82+
sink
83+
refrigerator
84+
???
85+
book
86+
clock
87+
vase
88+
scissors
89+
teddy bear
90+
hair drier
91+
toothbrush
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
_silence_
2+
_unknown_
3+
yes
4+
no
5+
up
6+
down
7+
left
8+
right
9+
on
10+
off
11+
stop
12+
go

0 commit comments

Comments
 (0)