segmentation
SegmentationDataModule(data_path, name='segmentation_datamodule', test_size=0.3, val_size=0.3, seed=42, dataset=SegmentationDataset, batch_size=32, num_workers=6, train_transform=None, test_transform=None, val_transform=None, train_split_file=None, test_split_file=None, val_split_file=None, num_data_class=None, exclude_good=False, **kwargs)
¶
Bases: BaseDataModule
Base class for segmentation datasets.
Parameters:
-
data_path
(
str
) –Path to the data main folder.
-
name
(
str
, default:'segmentation_datamodule'
) –The name for the data module. Defaults to "segmentation_datamodule".
-
val_size
(
float
, default:0.3
) –The validation split. Defaults to 0.2.
-
test_size
(
float
, default:0.3
) –The test split. Defaults to 0.2.
-
seed
(
int
, default:42
) –Random generator seed. Defaults to 42.
-
dataset
(
type[SegmentationDataset]
, default:SegmentationDataset
) –Dataset class.
-
batch_size
(
int
, default:32
) –Batch size. Defaults to 32.
-
num_workers
(
int
, default:6
) –Number of workers for dataloaders. Defaults to 16.
-
train_transform
(
Compose | None
, default:None
) –Transformations for train dataset. Defaults to None.
-
val_transform
(
Compose | None
, default:None
) –Transformations for validation dataset. Defaults to None.
-
test_transform
(
Compose | None
, default:None
) –Transformations for test dataset. Defaults to None.
-
num_data_class
(
int | None
, default:None
) –The number of samples per class. Defaults to None.
-
exclude_good
(
bool
, default:False
) –If True, exclude good samples from the dataset. Defaults to False.
Source code in quadra/datamodules/segmentation.py
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 |
|
predict_dataloader()
¶
Returns a dataloader used for predictions.
Source code in quadra/datamodules/segmentation.py
365 366 367 |
|
setup(stage=None)
¶
Setup data module based on stages of training.
Source code in quadra/datamodules/segmentation.py
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 |
|
test_dataloader()
¶
Returns the test dataloader.
Raises:
-
ValueError
–If test dataset is not initialized.
Returns:
-
DataLoader
–test dataloader.
Source code in quadra/datamodules/segmentation.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
|
train_dataloader()
¶
Returns the train dataloader.
Raises:
-
ValueError
–If train dataset is not initialized.
Returns:
-
DataLoader
–Train dataloader.
Source code in quadra/datamodules/segmentation.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
val_dataloader()
¶
Returns the validation dataloader.
Raises:
-
ValueError
–If validation dataset is not initialized.
Returns:
-
DataLoader
–val dataloader.
Source code in quadra/datamodules/segmentation.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
SegmentationMulticlassDataModule(data_path, idx_to_class, name='multiclass_segmentation_datamodule', dataset=SegmentationDatasetMulticlass, batch_size=32, test_size=0.3, val_size=0.3, seed=42, num_workers=6, train_transform=None, test_transform=None, val_transform=None, train_split_file=None, test_split_file=None, val_split_file=None, exclude_good=False, num_data_train=None, one_hot_encoding=False, **kwargs)
¶
Bases: BaseDataModule
Base class for segmentation datasets with multiple classes.
Parameters:
-
data_path
–
Path to the data main folder.
-
idx_to_class
(
dict
) –dict with corrispondence btw mask index and classes: {1: class_1, 2: class_2, ..., N: class_N} except background class which is 0.
-
name
–
The name for the data module. Defaults to "multiclass_segmentation_datamodule".
-
dataset
(
type[SegmentationDatasetMulticlass]
, default:SegmentationDatasetMulticlass
) –Dataset class.
-
batch_size
–
Batch size. Defaults to 32.
-
val_size
–
The validation split. Defaults to 0.3.
-
test_size
–
The test split. Defaults to 0.3.
-
seed
–
Random generator seed. Defaults to 42.
-
num_workers
(
int
, default:6
) –Number of workers for dataloaders. Defaults to 6.
-
train_transform
(
Compose | None
, default:None
) –Transformations for train dataset. Defaults to None.
-
val_transform
–
Transformations for validation dataset. Defaults to None.
-
test_transform
–
Transformations for test dataset. Defaults to None.
-
train_split_file
(
str | None
, default:None
) –path to txt file with training samples list
-
val_split_file
(
str | None
, default:None
) –path to txt file with validation samples list
-
test_split_file
(
str | None
, default:None
) –path to txt file with test samples list
-
exclude_good
–
If True, exclude good samples from the dataset. Defaults to False.
-
num_data_train
(
int | None
, default:None
) –number of samples to use in the train split (shuffle the samples and pick the first num_data_train)
-
one_hot_encoding
(
bool
, default:False
) –if True, the labels are one-hot encoded to N channels, where N is the number of classes. If False, masks are single channel that contains values as class indexes. Defaults to True.
Source code in quadra/datamodules/segmentation.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
|
predict_dataloader()
¶
Returns a dataloader used for predictions.
Source code in quadra/datamodules/segmentation.py
740 741 742 |
|
setup(stage=None)
¶
Setup data module based on stages of training.
Source code in quadra/datamodules/segmentation.py
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 |
|
test_dataloader()
¶
Returns the test dataloader.
Raises:
-
ValueError
–If test dataset is not initialized.
Returns:
-
DataLoader
–test dataloader.
Source code in quadra/datamodules/segmentation.py
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 |
|
train_dataloader()
¶
Returns the train dataloader.
Raises:
-
ValueError
–If train dataset is not initialized.
Returns:
-
DataLoader
–Train dataloader.
Source code in quadra/datamodules/segmentation.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
|
val_dataloader()
¶
Returns the validation dataloader.
Raises:
-
ValueError
–If validation dataset is not initialized.
Returns:
-
DataLoader
–val dataloader.
Source code in quadra/datamodules/segmentation.py
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
|