Skip to content

Commit d0b059d

Browse files
authored
[Data] Add batch inference object detection example (ray-project#35143)
1 parent fb95f03 commit d0b059d

File tree

6 files changed

+1090
-2
lines changed

6 files changed

+1090
-2
lines changed

doc/source/_toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ parts:
102102
- file: data/examples/ocr_example
103103
title: Scaling OCR with Ray Data
104104
- file: data/examples/random-access
105+
- file: data/examples/batch_inference_object_detection
106+
title: Object Detection Batch Inference with PyTorch
105107
- file: data/faq
106108
- file: data/api/api
107109
- file: data/glossary

doc/source/data/batch_inference.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,14 @@ tutorials and examples:
782782

783783
Batch Inference on NYC taxi data using Ray Data
784784

785+
.. grid-item-card::
786+
:img-top: /images/ray_logo.png
787+
:class-img-top: pt-2 w-75 d-block mx-auto fixed-height-img
788+
789+
.. button-ref:: /data/examples/batch_inference_object_detection
790+
791+
Object Detection Batch Inference with PyTorch
792+
785793
.. grid-item-card::
786794
:img-top: /images/ray_logo.png
787795
:class-img-top: pt-2 w-75 d-block mx-auto fixed-height-img

doc/source/data/examples/BUILD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ filegroup(
55
srcs = glob(["*.ipynb"]),
66
visibility = ["//doc:__subpackages__"]
77
)
8+
9+
py_test_run_all_notebooks(
10+
size = "medium",
11+
include = ["batch_inference_object_detection.ipynb"],
12+
exclude = [],
13+
data = ["//doc/source/data/examples:data_examples"],
14+
tags = ["exclusive", "team:data"],
15+
)

doc/source/data/examples/batch_inference_object_detection.ipynb

Lines changed: 1059 additions & 0 deletions
Large diffs are not rendered by default.

doc/test_myst_doc.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ def postprocess_notebook(notebook):
4848
return notebook
4949

5050

51-
if __name__ == "__main__":
51+
DISPLAY_FUNCTION = """
52+
def display(*args, **kwargs):
53+
print(*args, **kwargs)
54+
"""
5255

56+
57+
if __name__ == "__main__":
5358
args, remainder = parser.parse_known_args()
5459

5560
path = Path(args.path)
@@ -66,6 +71,9 @@ def postprocess_notebook(notebook):
6671

6772
name = ""
6873
with tempfile.NamedTemporaryFile("w", delete=False) as f:
74+
# Define the display function, which is available in notebooks,
75+
# but not in normal Python scripts.
76+
f.write(DISPLAY_FUNCTION)
6977
jupytext.write(notebook, f, fmt="py:percent")
7078
name = f.name
7179

python/ray/data/_internal/table_block.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ def _compact_if_needed(self) -> None:
146146
assert self._columns
147147
if self._uncompacted_size.size_bytes() < MAX_UNCOMPACTED_SIZE_BYTES:
148148
return
149-
block = self._table_from_pydict(self._columns)
149+
columns = {
150+
key: convert_udf_returns_to_numpy(col) for key, col in self._columns.items()
151+
}
152+
block = self._table_from_pydict(columns)
150153
self.add_block(block)
151154
self._uncompacted_size = SizeEstimator()
152155
self._columns.clear()

0 commit comments

Comments
 (0)