deeplabcut.pose_estimation_pytorch.data.base
Classes:
| Name | Description |
|---|---|
Loader |
Abstract class that represents a blueprint for loading and processing dataset |
Loader
Bases: ABC
Abstract class that represents a blueprint for loading and processing dataset information.
Methods:
| Name | Description |
|---|---|
load_data |
str = 'train') -> dict: Abstract method to convert the project configuration to a standard COCO format. |
create_dataset |
dict = None, annotations: dict = None, transform: object = None, mode: str = "train", task: Task = Task.BOTTOM_UP) -> PoseDataset: Creates and returns a PoseDataset given a set of images, annotations, and other parameters. |
_compute_bboxes |
str = 'gt') -> dict: Retrieves all bounding boxes based on the specified method. |
get_dataset_parameters |
Returns a dictionary containing dataset parameters derived from the configuration. |
Attributes:
| Name | Type | Description |
|---|---|---|
model_folder |
Path
|
Returns: The path of the folder containing the model data |
Source code in deeplabcut/pose_estimation_pytorch/data/base.py
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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
create_dataset
create_dataset(transform: BaseCompose | None = None, mode: str = 'train', task: Task = Task.BOTTOM_UP) -> PoseDataset
Creates a PoseDataset based on provided arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
BaseCompose | None
|
Transformation to be applied on dataset. Defaults to None. |
None
|
|
str
|
Mode in which dataset is to be used (e.g., 'train', 'test'). Defaults to 'train'. |
'train'
|
|
Task
|
Task for which the dataset is being used. Defaults to 'BU'. |
BOTTOM_UP
|
Returns:
| Name | Type | Description |
|---|---|---|
PoseDataset |
PoseDataset
|
An instance of the PoseDataset class. |
Source code in deeplabcut/pose_estimation_pytorch/data/base.py
filter_annotations
staticmethod
Filters annotations based on the task, removing empty annotations.
For pose estimation tasks, annotations with empty keypoints are removed. For detection task, annotations with no bounding boxes are removed
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[dict]
|
the annotations to filter |
required |
|
Task
|
the task for which to filter |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
list[dict]
|
the filtered annotations |
Source code in deeplabcut/pose_estimation_pytorch/data/base.py
get_dataset_parameters
abstractmethod
Retrieves dataset parameters based on the instance's configuration.
Returns:
| Type | Description |
|---|---|
PoseDatasetParameters
|
An instance of the PoseDatasetParameters with the parameters set. |
Source code in deeplabcut/pose_estimation_pytorch/data/base.py
ground_truth_bboxes
Creates a dictionary containing the ground truth bounding boxes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
{"train", "test"} whether to load train or test data |
'train'
|
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
A dict mapping image paths to the ground truth annotations for the mode in the format: { 'path/to/image000.png': { "width": (int) the width of the image, in pixels "height": (int) the height of the image, in pixels "bboxes": (np.ndarray) bboxes with shape (num_individuals, xywh) }, 'path/to/image000.png': {...}, } |
Source code in deeplabcut/pose_estimation_pytorch/data/base.py
ground_truth_keypoints
Creates a dictionary containing the ground truth data.
TODO: make more efficient
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
{"train", "test"} whether to load train or test data |
'train'
|
|
bool
|
returns the ground truth for unique bodyparts |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
A dict mapping image paths to the ground truth annotations for the mode in the format: |
Source code in deeplabcut/pose_estimation_pytorch/data/base.py
image_filenames
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
{"train", "test"} whether to load train or test data |
'train'
|
Returns:
| Type | Description |
|---|---|
list[str]
|
the image paths for this mode |
Source code in deeplabcut/pose_estimation_pytorch/data/base.py
load_data
abstractmethod
Abstract method to convert the project configuration to a standard coco format.
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
This method must be implemented in the derived classes. |
Source code in deeplabcut/pose_estimation_pytorch/data/base.py
snapshots
Lists snapshots saved for the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
If the Loader is for a Top-Down model, passing detector=True will return the snapshots for the detector. Otherwise, the snapshots for the pose model are returned. |
False
|
|
bool
|
Whether to place the snapshot with the best performance in the last position in the list, even if it wasn't the last epoch. |
True
|
Returns:
| Type | Description |
|---|---|
list[Snapshot]
|
The snapshots stored in a folder, sorted by the number of epochs they were trained for. If best_in_last=True and a best snapshot exists, it will be the last one in the list. |
Source code in deeplabcut/pose_estimation_pytorch/data/base.py
update_model_cfg
Updates the model configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict
|
the items to update in the model configuration |
required |