@@ -154,8 +154,9 @@ def __getitem__(self, index):
154
154
if self .debug and "test" in self .split :
155
155
outdir = f"debug/sectionLoader_{ self .split } _raw"
156
156
generate_path (outdir )
157
- image_to_disk (im , f"{ outdir } /index_{ index } _section_{ section_name } _img.png" )
158
- mask_to_disk (lbl , f"{ outdir } /index_{ index } _section_{ section_name } _lbl.png" )
157
+ path_prefix = f"{ outdir } /index_{ index } _section_{ section_name } "
158
+ image_to_disk (im , path_prefix + "_img.png" )
159
+ mask_to_disk (lbl , path_prefix + "_lbl.png" , self .n_classes )
159
160
160
161
if self .augmentations is not None :
161
162
augmented_dict = self .augmentations (image = im , mask = lbl )
@@ -167,8 +168,9 @@ def __getitem__(self, index):
167
168
if self .debug and "test" in self .split :
168
169
outdir = f"debug/sectionLoader_{ self .split } _{ 'aug' if self .augmentations is not None else 'noaug' } "
169
170
generate_path (outdir )
170
- image_to_disk (np .array (im [0 ]), f"{ outdir } /index_{ index } _section_{ section_name } _img.png" )
171
- mask_to_disk (np .array (lbl [0 ]), f"{ outdir } /index_{ index } _section_{ section_name } _lbl.png" )
171
+ path_prefix = f"{ outdir } /index_{ index } _section_{ section_name } "
172
+ image_to_disk (np .array (im [0 ]), path_prefix + "_img.png" )
173
+ mask_to_disk (np .array (lbl [0 ]), path_prefix + "_lbl.png" , self .n_classes )
172
174
173
175
return im , lbl
174
176
@@ -408,8 +410,9 @@ def __getitem__(self, index):
408
410
outdir = f"debug/testSectionLoaderWithDepth_{ self .split } _raw"
409
411
generate_path (outdir )
410
412
# this needs to take the first dimension of image (no depth) but lbl only has 1 dim
411
- image_to_disk (im [0 , :, :], f"{ outdir } /index_{ index } _section_{ section_name } _img.png" )
412
- mask_to_disk (lbl , f"{ outdir } /index_{ index } _section_{ section_name } _lbl.png" )
413
+ path_prefix = f"{ outdir } /index_{ index } _section_{ section_name } "
414
+ image_to_disk (im [0 , :, :], path_prefix + "_img.png" )
415
+ mask_to_disk (lbl , path_prefix + "_lbl.png" , self .n_classes )
413
416
414
417
if self .augmentations is not None :
415
418
im = _transform_CHW_to_HWC (im )
@@ -426,8 +429,9 @@ def __getitem__(self, index):
426
429
f"debug/testSectionLoaderWithDepth_{ self .split } _{ 'aug' if self .augmentations is not None else 'noaug' } "
427
430
)
428
431
generate_path (outdir )
429
- image_to_disk (np .array (im [0 , :, :]), f"{ outdir } /index_{ index } _section_{ section_name } _img.png" )
430
- mask_to_disk (np .array (lbl [0 , :, :]), f"{ outdir } /index_{ index } _section_{ section_name } _lbl.png" )
432
+ path_prefix = f"{ outdir } /index_{ index } _section_{ section_name } "
433
+ image_to_disk (np .array (im [0 , :, :]), path_prefix + "_img.png" )
434
+ mask_to_disk (np .array (lbl [0 , :, :]), path_prefix + "_lbl.png" , self .n_classes )
431
435
432
436
return im , lbl
433
437
@@ -495,8 +499,9 @@ def __getitem__(self, index):
495
499
if self .debug :
496
500
outdir = f"debug/patchLoader_{ self .split } _raw"
497
501
generate_path (outdir )
498
- image_to_disk (im , f"{ outdir } /index_{ index } _section_{ patch_name } _img.png" )
499
- mask_to_disk (lbl , f"{ outdir } /index_{ index } _section_{ patch_name } _lbl.png" )
502
+ path_prefix = f"{ outdir } /index_{ index } _section_{ patch_name } "
503
+ image_to_disk (im , path_prefix + "_img.png" )
504
+ mask_to_disk (lbl , path_prefix + "_lbl.png" , self .n_classes )
500
505
501
506
if self .augmentations is not None :
502
507
augmented_dict = self .augmentations (image = im , mask = lbl )
@@ -506,8 +511,9 @@ def __getitem__(self, index):
506
511
if self .debug :
507
512
outdir = f"patchLoader_{ self .split } _{ 'aug' if self .augmentations is not None else 'noaug' } "
508
513
generate_path (outdir )
509
- image_to_disk (im , f"{ outdir } /{ index } _img.png" )
510
- mask_to_disk (lbl , f"{ outdir } /{ index } _lbl.png" )
514
+ path_prefix = f"{ outdir } /{ index } "
515
+ image_to_disk (im , path_prefix + "_img.png" )
516
+ mask_to_disk (lbl , path_prefix + "_lbl.png" , self .n_classes )
511
517
512
518
if self .is_transform :
513
519
im , lbl = self .transform (im , lbl )
@@ -516,8 +522,9 @@ def __getitem__(self, index):
516
522
if self .debug :
517
523
outdir = f"debug/patchLoader_{ self .split } _{ 'aug' if self .augmentations is not None else 'noaug' } "
518
524
generate_path (outdir )
519
- image_to_disk (np .array (im [0 , :, :]), f"{ outdir } /index_{ index } _section_{ patch_name } _img.png" )
520
- mask_to_disk (np .array (lbl [0 , :, :]), f"{ outdir } /index_{ index } _section_{ patch_name } _lbl.png" )
525
+ path_prefix = f"{ outdir } /index_{ index } _section_{ patch_name } "
526
+ image_to_disk (np .array (im [0 , :, :]), path_prefix + "_img.png" )
527
+ mask_to_disk (np .array (lbl [0 , :, :]), path_prefix + "_lbl.png" , self .n_classes )
521
528
522
529
return im , lbl
523
530
@@ -761,8 +768,9 @@ def __getitem__(self, index):
761
768
if self .debug :
762
769
outdir = f"debug/patchLoaderWithSectionDepth_{ self .split } _raw"
763
770
generate_path (outdir )
764
- image_to_disk (im [0 , :, :], f"{ outdir } /index_{ index } _section_{ patch_name } _img.png" )
765
- mask_to_disk (lbl , f"{ outdir } /index_{ index } _section_{ patch_name } _lbl.png" )
771
+ path_prefix = f"{ outdir } /index_{ index } _section_{ patch_name } "
772
+ image_to_disk (im [0 , :, :], path_prefix + "_img.png" )
773
+ mask_to_disk (lbl , path_prefix + "_lbl.png" , self .n_classes )
766
774
767
775
if self .augmentations is not None :
768
776
im = _transform_CHW_to_HWC (im )
@@ -774,8 +782,9 @@ def __getitem__(self, index):
774
782
if self .debug :
775
783
outdir = f"patchLoaderWithSectionDepth_{ self .split } _{ 'aug' if self .augmentations is not None else 'noaug' } "
776
784
generate_path (outdir )
777
- image_to_disk (im [0 ,:,:], f"{ outdir } /{ index } _img.png" )
778
- mask_to_disk (lbl , f"{ outdir } /{ index } _lbl.png" )
785
+ path_prefix = f"{ outdir } /{ index } "
786
+ image_to_disk (im [0 , :, :], path_prefix + "_img.png" )
787
+ mask_to_disk (lbl , path_prefix + "_lbl.png" , self .n_classes )
779
788
780
789
if self .is_transform :
781
790
im , lbl = self .transform (im , lbl )
@@ -786,8 +795,9 @@ def __getitem__(self, index):
786
795
f"debug/patchLoaderWithSectionDepth_{ self .split } _{ 'aug' if self .augmentations is not None else 'noaug' } "
787
796
)
788
797
generate_path (outdir )
789
- image_to_disk (np .array (im [0 , :, :]), f"{ outdir } /index_{ index } _section_{ patch_name } _img.png" )
790
- mask_to_disk (np .array (lbl [0 , :, :]), f"{ outdir } /index_{ index } _section_{ patch_name } _lbl.png" )
798
+ path_prefix = f"{ outdir } /index_{ index } _section_{ patch_name } "
799
+ image_to_disk (np .array (im [0 , :, :]), path_prefix + "_img.png" )
800
+ mask_to_disk (np .array (lbl [0 , :, :]), path_prefix + "_lbl.png" , self .n_classes )
791
801
792
802
return im , lbl
793
803
0 commit comments