Dataloaders
BaseDataloaderAdapterFactory
Bases: ABC
Factory class, responsible for adapting datasets/dataloaders to seamlessly work with SG format.
Source code in src/super_gradients/training/dataloaders/adapters.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
from_dataloader(dataloader, config=None, config_path=None)
classmethod
Wrap a DataLoader to adapt its output to fit SuperGradients format for the specific task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataloader |
torch.utils.data.DataLoader
|
DataLoader to adapt. |
required |
config |
Optional[DataConfig]
|
Adapter configuration. Use this if you want to explicitly set some specific params of your dataset. Mutually exclusive with |
None
|
config_path |
Optional[str]
|
Adapter cache path. Use this if you want to load and/or save the adapter config from a local path. Mutually exclusive with |
None
|
Returns:
Type | Description |
---|---|
torch.utils.data.DataLoader
|
Adapted DataLoader. |
Source code in src/super_gradients/training/dataloaders/adapters.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
from_dataset(dataset, config=None, config_path=None, collate_fn=None, **dataloader_kwargs)
classmethod
Wrap a DataLoader to adapt its output to fit SuperGradients format for the specific task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
torch.utils.data.Dataset
|
Dataset to adapt. |
required |
config |
Optional[DataConfig]
|
Adapter configuration. Use this if you want to explicitly set some specific params of your dataset. Mutually exclusive with |
None
|
config_path |
Optional[str]
|
Adapter cache path. Use this if you want to load and/or save the adapter config from a local path. Mutually exclusive with |
None
|
collate_fn |
Optional[callable]
|
Collate function to use. Use this if you .If None, the pytorch default collate function will be used. |
None
|
Returns:
Type | Description |
---|---|
torch.utils.data.DataLoader
|
Adapted DataLoader. |
Source code in src/super_gradients/training/dataloaders/adapters.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
DetectionDataloaderAdapterFactory
Bases: BaseDataloaderAdapterFactory
Factory class, responsible for adapting datasets/dataloaders to seamlessly work with SG YOLOX, YOLONAS and PPYOLOE
Source code in src/super_gradients/training/dataloaders/adapters.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
maybe_setup_dataloader_adapter(dataloader)
If the dataloader collate function is an adapter, and requires to be set up, do it. Otherwise skip.
Source code in src/super_gradients/training/dataloaders/adapters.py
126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
get(name=None, dataset_params=None, dataloader_params=None, dataset=None)
Get DataLoader of the recipe-configured dataset defined by name in ALL_DATALOADERS.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
dataset name in ALL_DATALOADERS. |
None
|
dataset_params |
Dict
|
dataset params that override the yaml configured defaults, then passed to the dataset_cls.init. |
None
|
dataloader_params |
Dict
|
DataLoader params that override the yaml configured defaults, then passed to the DataLoader.init |
None
|
dataset |
torch.utils.data.Dataset
|
torch.utils.data.Dataset to be used instead of passing "name" (i.e for external dataset objects). |
None
|
Returns:
Type | Description |
---|---|
DataLoader
|
initialized DataLoader. |
Source code in src/super_gradients/training/dataloaders/dataloaders.py
889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 |
|
get_data_loader(config_name, dataset_cls, train, dataset_params=None, dataloader_params=None)
Class for creating dataloaders for taking defaults from yaml files in src/super_gradients/recipes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_name |
str
|
yaml config filename of dataset_params in recipes (for example coco_detection_dataset_params). |
required |
dataset_cls |
object
|
torch dataset uninitialized class. |
required |
train |
bool
|
controls whether to take cfg.train_dataloader_params or cfg.valid_dataloader_params as defaults for the dataset constructor and cfg.train_dataset_params or cfg.valid_dataset_params as defaults for DataLoader contructor. |
required |
dataset_params |
Mapping
|
dataset params that override the yaml configured defaults, then passed to the dataset_cls.init. |
None
|
dataloader_params |
Mapping
|
DataLoader params that override the yaml configured defaults, then passed to the DataLoader.init |
None
|
Returns:
Type | Description |
---|---|
DataLoader
|
DataLoader |
Source code in src/super_gradients/training/dataloaders/dataloaders.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|