1616from torch .utils .data .dataloader import DataLoader
1717
1818from src .datasets .semantic_segmentation import (
19- SemanticSegmentationDataset ,
19+ SemanticSegmentationPyTorchDataset ,
2020 SemanticSegmentationStochasticPatchingDataset ,
2121 ToySemanticSegmentationDataset ,
2222)
@@ -151,7 +151,7 @@ def forward(self, x):
151151 default = "" ,
152152 )
153153 parser .add_argument ("--toy" , type = bool , required = False , default = False )
154- parser .add_argument ("--classes" , type = str , default = "1, 2, 3, 4 " )
154+ parser .add_argument ("--classes" , type = str , default = "1, 2" )
155155 parser .add_argument (
156156 "--log-file" , type = str , required = False , default = "train.log"
157157 )
@@ -195,7 +195,7 @@ def forward(self, x):
195195 "--class-balance" , type = str2bool , required = False , default = False
196196 )
197197 parser .add_argument (
198- "--cache-strategy" , type = str , required = False , default = "memory "
198+ "--cache-strategy" , type = str , required = False , default = "none "
199199 )
200200 args = parser .parse_args ()
201201
@@ -204,8 +204,8 @@ def forward(self, x):
204204
205205 train_dir = str (args .train_dir )
206206 val_dir = str (args .val_dir )
207- experiment_dir = str ( uuid . uuid4 ())
208- model_dir = join (train_dir , experiment_dir )
207+
208+ model_dir = join ("outputs" , "models" )
209209 Path (model_dir ).mkdir (parents = True , exist_ok = True )
210210
211211 if args .cache_dir is not None :
@@ -285,7 +285,7 @@ def forward(self, x):
285285 )
286286 # Toy Dataset for Integration Testing Purposes
287287 Dataset = (
288- SemanticSegmentationDataset
288+ SemanticSegmentationPyTorchDataset
289289 if not is_toy
290290 else ToySemanticSegmentationDataset
291291 )
@@ -355,14 +355,18 @@ def forward(self, x):
355355 f"Validation dataset number of images: { dataset_val_len } | Batch size: { batch_size } | Expected number of batches: { tot_validation_batches } "
356356 )
357357
358- num_classes : int = classes [- 1 ] + 1 # Plus 1 for background
359- classes = [class_id_to_class_name [i ] for i in range (num_classes )]
358+ num_classes : int = len (classes ) + 1 # Plus 1 for background
360359
361360 # define training and validation data loaders
362361 # drop_last True to avoid single instances which throw an error on batch norm layers
363362
364363 # Maxing the num_workers at 8 due to shared memory limitations
365- num_workers = min (int (round (multiprocessing .cpu_count () * 2 / 3 )), 8 )
364+ num_workers = min (
365+ # Preferably use 2/3's of total cpus. If the cpu count is 1, it will be set to 0 which will result
366+ # in dataloader using the main thread
367+ int (round (multiprocessing .cpu_count () * 2 / 3 )),
368+ 8 ,
369+ )
366370
367371 dataloader = DataLoader (
368372 dataset ,
@@ -386,7 +390,9 @@ def forward(self, x):
386390 model = get_fcn_resnet50 (num_classes , pretrained = pretrained )
387391 elif model_name == "deeplab" :
388392 model = DeepLabModelWrapper (
389- num_classes , pretrained = pretrained
393+ num_classes ,
394+ pretrained = pretrained ,
395+ is_feature_extracting = pretrained ,
390396 ) # get_deeplabv3(num_classes, is_feature_extracting=pretrained)
391397 else :
392398 raise ValueError (
0 commit comments