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] minor updates for the object detection example #44168

Merged
merged 1 commit into from
Mar 20, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
"from torchvision.transforms.functional import to_pil_image\n",
"\n",
"labels = [weights.meta[\"categories\"][i] for i in prediction[\"labels\"]]\n",
"box = draw_bounding_boxes(img, \n",
"box = draw_bounding_boxes(img,\n",
" boxes=prediction[\"boxes\"],\n",
" labels=labels,\n",
" colors=\"red\",\n",
Expand All @@ -444,7 +444,7 @@
"source": [
"## Scaling with Ray Data\n",
"\n",
"Then let's see how to scale the previous example to a large set of images. We will use Ray Data to do batch inference in a distributed fashion, leveraging all the CPU and GPU resources in our cluster.\n",
"Then let's see how to scale the previous example to a large set of images. We will use Ray Data to do batch inference in a streaming and distributed fashion, leveraging all the CPU and GPU resources in our cluster.\n",
"\n",
"### Loading the Image Dataset\n",
"\n",
Expand Down Expand Up @@ -536,7 +536,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Then we use the {meth}`map <ds.data.Dataset.map>` API to apply the function to the whole dataset. By using Ray Data's map, we can scale out the preprocessing to all the resources in our Ray cluster Note, the `map` method is lazy, it won't perform execution until we start to consume the results."
"Then we use the {meth}`map <ds.data.Dataset.map>` API to apply the function to the whole dataset. By using Ray Data's map, we can scale out the preprocessing to all the resources in our Ray cluster. Note, the `map` method is lazy, it won't perform execution until we start to consume the results."
]
},
{
Expand Down Expand Up @@ -944,9 +944,11 @@
"source": [
"ds = ds.map_batches(\n",
" ObjectDetectionModel,\n",
" concurrency=4, # Use 4 GPUs. Change this number based on the number of GPUs in your cluster.\n",
" batch_size=4, # Use the largest batch size that can fit in GPU memory.\n",
" num_gpus=1, # Specify 1 GPU per model replica. Remove this if you are doing CPU inference.\n",
" # Use 4 GPUs. Change this number based on the number of GPUs in your cluster.\n",
" concurrency=4,\n",
" batch_size=4, # Use the largest batch size that can fit in GPU memory.\n",
" # Specify 1 GPU per model replica. Remove this if you are doing CPU inference.\n",
" num_gpus=1,\n",
")"
]
},
Expand Down
Loading