Skip to content

Commit b7c5042

Browse files
khanhlvgtflite-support-robot
authored andcommitted
Improved API docs for TFLite Task Lib
PiperOrigin-RevId: 447372882
1 parent 8465d29 commit b7c5042

File tree

10 files changed

+103
-10
lines changed

10 files changed

+103
-10
lines changed

tensorflow_lite_support/opensource/opensource_only.files

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ tensorflow_lite_support/tools/pip_package/build_pip_package.sh:
4444
tensorflow_lite_support/tools/pip_package/metadata_writers.__init__.py:
4545
tensorflow_lite_support/tools/pip_package/setup.py:
4646
tensorflow_lite_support/tools/pip_package/simple_console_for_windows.py:
47+
tensorflow_lite_support/tools/pip_package/task.__init__.py:
4748
tensorflow_lite_support/tools/pip_package/task_audio.__init__.py:
4849
tensorflow_lite_support/tools/pip_package/task_core.__init__.py:
4950
tensorflow_lite_support/tools/pip_package/task_processor.__init__.py:

tensorflow_lite_support/python/task/audio/core/tensor_audio.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
from tensorflow_lite_support.python.task.audio.core import audio_record
1919
from tensorflow_lite_support.python.task.audio.core.pybinds import _pywrap_audio_buffer
2020

21-
_CppAudioFormat = _pywrap_audio_buffer.AudioFormat
2221
_LoadAudioBufferFromFile = _pywrap_audio_buffer.LoadAudioBufferFromFile
22+
AudioFormat = _pywrap_audio_buffer.AudioFormat
2323

2424

2525
class TensorAudio(object):
2626
"""A wrapper class to store the input audio."""
2727

