Reference for ultralytics/data/build.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/data/build.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.data.build.InfiniteDataLoader
Bases: DataLoader
Dataloader that reuses workers.
Uses same syntax as vanilla DataLoader.
Source code in ultralytics/data/build.py
__iter__
__len__
reset
Reset iterator.
This is useful when we want to modify settings of dataset while training.
ultralytics.data.build._RepeatSampler
Sampler that repeats forever.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sampler |
sampler
|
The sampler to repeat. |
required |
Source code in ultralytics/data/build.py
ultralytics.data.build.seed_worker
Set dataloader worker seed https://pytorch.org/docs/stable/notes/randomness.html#dataloader.
ultralytics.data.build.build_yolo_dataset
build_yolo_dataset(
cfg,
img_path,
batch,
data,
mode="train",
rect=False,
stride=32,
multi_modal=False,
)
Build YOLO Dataset.
Source code in ultralytics/data/build.py
ultralytics.data.build.build_grounding
Build YOLO Dataset.
Source code in ultralytics/data/build.py
ultralytics.data.build.build_dataloader
Return an InfiniteDataLoader or DataLoader for training or validation set.
Source code in ultralytics/data/build.py
ultralytics.data.build.check_source
Check source type and return corresponding flag values.
Source code in ultralytics/data/build.py
ultralytics.data.build.load_inference_source
Loads an inference source for object detection and applies necessary transformations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
(str, Path, Tensor, Image, ndarray)
|
The input source for inference. |
None
|
batch |
int
|
Batch size for dataloaders. Default is 1. |
1
|
vid_stride |
int
|
The frame interval for video sources. Default is 1. |
1
|
buffer |
bool
|
Determined whether stream frames will be buffered. Default is False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
dataset |
Dataset
|
A dataset object for the specified input source. |