提交 727d93ad 编写于 作者: C chenguowei01

update annotation

上级 8d371858
...@@ -30,7 +30,7 @@ class ADE20K(Dataset): ...@@ -30,7 +30,7 @@ class ADE20K(Dataset):
dataset_root: The dataset directory. dataset_root: The dataset directory.
mode: Which part of dataset to use.. it is one of ('train', 'val'). Default: 'train'. mode: Which part of dataset to use.. it is one of ('train', 'val'). Default: 'train'.
transforms: Transforms for image. 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, def __init__(self,
...@@ -46,23 +46,23 @@ class ADE20K(Dataset): ...@@ -46,23 +46,23 @@ class ADE20K(Dataset):
if mode.lower() not in ['train', 'val']: if mode.lower() not in ['train', 'val']:
raise Exception( 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)) .format(mode))
if self.transforms is None: 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 self.dataset_root is None:
if not download: if not download:
raise Exception( 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( self.dataset_root = download_file_and_uncompress(
url=URL, url=URL,
savepath=DATA_HOME, savepath=DATA_HOME,
extrapath=DATA_HOME, extrapath=DATA_HOME,
extraname='ADEChallengeData2016') extraname='ADEChallengeData2016')
elif not os.path.exists(self.dataset_root): 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)) self.dataset_root))
if mode == 'train': if mode == 'train':
......
...@@ -53,7 +53,7 @@ class Cityscapes(Dataset): ...@@ -53,7 +53,7 @@ class Cityscapes(Dataset):
mode)) mode))
if self.transforms is None: 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') img_dir = os.path.join(self.dataset_root, 'leftImg8bit')
grt_dir = os.path.join(self.dataset_root, 'gtFine') grt_dir = os.path.join(self.dataset_root, 'gtFine')
......
...@@ -63,39 +63,40 @@ class Dataset(fluid.io.Dataset): ...@@ -63,39 +63,40 @@ class Dataset(fluid.io.Dataset):
mode)) mode))
if self.transforms is None: 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 self.dataset_root = dataset_root
if not os.path.exists(self.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)) self.dataset_root))
if mode == 'train': if mode == 'train':
if train_list is None: if train_list is None:
raise Exception( 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): elif not os.path.exists(train_list):
raise Exception( raise Exception(
'train_list is not found: {}'.format(train_list)) '`train_list` is not found: {}'.format(train_list))
else: else:
file_list = train_list file_list = train_list
elif mode == 'val': elif mode == 'val':
if val_list is None: if val_list is None:
raise Exception( 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): 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: else:
file_list = val_list file_list = val_list
else: else:
if test_list is None: if test_list is None:
raise Exception( 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): 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: else:
file_list = test_list file_list = test_list
......
...@@ -35,19 +35,20 @@ class OpticDiscSeg(Dataset): ...@@ -35,19 +35,20 @@ class OpticDiscSeg(Dataset):
if mode.lower() not in ['train', 'val', 'test']: if mode.lower() not in ['train', 'val', 'test']:
raise Exception( raise Exception(
"mode should be 'train', 'val' or 'test', but got {}.".format( "`mode` should be 'train', 'val' or 'test', but got {}.".format(
mode)) mode))
if self.transforms is None: 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 self.dataset_root is None:
if not download: 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( self.dataset_root = download_file_and_uncompress(
url=URL, savepath=DATA_HOME, extrapath=DATA_HOME) url=URL, savepath=DATA_HOME, extrapath=DATA_HOME)
elif not os.path.exists(self.dataset_root): 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)) self.dataset_root))
if mode == 'train': if mode == 'train':
......
...@@ -43,23 +43,23 @@ class PascalVOC(Dataset): ...@@ -43,23 +43,23 @@ class PascalVOC(Dataset):
if mode.lower() not in ['train', 'trainval', 'trainaug', 'val']: if mode.lower() not in ['train', 'trainval', 'trainaug', 'val']:
raise Exception( 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)) .format(mode))
if self.transforms is None: 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 self.dataset_root is None:
if not download: if not download:
raise Exception( 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( self.dataset_root = download_file_and_uncompress(
url=URL, url=URL,
savepath=DATA_HOME, savepath=DATA_HOME,
extrapath=DATA_HOME, extrapath=DATA_HOME,
extraname='VOCdevkit') extraname='VOCdevkit')
elif not os.path.exists(self.dataset_root): 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)) self.dataset_root))
image_set_dir = os.path.join(self.dataset_root, 'VOC2012', 'ImageSets', image_set_dir = os.path.join(self.dataset_root, 'VOC2012', 'ImageSets',
...@@ -76,7 +76,7 @@ class PascalVOC(Dataset): ...@@ -76,7 +76,7 @@ class PascalVOC(Dataset):
if not os.path.exists(file_list_aug): if not os.path.exists(file_list_aug):
raise Exception( 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." "Please make sure voc_augment.py has been properly run when using this mode."
) )
......
...@@ -88,7 +88,7 @@ def main(args): ...@@ -88,7 +88,7 @@ def main(args):
else fluid.CPUPlace() else fluid.CPUPlace()
if args.dataset not in DATASETS: 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())))) str(list(DATASETS.keys()))))
dataset = DATASETS[args.dataset] dataset = DATASETS[args.dataset]
...@@ -101,7 +101,7 @@ def main(args): ...@@ -101,7 +101,7 @@ def main(args):
if args.model_name not in MODELS: if args.model_name not in MODELS:
raise Exception( 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())))) str(list(MODELS.keys()))))
model = MODELS[args.model_name](num_classes=test_dataset.num_classes) model = MODELS[args.model_name](num_classes=test_dataset.num_classes)
......
...@@ -13,21 +13,14 @@ ...@@ -13,21 +13,14 @@
# limitations under the License. # limitations under the License.
import argparse import argparse
import os
import paddle.fluid as fluid import paddle.fluid as fluid
from paddle.fluid.dygraph.parallel import ParallelEnv from paddle.fluid.dygraph.parallel import ParallelEnv
from paddle.fluid.io import DataLoader
from paddle.incubate.hapi.distributed import DistributedBatchSampler
from datasets import DATASETS from datasets import DATASETS
import transforms as T import transforms as T
from models import MODELS from models import MODELS
import utils.logging as logging
from utils import get_environ_info 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 from core import train
...@@ -141,7 +134,7 @@ def main(args): ...@@ -141,7 +134,7 @@ def main(args):
else fluid.CPUPlace() else fluid.CPUPlace()
if args.dataset not in DATASETS: 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())))) str(list(DATASETS.keys()))))
dataset = DATASETS[args.dataset] dataset = DATASETS[args.dataset]
...@@ -169,7 +162,7 @@ def main(args): ...@@ -169,7 +162,7 @@ def main(args):
if args.model_name not in MODELS: if args.model_name not in MODELS:
raise Exception( 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())))) str(list(MODELS.keys()))))
model = MODELS[args.model_name](num_classes=train_dataset.num_classes) model = MODELS[args.model_name](num_classes=train_dataset.num_classes)
......
...@@ -13,25 +13,14 @@ ...@@ -13,25 +13,14 @@
# limitations under the License. # limitations under the License.
import argparse 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 import paddle.fluid as fluid
from paddle.fluid.dygraph.parallel import ParallelEnv from paddle.fluid.dygraph.parallel import ParallelEnv
from paddle.fluid.io import DataLoader
from paddle.fluid.dataloader import BatchSampler
from datasets import DATASETS from datasets import DATASETS
import transforms as T import transforms as T
from models import MODELS from models import MODELS
import utils.logging as logging
from utils import get_environ_info from utils import get_environ_info
from utils import ConfusionMatrix
from utils import Timer, calculate_eta
from core import evaluate from core import evaluate
...@@ -87,7 +76,7 @@ def main(args): ...@@ -87,7 +76,7 @@ def main(args):
else fluid.CPUPlace() else fluid.CPUPlace()
if args.dataset not in DATASETS: 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())))) str(list(DATASETS.keys()))))
dataset = DATASETS[args.dataset] dataset = DATASETS[args.dataset]
...@@ -100,7 +89,7 @@ def main(args): ...@@ -100,7 +89,7 @@ def main(args):
if args.model_name not in MODELS: if args.model_name not in MODELS:
raise Exception( 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())))) str(list(MODELS.keys()))))
model = MODELS[args.model_name](num_classes=eval_dataset.num_classes) model = MODELS[args.model_name](num_classes=eval_dataset.num_classes)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册