diff --git a/dygraph/datasets/ade.py b/dygraph/datasets/ade.py index 6a220adb91430a96d443556cc97bd1e770b90bc6..7144fd0f567f03356d72cb15c7ea54d186807915 100644 --- a/dygraph/datasets/ade.py +++ b/dygraph/datasets/ade.py @@ -30,7 +30,7 @@ class ADE20K(Dataset): dataset_root: The dataset directory. mode: Which part of dataset to use.. it is one of ('train', 'val'). Default: 'train'. transforms: Transforms for image. - download: Whether to download dataset if dataset_root is None. + download: Whether to download dataset if `dataset_root` is None. """ def __init__(self, @@ -46,23 +46,23 @@ class ADE20K(Dataset): if mode.lower() not in ['train', 'val']: raise Exception( - "mode should be one of ('train', 'val') in ADE20K dataset, but got {}." + "`mode` should be one of ('train', 'val') in ADE20K dataset, but got {}." .format(mode)) if self.transforms is None: - raise Exception("transforms is necessary, but it is None.") + raise Exception("`transforms` is necessary, but it is None.") if self.dataset_root is None: if not download: raise Exception( - "dataset_root not set and auto download disabled.") + "`dataset_root` not set and auto download disabled.") self.dataset_root = download_file_and_uncompress( url=URL, savepath=DATA_HOME, extrapath=DATA_HOME, extraname='ADEChallengeData2016') elif not os.path.exists(self.dataset_root): - raise Exception('there is not dataset_root: {}.'.format( + raise Exception('there is not `dataset_root`: {}.'.format( self.dataset_root)) if mode == 'train': diff --git a/dygraph/datasets/cityscapes.py b/dygraph/datasets/cityscapes.py index 4e735fc250346bffd11a94432e0a49f331a79fd4..7f6c8742ffa287b31dad7394b4cd89db2a72bfc9 100644 --- a/dygraph/datasets/cityscapes.py +++ b/dygraph/datasets/cityscapes.py @@ -53,7 +53,7 @@ class Cityscapes(Dataset): mode)) if self.transforms is None: - raise Exception("transforms is necessary, but it is None.") + raise Exception("`transforms` is necessary, but it is None.") img_dir = os.path.join(self.dataset_root, 'leftImg8bit') grt_dir = os.path.join(self.dataset_root, 'gtFine') diff --git a/dygraph/datasets/dataset.py b/dygraph/datasets/dataset.py index 0b0fca9dc78df1495b8bd24146c6aaa0d2be59c6..5853103582cfb0ebefdaebe36e11d51231a0d493 100644 --- a/dygraph/datasets/dataset.py +++ b/dygraph/datasets/dataset.py @@ -63,39 +63,40 @@ class Dataset(fluid.io.Dataset): mode)) if self.transforms is None: - raise Exception("transforms is necessary, but it is None.") + raise Exception("`transforms` is necessary, but it is None.") self.dataset_root = dataset_root if not os.path.exists(self.dataset_root): - raise Exception('there is not dataset_root: {}.'.format( + raise Exception('there is not `dataset_root`: {}.'.format( self.dataset_root)) if mode == 'train': if train_list is None: raise Exception( - 'When mode is "train", train_list is necessary, but it is None.' + 'When `mode` is "train", `train_list` is necessary, but it is None.' ) elif not os.path.exists(train_list): raise Exception( - 'train_list is not found: {}'.format(train_list)) + '`train_list` is not found: {}'.format(train_list)) else: file_list = train_list elif mode == 'val': if val_list is None: raise Exception( - 'When mode is "val", val_list is necessary, but it is None.' + 'When `mode` is "val", `val_list` is necessary, but it is None.' ) elif not os.path.exists(val_list): - raise Exception('val_list is not found: {}'.format(val_list)) + raise Exception('`val_list` is not found: {}'.format(val_list)) else: file_list = val_list else: if test_list is None: raise Exception( - 'When mode is "test", test_list is necessary, but it is None.' + 'When `mode` is "test", `test_list` is necessary, but it is None.' ) elif not os.path.exists(test_list): - raise Exception('test_list is not found: {}'.format(test_list)) + raise Exception( + '`test_list` is not found: {}'.format(test_list)) else: file_list = test_list diff --git a/dygraph/datasets/optic_disc_seg.py b/dygraph/datasets/optic_disc_seg.py index a8c25a155fa9c06c54d635573b0020cc22c634d5..a59ac847dccb5a1b17738dcd67abc315ef076e30 100644 --- a/dygraph/datasets/optic_disc_seg.py +++ b/dygraph/datasets/optic_disc_seg.py @@ -35,19 +35,20 @@ class OpticDiscSeg(Dataset): if mode.lower() not in ['train', 'val', 'test']: raise Exception( - "mode should be 'train', 'val' or 'test', but got {}.".format( + "`mode` should be 'train', 'val' or 'test', but got {}.".format( mode)) if self.transforms is None: - raise Exception("transforms is necessary, but it is None.") + raise Exception("`transforms` is necessary, but it is None.") if self.dataset_root is None: if not download: - raise Exception("data_file not set and auto download disabled.") + raise Exception( + "`data_root` not set and auto download disabled.") self.dataset_root = download_file_and_uncompress( url=URL, savepath=DATA_HOME, extrapath=DATA_HOME) elif not os.path.exists(self.dataset_root): - raise Exception('there is not dataset_root: {}.'.format( + raise Exception('there is not `dataset_root`: {}.'.format( self.dataset_root)) if mode == 'train': diff --git a/dygraph/datasets/voc.py b/dygraph/datasets/voc.py index 8f8521cbb3d626c725a4510d02832a665adacd99..4e2dcf6c3fcc807d0996f498486e498a1151e330 100644 --- a/dygraph/datasets/voc.py +++ b/dygraph/datasets/voc.py @@ -43,23 +43,23 @@ class PascalVOC(Dataset): if mode.lower() not in ['train', 'trainval', 'trainaug', 'val']: raise Exception( - "mode should be one of ('train', 'trainval', 'trainaug', 'val') in PascalVOC dataset, but got {}." + "`mode` should be one of ('train', 'trainval', 'trainaug', 'val') in PascalVOC dataset, but got {}." .format(mode)) if self.transforms is None: - raise Exception("transforms is necessary, but it is None.") + raise Exception("`transforms` is necessary, but it is None.") if self.dataset_root is None: if not download: raise Exception( - "dataset_root not set and auto download disabled.") + "`dataset_root` not set and auto download disabled.") self.dataset_root = download_file_and_uncompress( url=URL, savepath=DATA_HOME, extrapath=DATA_HOME, extraname='VOCdevkit') elif not os.path.exists(self.dataset_root): - raise Exception('there is not dataset_root: {}.'.format( + raise Exception('there is not `dataset_root`: {}.'.format( self.dataset_root)) image_set_dir = os.path.join(self.dataset_root, 'VOC2012', 'ImageSets', @@ -76,7 +76,7 @@ class PascalVOC(Dataset): if not os.path.exists(file_list_aug): raise Exception( - "When mode is 'trainaug', Pascal Voc dataset should be augmented, " + "When `mode` is 'trainaug', Pascal Voc dataset should be augmented, " "Please make sure voc_augment.py has been properly run when using this mode." ) diff --git a/dygraph/infer.py b/dygraph/infer.py index 364287bda87ef80a4d6f9eb2540843279ffa4149..8111ff01a07e56aa3479a6ac08e49fb325968397 100644 --- a/dygraph/infer.py +++ b/dygraph/infer.py @@ -88,7 +88,7 @@ def main(args): else fluid.CPUPlace() if args.dataset not in DATASETS: - raise Exception('--dataset is invalid. it should be one of {}'.format( + raise Exception('`--dataset` is invalid. it should be one of {}'.format( str(list(DATASETS.keys())))) dataset = DATASETS[args.dataset] @@ -101,7 +101,7 @@ def main(args): if args.model_name not in MODELS: raise Exception( - '--model_name is invalid. it should be one of {}'.format( + '`--model_name` is invalid. it should be one of {}'.format( str(list(MODELS.keys())))) model = MODELS[args.model_name](num_classes=test_dataset.num_classes) diff --git a/dygraph/train.py b/dygraph/train.py index f6ccc39a22a9345b2e1d53fbe1650f88db96e512..8cd979654cc3ef8d0222c3668a3a7e0b26ce6656 100644 --- a/dygraph/train.py +++ b/dygraph/train.py @@ -13,21 +13,14 @@ # limitations under the License. import argparse -import os import paddle.fluid as fluid from paddle.fluid.dygraph.parallel import ParallelEnv -from paddle.fluid.io import DataLoader -from paddle.incubate.hapi.distributed import DistributedBatchSampler from datasets import DATASETS import transforms as T from models import MODELS -import utils.logging as logging from utils import get_environ_info -from utils import load_pretrained_model -from utils import resume -from utils import Timer, calculate_eta from core import train @@ -141,7 +134,7 @@ def main(args): else fluid.CPUPlace() if args.dataset not in DATASETS: - raise Exception('--dataset is invalid. it should be one of {}'.format( + raise Exception('`--dataset` is invalid. it should be one of {}'.format( str(list(DATASETS.keys())))) dataset = DATASETS[args.dataset] @@ -169,7 +162,7 @@ def main(args): if args.model_name not in MODELS: raise Exception( - '--model_name is invalid. it should be one of {}'.format( + '`--model_name` is invalid. it should be one of {}'.format( str(list(MODELS.keys())))) model = MODELS[args.model_name](num_classes=train_dataset.num_classes) diff --git a/dygraph/val.py b/dygraph/val.py index e3e1dca671e7dd9e5fe4db77e33d46e12bfbb5e8..d388fccf81d39b928323412dbc08145c5401d184 100644 --- a/dygraph/val.py +++ b/dygraph/val.py @@ -13,25 +13,14 @@ # limitations under the License. import argparse -import os -import math -import numpy as np -import tqdm -import cv2 -from paddle.fluid.dygraph.base import to_variable import paddle.fluid as fluid from paddle.fluid.dygraph.parallel import ParallelEnv -from paddle.fluid.io import DataLoader -from paddle.fluid.dataloader import BatchSampler from datasets import DATASETS import transforms as T from models import MODELS -import utils.logging as logging from utils import get_environ_info -from utils import ConfusionMatrix -from utils import Timer, calculate_eta from core import evaluate @@ -87,7 +76,7 @@ def main(args): else fluid.CPUPlace() if args.dataset not in DATASETS: - raise Exception('--dataset is invalid. it should be one of {}'.format( + raise Exception('`--dataset` is invalid. it should be one of {}'.format( str(list(DATASETS.keys())))) dataset = DATASETS[args.dataset] @@ -100,7 +89,7 @@ def main(args): if args.model_name not in MODELS: raise Exception( - '--model_name is invalid. it should be one of {}'.format( + '`--model_name` is invalid. it should be one of {}'.format( str(list(MODELS.keys())))) model = MODELS[args.model_name](num_classes=eval_dataset.num_classes)