Change from 'if' to 'elif'
Summary:
'if' is changed to 'elif' in case only one of several condition statements is executed A small increase in performance may increase readability.
Pull Request resolved:
@@ -72,14 +72,14 @@ class Trainer(DefaultTrainer):
evaluator_list.append(COCOEvaluator(dataset_name, cfg, True, output_folder))
if evaluator_type == "coco_panoptic_seg":
evaluator_list.append(COCOPanopticEvaluator(dataset_name, output_folder))
- if evaluator_type == "cityscapes":
+ elif evaluator_type == "cityscapes":
assert (
torch.cuda.device_count() >= comm.get_rank()
), "CityscapesEvaluator currently do not work with multiple machines."
return CityscapesEvaluator(dataset_name)
- if evaluator_type == "pascal_voc":
+ elif evaluator_type == "pascal_voc":
return PascalVOCDetectionEvaluator(dataset_name)
- if evaluator_type == "lvis":
+ elif evaluator_type == "lvis":
return LVISEvaluator(dataset_name, cfg, True, output_folder)
if len(evaluator_list) == 0:
raise NotImplementedError(
@@ -87,7 +87,7 @@ class Trainer(DefaultTrainer):
dataset_name, evaluator_type
)
)
- if len(evaluator_list) == 1:
+ elif len(evaluator_list) == 1:
return evaluator_list[0]
return DatasetEvaluators(evaluator_list)
