未验证 提交 ab465673 编写于 作者: K Kaipeng Deng 提交者: GitHub

fix infer doc and config default (#2923)

上级 4d19fc31
...@@ -129,7 +129,7 @@ FasterRCNNEvalFeed: ...@@ -129,7 +129,7 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -112,4 +112,4 @@ FasterRCNNEvalFeed: ...@@ -112,4 +112,4 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
...@@ -129,7 +129,7 @@ FasterRCNNEvalFeed: ...@@ -129,7 +129,7 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -129,7 +129,7 @@ FasterRCNNEvalFeed: ...@@ -129,7 +129,7 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -130,7 +130,7 @@ FasterRCNNEvalFeed: ...@@ -130,7 +130,7 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -130,7 +130,7 @@ FasterRCNNEvalFeed: ...@@ -130,7 +130,7 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -112,4 +112,4 @@ FasterRCNNEvalFeed: ...@@ -112,4 +112,4 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
...@@ -112,4 +112,4 @@ FasterRCNNEvalFeed: ...@@ -112,4 +112,4 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
...@@ -129,7 +129,7 @@ FasterRCNNEvalFeed: ...@@ -129,7 +129,7 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -129,7 +129,7 @@ FasterRCNNEvalFeed: ...@@ -129,7 +129,7 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: coco/annotations/instances_val2017.json annotation: dataset/coco/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -114,4 +114,4 @@ FasterRCNNEvalFeed: ...@@ -114,4 +114,4 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
...@@ -130,7 +130,7 @@ FasterRCNNEvalFeed: ...@@ -130,7 +130,7 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -132,7 +132,7 @@ FasterRCNNEvalFeed: ...@@ -132,7 +132,7 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -134,7 +134,7 @@ FasterRCNNEvalFeed: ...@@ -134,7 +134,7 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -133,7 +133,7 @@ FasterRCNNEvalFeed: ...@@ -133,7 +133,7 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -136,7 +136,7 @@ MaskRCNNEvalFeed: ...@@ -136,7 +136,7 @@ MaskRCNNEvalFeed:
MaskRCNNTestFeed: MaskRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -120,4 +120,4 @@ MaskRCNNEvalFeed: ...@@ -120,4 +120,4 @@ MaskRCNNEvalFeed:
MaskRCNNTestFeed: MaskRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
...@@ -122,4 +122,4 @@ MaskRCNNEvalFeed: ...@@ -122,4 +122,4 @@ MaskRCNNEvalFeed:
MaskRCNNTestFeed: MaskRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
...@@ -136,7 +136,7 @@ MaskRCNNEvalFeed: ...@@ -136,7 +136,7 @@ MaskRCNNEvalFeed:
MaskRCNNTestFeed: MaskRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -136,7 +136,7 @@ MaskRCNNEvalFeed: ...@@ -136,7 +136,7 @@ MaskRCNNEvalFeed:
MaskRCNNTestFeed: MaskRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -138,7 +138,7 @@ MaskRCNNEvalFeed: ...@@ -138,7 +138,7 @@ MaskRCNNEvalFeed:
MaskRCNNTestFeed: MaskRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -140,7 +140,7 @@ MaskRCNNEvalFeed: ...@@ -140,7 +140,7 @@ MaskRCNNEvalFeed:
MaskRCNNTestFeed: MaskRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 32 pad_to_stride: 32
......
...@@ -101,5 +101,5 @@ FasterRCNNTestFeed: ...@@ -101,5 +101,5 @@ FasterRCNNTestFeed:
- !PadBatch - !PadBatch
pad_to_stride: 128 pad_to_stride: 128
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
num_workers: 2 num_workers: 2
...@@ -98,7 +98,7 @@ FasterRCNNEvalFeed: ...@@ -98,7 +98,7 @@ FasterRCNNEvalFeed:
FasterRCNNTestFeed: FasterRCNNTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
batch_transforms: batch_transforms:
- !PadBatch - !PadBatch
pad_to_stride: 128 pad_to_stride: 128
......
...@@ -77,4 +77,4 @@ YoloEvalFeed: ...@@ -77,4 +77,4 @@ YoloEvalFeed:
YoloTestFeed: YoloTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
...@@ -78,4 +78,4 @@ YoloEvalFeed: ...@@ -78,4 +78,4 @@ YoloEvalFeed:
YoloTestFeed: YoloTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
...@@ -80,4 +80,4 @@ YoloEvalFeed: ...@@ -80,4 +80,4 @@ YoloEvalFeed:
YoloTestFeed: YoloTestFeed:
batch_size: 1 batch_size: 1
dataset: dataset:
annotation: annotations/instances_val2017.json annotation: dataset/coco/annotations/instances_val2017.json
...@@ -70,7 +70,7 @@ python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_dir=demo ...@@ -70,7 +70,7 @@ python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_dir=demo
``` ```
The visualization files are saved in `output` by default, to specify a different The visualization files are saved in `output` by default, to specify a different
path, simply add a `--save_file=` flag. path, simply add a `--output_dir=` flag.
## FAQ ## FAQ
......
...@@ -52,11 +52,14 @@ def create_reader(feed, max_iter=0): ...@@ -52,11 +52,14 @@ def create_reader(feed, max_iter=0):
# if `DATASET_DIR` does not exists, search ~/.paddle/dataset for a directory # if `DATASET_DIR` does not exists, search ~/.paddle/dataset for a directory
# named `DATASET_DIR` (e.g., coco, pascal), if not present either, download # named `DATASET_DIR` (e.g., coco, pascal), if not present either, download
if feed.dataset.dataset_dir: if feed.dataset.dataset_dir:
dataset_dir = get_dataset_path(feed.dataset.dataset_dir) annotation = getattr(feed.dataset, 'annotation', None)
feed.dataset.annotation = os.path.join(dataset_dir, image_dir = getattr(feed.dataset, 'image_dir', None)
feed.dataset.annotation) dataset_dir = get_dataset_path(feed.dataset.dataset_dir,
feed.dataset.image_dir = os.path.join(dataset_dir, annotation, image_dir)
feed.dataset.image_dir) if annotation:
feed.dataset.annotation = os.path.join(dataset_dir, annotation)
if image_dir:
feed.dataset.image_dir = os.path.join(dataset_dir, image_dir)
mixup_epoch = -1 mixup_epoch = -1
if getattr(feed, 'mixup_epoch', None) is not None: if getattr(feed, 'mixup_epoch', None) is not None:
......
...@@ -67,14 +67,13 @@ def get_weights_path(url): ...@@ -67,14 +67,13 @@ def get_weights_path(url):
return get_path(url, WEIGHTS_HOME) return get_path(url, WEIGHTS_HOME)
def get_dataset_path(path): def get_dataset_path(path, annotation, image_dir):
""" """
If path exists, return path. If path exists, return path.
Otherwise, get dataset path from DATASET_HOME, if not exists, Otherwise, get dataset path from DATASET_HOME, if not exists,
download it. download it.
""" """
if _dataset_exists(path): if _dataset_exists(path, annotation, image_dir):
logger.debug("Dataset path: {}".format(osp.realpath(path)))
return path return path
logger.info("Dataset {} not exitst, try searching {} or " logger.info("Dataset {} not exitst, try searching {} or "
...@@ -82,7 +81,7 @@ def get_dataset_path(path): ...@@ -82,7 +81,7 @@ def get_dataset_path(path):
osp.realpath(path), DATASET_HOME)) osp.realpath(path), DATASET_HOME))
for name, dataset in DATASETS.items(): for name, dataset in DATASETS.items():
if path.lower().find(name) >= 0: if os.path.split(path.strip().lower())[-1] == name:
logger.info("Parse dataset_dir {} as dataset " logger.info("Parse dataset_dir {} as dataset "
"{}".format(path, name)) "{}".format(path, name))
data_dir = osp.join(DATASET_HOME, name) data_dir = osp.join(DATASET_HOME, name)
...@@ -163,19 +162,26 @@ def get_path(url, root_dir, md5sum=None): ...@@ -163,19 +162,26 @@ def get_path(url, root_dir, md5sum=None):
return fullpath return fullpath
def _dataset_exists(path): def _dataset_exists(path, annotation, image_dir):
""" """
Check if user define dataset exists Check if user define dataset exists
""" """
if not osp.exists(path): if not osp.exists(path):
logger.info("Config dataset_dir {} not exits".format(path))
return False return False
for name, dataset in DATASETS.items(): if annotation:
if path.lower().find(name) >= 0: annotation_path = osp.join(path, annotation)
for sub_dir in dataset[1]: if not osp.isfile(annotation_path):
if not osp.exists(osp.join(path, sub_dir)): logger.info("Config annotation {} is not a "
return False "file".format(annotation_path))
return True return False
if image_dir:
image_path = osp.join(path, image_dir)
if not osp.isdir(image_path):
logger.info("Config image_dir {} is not a "
"directory".format(image_path))
return False
return True return True
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册