28-
def __init__(self, audio_format: _CppAudioFormat, buffer_size: int) -> None:
28+
def __init__(self, audio_format: AudioFormat, buffer_size: int) -> None:
2929
"""Initializes the `TensorAudio` object.
3030
3131
Args:
@@ -137,7 +137,7 @@ def load_from_array(self,
137137
self._buffer[-shift:, :] = src[offset:offset + size].copy()
138138

139139
@property
140-
def format(self) -> _CppAudioFormat:
140+
def format(self) -> AudioFormat:
141141
"""Gets the audio format of the audio."""
142142
return self._format
143143

tensorflow_lite_support/tools/pip_package/build_pip_package.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ function prepare_src() {
9898
# Task Library is not supported on Windows yet.
9999
mkdir ${TMPDIR}/tflite_support/task
100100
mkdir ${TMPDIR}/tflite_support/task/core
101+
cp tensorflow_lite_support/tools/pip_package/task.__init__.py ${TMPDIR}/tflite_support/task/__init__.py
101102
cp tensorflow_lite_support/tools/pip_package/task_core.__init__.py ${TMPDIR}/tflite_support/task/core/__init__.py
102103
mkdir ${TMPDIR}/tflite_support/task/vision
103104
cp tensorflow_lite_support/tools/pip_package/task_vision.__init__.py ${TMPDIR}/tflite_support/task/vision/__init__.py
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright 2022 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+
"""The TensorFlow Lite Task Library.
16+
17+
TensorFlow Lite Task Library contains a set of powerful and easy-to-use
18+
task-specific libraries for app developers to create ML experiences with
19+
TensorFlow Lite. It provides optimized out-of-box model interfaces for popular
20+
machine learning tasks, such as image and text classification. The model
21+
interfaces are specifically designed for each task to achieve the best
22+
performance and usability.
23+
24+
Read more in the [Task Library Guide](
25+
https://tensorflow.org/lite/inference_with_metadata/task_library/overview).
26+
"""
27+
28+
from . import audio
29+
from . import core
30+
from . import processor
31+
from . import text
32+
from . import vision

tensorflow_lite_support/tools/pip_package/task_audio.__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# ==============================================================================
15-
"""An import entry for Task Audio Library."""
15+
"""TensorFlow Lite Task Library Audio APIs.
16+
17+
This module provides interface to run TensorFlow Lite audio models.
18+
"""
1619

1720
from tensorflow_lite_support.python.task.audio import audio_classifier
1821
from tensorflow_lite_support.python.task.audio import audio_embedder
@@ -24,4 +27,11 @@
2427
AudioEmbedder = audio_embedder.AudioEmbedder
2528
AudioEmbedderOptions = audio_embedder.AudioEmbedderOptions
2629
AudioRecord = audio_record.AudioRecord
30+
AudioFormat = tensor_audio.AudioFormat
2731
TensorAudio = tensor_audio.TensorAudio
32+
33+
# Remove unnecessary modules to avoid duplication in API docs.
34+
del audio_classifier
35+
del audio_embedder
36+
del audio_record
37+
del tensor_audio

tensorflow_lite_support/tools/pip_package/task_core.__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# ==============================================================================
15-
"""An import entry for the Task Core module."""
15+
"""TensorFlow Lite Task Library's core module.
16+
17+
This module contains classes used across multiple tasks in the Task Library."""
1618

1719
from tensorflow_lite_support.python.task.core.proto import base_options_pb2
1820

1921
BaseOptions = base_options_pb2.BaseOptions
22+
23+
# Remove unnecessary modules to avoid duplication in API docs.
24+
del base_options_pb2

tensorflow_lite_support/tools/pip_package/task_processor.__init__.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# ==============================================================================
15-
"""An import entry for the Task Processor module."""
15+
"""TensorFlow Lite Task Library's processor module.
16+
17+
This module contains classes related to the pre-processing and post-processing
18+
steps of the Task Library.
19+
"""
1620

1721
from tensorflow_lite_support.python.task.processor.proto import bounding_box_pb2
1822
from tensorflow_lite_support.python.task.processor.proto import classification_options_pb2
@@ -37,3 +41,16 @@
3741
Segmentation = segmentations_pb2.Segmentation
3842
SearchOptions = search_options_pb2.SearchOptions
3943
SearchResult = search_result_pb2.SearchResult
44+
45+
# Remove unnecessary modules to avoid duplication in API docs.
46+
del bounding_box_pb2
47+
del classification_options_pb2
48+
del classifications_pb2
49+
del detection_options_pb2
50+
del detections_pb2
51+
del embedding_options_pb2
52+
del embedding_pb2
53+
del segmentation_options_pb2
54+
del segmentations_pb2
55+
del search_options_pb2
56+
del search_result_pb2

tensorflow_lite_support/tools/pip_package/task_text.__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# ==============================================================================
15-
"""An import entry for Task Text Library."""
15+
"""TensorFlow Lite Task Library Text APIs.
16+
17+
This module provides interface to run TensorFlow Lite natural language
18+
processing models.
19+
"""
1620

1721
from tensorflow_lite_support.python.task.text import text_embedder
1822
from tensorflow_lite_support.python.task.text import text_searcher
@@ -21,3 +25,7 @@
2125
TextEmbedderOptions = text_embedder.TextEmbedderOptions
2226
TextSearcher = text_searcher.TextSearcher
2327
TextSearcherOptions = text_searcher.TextSearcherOptions
28+
29+
# Remove unnecessary modules to avoid duplication in API docs.
30+
del text_embedder
31+
del text_searcher

tensorflow_lite_support/tools/pip_package/task_vision.__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# ==============================================================================
15-
"""An import entry for Task Vision Library."""
15+
"""TensorFlow Lite Task Library Vision APIs.
16+
17+
This module provides interface to run TensorFlow Lite computer vision models.
18+
"""
1619

1720
from tensorflow_lite_support.python.task.vision import image_classifier
1821
from tensorflow_lite_support.python.task.vision import image_embedder
@@ -32,3 +35,11 @@
3235
ImageSearcher = image_searcher.ImageSearcher
3336
ImageSearcherOptions = image_searcher.ImageSearcherOptions
3437
TensorImage = tensor_image.TensorImage
38+
39+
# Remove unnecessary modules to avoid duplication in API docs.
40+
del image_classifier
41+
del image_embedder
42+
del image_segmenter
43+
del image_searcher
44+
del object_detector
45+
del tensor_image

tensorflow_lite_support/tools/pip_package/tflite_support.__init__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,25 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
# ==============================================================================
15-
"""The TFLite Support Library.
15+
"""The TensorFlow Lite Support Library.
1616
1717
Install the pip package:
1818
1919
```
2020
pip install tflite-support
2121
```
2222
23+
This package provides two major features:
24+
* Metadata writers: add metadata to TensorFlow Lite models.
25+
* Task Library: run TensorFlow Lite models of major machine learning tasks.
26+
2327
To learn more about metadata, flatbuffers and TensorFlow Lite models, check out
2428
the [metadata section](https://www.tensorflow.org/lite/convert/metadata) of the
25-
TF Lite guide.
29+
TensorFlow Lite guide.
30+
31+
To learn more about Task Library, check out the
32+
[documentation](https://www.tensorflow.org/lite/inference_with_metadata/task_library/overview)
33+
on the TensorFlow Lite website.
2634
"""
2735

2836
# In the original project structure, all python targets are accessed by paths

0 commit comments

Comments
 (0)