Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data] Cherry-pick object detection example to 2.5.0 release #35637

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/source/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ parts:
- file: data/examples/ocr_example
title: Scaling OCR with Ray Data
- file: data/examples/random-access
- file: data/examples/batch_inference_object_detection
title: Object Detection Batch Inference with PyTorch
- file: data/faq
- file: data/api/api
- file: data/glossary
Expand Down
8 changes: 8 additions & 0 deletions doc/source/data/batch_inference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,14 @@ tutorials and examples:

Batch Inference on NYC taxi data using Ray Data

.. grid-item-card::
:img-top: /images/ray_logo.png
:class-img-top: pt-2 w-75 d-block mx-auto fixed-height-img

.. button-ref:: /data/examples/batch_inference_object_detection

Object Detection Batch Inference with PyTorch

.. grid-item-card::
:img-top: /images/ray_logo.png
:class-img-top: pt-2 w-75 d-block mx-auto fixed-height-img
Expand Down
8 changes: 8 additions & 0 deletions doc/source/data/examples/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ filegroup(
srcs = glob(["*.ipynb"]),
visibility = ["//doc:__subpackages__"]
)

py_test_run_all_notebooks(
size = "medium",
include = ["batch_inference_object_detection.ipynb"],
exclude = [],
data = ["//doc/source/data/examples:data_examples"],
tags = ["exclusive", "team:data", "gpu"],
)
1,059 changes: 1,059 additions & 0 deletions doc/source/data/examples/batch_inference_object_detection.ipynb

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion doc/test_myst_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ def postprocess_notebook(notebook):
return notebook


if __name__ == "__main__":
DISPLAY_FUNCTION = """
def display(*args, **kwargs):
print(*args, **kwargs)
"""


if __name__ == "__main__":
args, remainder = parser.parse_known_args()

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

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

Expand Down
5 changes: 4 additions & 1 deletion python/ray/data/_internal/table_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ def _compact_if_needed(self) -> None:
assert self._columns
if self._uncompacted_size.size_bytes() < MAX_UNCOMPACTED_SIZE_BYTES:
return
block = self._table_from_pydict(self._columns)
columns = {
key: convert_udf_returns_to_numpy(col) for key, col in self._columns.items()
}
block = self._table_from_pydict(columns)
self.add_block(block)
self._uncompacted_size = SizeEstimator()
self._columns.clear()
Expand Down