3232DEFAULT_VALID_LABELS = (7 , 8 , 11 , 12 , 13 , 17 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 31 , 32 , 33 )
3333
3434
35+ def _create_synth_Cityscapes_dataset (path_dir ):
36+ """Create synthetic dataset with random images, just to simulate that the dataset have been already downloaded."""
37+ non_existing_citites = ['dummy_kitti_1' , 'dummy_kitti_2' ]
38+ fine_labels_dir = Path (path_dir ) / 'gtFine'
39+ images_dir = Path (path_dir ) / 'leftImg8bit'
40+ dataset_splits = ['train' , 'val' , 'test' ]
41+
42+ for split in dataset_splits :
43+ for city in non_existing_citites :
44+ (images_dir / split / city ).mkdir (parents = True )
45+ (fine_labels_dir / split / city ).mkdir (parents = True )
46+ base_name = str (uuid .uuid4 ())
47+ image_name = f'{ base_name } _leftImg8bit.png'
48+ instance_target_name = f'{ base_name } _gtFine_instanceIds.png'
49+ semantic_target_name = f'{ base_name } _gtFine_labelIds.png'
50+ Image .new ('RGB' , (2048 , 1024 )).save (
51+ images_dir / split / city / image_name )
52+ Image .new ('L' , (2048 , 1024 )).save (
53+ fine_labels_dir / split / city / instance_target_name )
54+ Image .new ('L' , (2048 , 1024 )).save (
55+ fine_labels_dir / split / city / semantic_target_name )
56+
57+
3558class KITTI (Dataset ):
3659 """
3760 Class for KITTI Semantic Segmentation Benchmark dataset
@@ -53,6 +76,8 @@ class KITTI(Dataset):
5376 In the `get_item` function, images and masks are resized to the given `img_size`, masks are
5477 encoded using `encode_segmap`, and given `transform` (if any) are applied to the image only
5578 (mask does not usually require transforms, but they can be implemented in a similar way).
79+
80+ >>> KITTI() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
5681 """
5782 IMAGE_PATH = os .path .join ('training' , 'image_2' )
5883 MASK_PATH = os .path .join ('training' , 'semantic' )
@@ -141,6 +166,8 @@ class SegModel(pl.LightningModule):
141166 It uses the FCN ResNet50 model as an example.
142167
143168 Adam optimizer is used along with Cosine Annealing learning rate scheduler.
169+
170+ >>> SegModel() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
144171 """
145172 def __init__ (
146173 self ,
0 commit comments