diff --git a/configs/cascade_rcnn_r50_fpn_1x.yml b/configs/cascade_rcnn_r50_fpn_1x.yml index 81f5eb09a6dd7b1a7880a04a2dac87a6264718be..f8830ae6b1fea5435295c714d03beab3283291ff 100644 --- a/configs/cascade_rcnn_r50_fpn_1x.yml +++ b/configs/cascade_rcnn_r50_fpn_1x.yml @@ -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 diff --git a/configs/faster_rcnn_r101_1x.yml b/configs/faster_rcnn_r101_1x.yml index 27773309ac3e6ffa3abef7018f675ac00d62148c..c72c34d4da8ce429932069d5084f4e710ddba11b 100644 --- a/configs/faster_rcnn_r101_1x.yml +++ b/configs/faster_rcnn_r101_1x.yml @@ -112,4 +112,4 @@ FasterRCNNEvalFeed: FasterRCNNTestFeed: batch_size: 1 dataset: - annotation: annotations/instances_val2017.json + annotation: dataset/coco/annotations/instances_val2017.json diff --git a/configs/faster_rcnn_r101_fpn_1x.yml b/configs/faster_rcnn_r101_fpn_1x.yml index dbb4d6d9aa9019e111a32a5ba89642fd0b73a547..7c0074674bad60087a0badaa4a07e7aee7fddd87 100644 --- a/configs/faster_rcnn_r101_fpn_1x.yml +++ b/configs/faster_rcnn_r101_fpn_1x.yml @@ -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 diff --git a/configs/faster_rcnn_r101_fpn_2x.yml b/configs/faster_rcnn_r101_fpn_2x.yml index a742782bcf7e0fac62ac9d2179bd46806ed97d3e..9f9ea02a644e83a42478a14d1e21ac3cfe7c4cc5 100644 --- a/configs/faster_rcnn_r101_fpn_2x.yml +++ b/configs/faster_rcnn_r101_fpn_2x.yml @@ -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 diff --git a/configs/faster_rcnn_r101_vd_fpn_1x.yml b/configs/faster_rcnn_r101_vd_fpn_1x.yml index 7c0fc39be9a8c1bdc295cdf8a7dc6de246e9f186..181d5408a99d1caf709c37dbec7cee299039f9aa 100644 --- a/configs/faster_rcnn_r101_vd_fpn_1x.yml +++ b/configs/faster_rcnn_r101_vd_fpn_1x.yml @@ -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 diff --git a/configs/faster_rcnn_r101_vd_fpn_2x.yml b/configs/faster_rcnn_r101_vd_fpn_2x.yml index 726de38a9c2049c69f2c1427e2e1ab757164b805..33b751364fa53ba364c266008327d302266f7a96 100644 --- a/configs/faster_rcnn_r101_vd_fpn_2x.yml +++ b/configs/faster_rcnn_r101_vd_fpn_2x.yml @@ -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 diff --git a/configs/faster_rcnn_r50_1x.yml b/configs/faster_rcnn_r50_1x.yml index bf4a828fb0a9b8385924e05e3a1c9252ed0412c1..12d349612b3464cff0b945535a8d81a53b434a98 100644 --- a/configs/faster_rcnn_r50_1x.yml +++ b/configs/faster_rcnn_r50_1x.yml @@ -112,4 +112,4 @@ FasterRCNNEvalFeed: FasterRCNNTestFeed: batch_size: 1 dataset: - annotation: annotations/instances_val2017.json + annotation: dataset/coco/annotations/instances_val2017.json diff --git a/configs/faster_rcnn_r50_2x.yml b/configs/faster_rcnn_r50_2x.yml index 5257161aae01e6ff2a728f2929d13dc25d5027bb..255cd02663845235beac103dad7faaaf03bb90f2 100644 --- a/configs/faster_rcnn_r50_2x.yml +++ b/configs/faster_rcnn_r50_2x.yml @@ -112,4 +112,4 @@ FasterRCNNEvalFeed: FasterRCNNTestFeed: batch_size: 1 dataset: - annotation: annotations/instances_val2017.json + annotation: dataset/coco/annotations/instances_val2017.json diff --git a/configs/faster_rcnn_r50_fpn_1x.yml b/configs/faster_rcnn_r50_fpn_1x.yml index 0414a2ec8412b2e344922e2a704d570ae58cc88e..de8b573a5f370c7404fc1ab4105f2f6a459b55e8 100644 --- a/configs/faster_rcnn_r50_fpn_1x.yml +++ b/configs/faster_rcnn_r50_fpn_1x.yml @@ -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 diff --git a/configs/faster_rcnn_r50_fpn_2x.yml b/configs/faster_rcnn_r50_fpn_2x.yml index a1989db64b17967ba00d3f286c0209c27eb90013..bd1aec29ac843e73a1a137903da283956dd7d9ad 100644 --- a/configs/faster_rcnn_r50_fpn_2x.yml +++ b/configs/faster_rcnn_r50_fpn_2x.yml @@ -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 diff --git a/configs/faster_rcnn_r50_vd_1x.yml b/configs/faster_rcnn_r50_vd_1x.yml index 25ce550e408c7d935fd5e7f5e75a47fbbfbc2dc1..bcca99233c831fcb6260b2f0e0eb759f7c6be5c2 100644 --- a/configs/faster_rcnn_r50_vd_1x.yml +++ b/configs/faster_rcnn_r50_vd_1x.yml @@ -114,4 +114,4 @@ FasterRCNNEvalFeed: FasterRCNNTestFeed: batch_size: 1 dataset: - annotation: annotations/instances_val2017.json + annotation: dataset/coco/annotations/instances_val2017.json diff --git a/configs/faster_rcnn_r50_vd_fpn_2x.yml b/configs/faster_rcnn_r50_vd_fpn_2x.yml index ef19b275fdbd491a3b18e60580cda4fb709714ea..7abacdf3bb858e89f5960536e3749c99d1882579 100644 --- a/configs/faster_rcnn_r50_vd_fpn_2x.yml +++ b/configs/faster_rcnn_r50_vd_fpn_2x.yml @@ -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 diff --git a/configs/faster_rcnn_se154_vd_fpn_s1x.yml b/configs/faster_rcnn_se154_vd_fpn_s1x.yml index 3e16ecc25699d199765955d2cf610cc392185c26..41dc089085ddf967dd1151bb23949225217e39a0 100644 --- a/configs/faster_rcnn_se154_vd_fpn_s1x.yml +++ b/configs/faster_rcnn_se154_vd_fpn_s1x.yml @@ -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 diff --git a/configs/faster_rcnn_x101_vd_64x4d_fpn_1x.yml b/configs/faster_rcnn_x101_vd_64x4d_fpn_1x.yml index 1d6759e6f95ea201ca046cc85986ef41eccf8a8e..988f47e10fec13604853c1e95f7a5dd883c6a960 100644 --- a/configs/faster_rcnn_x101_vd_64x4d_fpn_1x.yml +++ b/configs/faster_rcnn_x101_vd_64x4d_fpn_1x.yml @@ -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 diff --git a/configs/faster_rcnn_x101_vd_64x4d_fpn_2x.yml b/configs/faster_rcnn_x101_vd_64x4d_fpn_2x.yml index 61f40e95e39be83efc5d92e57c94227a6d0bac8e..2282ad0d009238b51168c87d29c5b6eaf213ab77 100644 --- a/configs/faster_rcnn_x101_vd_64x4d_fpn_2x.yml +++ b/configs/faster_rcnn_x101_vd_64x4d_fpn_2x.yml @@ -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 diff --git a/configs/mask_rcnn_r101_fpn_1x.yml b/configs/mask_rcnn_r101_fpn_1x.yml index d9a476b9eadaa5d9d39ea5e210497d36b2b94be1..48a0e44a2c2bdcbea1ab9ab8e43186e91c6cdfb5 100644 --- a/configs/mask_rcnn_r101_fpn_1x.yml +++ b/configs/mask_rcnn_r101_fpn_1x.yml @@ -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 diff --git a/configs/mask_rcnn_r50_1x.yml b/configs/mask_rcnn_r50_1x.yml index b652affbea5d9ae1b69a0bf9bcd9d09d4be095fb..4fd6e344ca58c642735980a2c2e44f9d43309b41 100644 --- a/configs/mask_rcnn_r50_1x.yml +++ b/configs/mask_rcnn_r50_1x.yml @@ -120,4 +120,4 @@ MaskRCNNEvalFeed: MaskRCNNTestFeed: batch_size: 1 dataset: - annotation: annotations/instances_val2017.json + annotation: dataset/coco/annotations/instances_val2017.json diff --git a/configs/mask_rcnn_r50_2x.yml b/configs/mask_rcnn_r50_2x.yml index 58f9b39f48399aa540466f121baa1e3edfc59097..d4456919ba2e63fa29951afbecf9d377e60ca507 100644 --- a/configs/mask_rcnn_r50_2x.yml +++ b/configs/mask_rcnn_r50_2x.yml @@ -122,4 +122,4 @@ MaskRCNNEvalFeed: MaskRCNNTestFeed: batch_size: 1 dataset: - annotation: annotations/instances_val2017.json + annotation: dataset/coco/annotations/instances_val2017.json diff --git a/configs/mask_rcnn_r50_fpn_1x.yml b/configs/mask_rcnn_r50_fpn_1x.yml index 1059d7b4e907ac2ae3659b85937205c1f61d5f96..656f59f8a0b2423bec0b1d44c571b4ad6d38bb35 100644 --- a/configs/mask_rcnn_r50_fpn_1x.yml +++ b/configs/mask_rcnn_r50_fpn_1x.yml @@ -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 diff --git a/configs/mask_rcnn_r50_fpn_2x.yml b/configs/mask_rcnn_r50_fpn_2x.yml index 9f7604982d38cd66eb34299dfc2ae8e043583de1..36784cde6abee728051cc5222e045f24c8c98111 100644 --- a/configs/mask_rcnn_r50_fpn_2x.yml +++ b/configs/mask_rcnn_r50_fpn_2x.yml @@ -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 diff --git a/configs/mask_rcnn_r50_vd_fpn_2x.yml b/configs/mask_rcnn_r50_vd_fpn_2x.yml index 957c53d6ded13574c4e5093e14430831b4a94794..0ebae8546569a74dfd194858f268d2cbc632aab6 100644 --- a/configs/mask_rcnn_r50_vd_fpn_2x.yml +++ b/configs/mask_rcnn_r50_vd_fpn_2x.yml @@ -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 diff --git a/configs/mask_rcnn_se154_vd_fpn_s1x.yml b/configs/mask_rcnn_se154_vd_fpn_s1x.yml index 63b84f98852284c675fd71be5169809d5d419233..d7f72b243fdc68a684d6c3ec4c6f84accdc2f402 100644 --- a/configs/mask_rcnn_se154_vd_fpn_s1x.yml +++ b/configs/mask_rcnn_se154_vd_fpn_s1x.yml @@ -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 diff --git a/configs/retinanet_r101_fpn_1x.yml b/configs/retinanet_r101_fpn_1x.yml index 67399e13df448337a74516ac58344a5b13d1c14c..7ad343d54e4e9dce524537c387a18bf281c87efd 100644 --- a/configs/retinanet_r101_fpn_1x.yml +++ b/configs/retinanet_r101_fpn_1x.yml @@ -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 diff --git a/configs/retinanet_r50_fpn_1x.yml b/configs/retinanet_r50_fpn_1x.yml index ebd069110d126ba8dab49c4748007e46294a98ec..87ee5f2841eeb5b69c9e13d294631b32353168dd 100644 --- a/configs/retinanet_r50_fpn_1x.yml +++ b/configs/retinanet_r50_fpn_1x.yml @@ -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 diff --git a/configs/yolov3_darknet.yml b/configs/yolov3_darknet.yml index 50b97204931a47b54309488eb292cc27c917f63e..6a071814c08e0811627ff51999d3875d5d340174 100644 --- a/configs/yolov3_darknet.yml +++ b/configs/yolov3_darknet.yml @@ -77,4 +77,4 @@ YoloEvalFeed: YoloTestFeed: batch_size: 1 dataset: - annotation: annotations/instances_val2017.json + annotation: dataset/coco/annotations/instances_val2017.json diff --git a/configs/yolov3_mobilenet_v1.yml b/configs/yolov3_mobilenet_v1.yml index 2456da56215a7d5a21653c58f178a90bc6623049..6ee6ff4a56a9e7dd88df821fbc36adb66d62bc3b 100644 --- a/configs/yolov3_mobilenet_v1.yml +++ b/configs/yolov3_mobilenet_v1.yml @@ -78,4 +78,4 @@ YoloEvalFeed: YoloTestFeed: batch_size: 1 dataset: - annotation: annotations/instances_val2017.json + annotation: dataset/coco/annotations/instances_val2017.json diff --git a/configs/yolov3_r34.yml b/configs/yolov3_r34.yml index 0247eb8ca2e633f29cb184537f494ae0d460caef..0cf6e419512c4b483a7d3d42d9fa72834526776f 100644 --- a/configs/yolov3_r34.yml +++ b/configs/yolov3_r34.yml @@ -80,4 +80,4 @@ YoloEvalFeed: YoloTestFeed: batch_size: 1 dataset: - annotation: annotations/instances_val2017.json + annotation: dataset/coco/annotations/instances_val2017.json diff --git a/docs/GETTING_STARTED.md b/docs/GETTING_STARTED.md index e8824adae2538cea694101d6263b323903d2dcf7..ae527a46d2773d6f31ba06297e9c02e8eb49ec1a 100644 --- a/docs/GETTING_STARTED.md +++ b/docs/GETTING_STARTED.md @@ -71,7 +71,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. - Save inference model diff --git a/docs/GETTING_STARTED_cn.md b/docs/GETTING_STARTED_cn.md index 9116dd77b238521b12dad983e94fef052069d385..8f95a9c21e9775def833729b61f3fdcf6f3a24fd 100644 --- a/docs/GETTING_STARTED_cn.md +++ b/docs/GETTING_STARTED_cn.md @@ -68,7 +68,7 @@ export CUDA_VISIBLE_DEVICES=0 python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_dir=demo ``` -可视化文件默认保存在`output`中,可通过`--save_file=`指定不同的输出路径。 +可视化文件默认保存在`output`中,可通过`--output_dir=`指定不同的输出路径。 - 保存推断模型 diff --git a/ppdet/data/data_feed.py b/ppdet/data/data_feed.py index b3c7222cae5a3d819b72a5d11438787f97c33ba6..1da81969f8d98336f302e06b89028a70ee8bfa6f 100644 --- a/ppdet/data/data_feed.py +++ b/ppdet/data/data_feed.py @@ -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: diff --git a/ppdet/utils/download.py b/ppdet/utils/download.py index dbc1fa25df8de75e3cb055e172453f7aca67d228..43f9891ad65531075d6f154134980137a089f089 100644 --- a/ppdet/utils/download.py +++ b/ppdet/utils/download.py @@ -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