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

fix infer doc and config default (#2923)

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