From a2a047f2dab23343eabeea06c3813edc463ac3d8 Mon Sep 17 00:00:00 2001 From: Kaipeng Deng Date: Fri, 23 Aug 2019 14:25:31 +0800 Subject: [PATCH] enable yolov3 set input size with image_shape in yml (#3141) --- .../PaddleDetection/configs/yolov3_darknet.yml | 2 ++ .../PaddleDetection/configs/yolov3_darknet_voc.yml | 2 ++ .../configs/yolov3_mobilenet_v1.yml | 2 ++ .../configs/yolov3_mobilenet_v1_voc.yml | 2 ++ PaddleCV/PaddleDetection/configs/yolov3_r34.yml | 2 ++ .../PaddleDetection/configs/yolov3_r34_voc.yml | 2 ++ PaddleCV/PaddleDetection/ppdet/data/data_feed.py | 14 ++++++++++++++ 7 files changed, 26 insertions(+) diff --git a/PaddleCV/PaddleDetection/configs/yolov3_darknet.yml b/PaddleCV/PaddleDetection/configs/yolov3_darknet.yml index fe7ad04a..9a1c243b 100644 --- a/PaddleCV/PaddleDetection/configs/yolov3_darknet.yml +++ b/PaddleCV/PaddleDetection/configs/yolov3_darknet.yml @@ -69,6 +69,7 @@ YoloTrainFeed: YoloEvalFeed: batch_size: 8 + image_shape: [3, 608, 608] dataset: dataset_dir: dataset/coco annotation: annotations/instances_val2017.json @@ -76,5 +77,6 @@ YoloEvalFeed: YoloTestFeed: batch_size: 1 + image_shape: [3, 608, 608] dataset: annotation: dataset/coco/annotations/instances_val2017.json diff --git a/PaddleCV/PaddleDetection/configs/yolov3_darknet_voc.yml b/PaddleCV/PaddleDetection/configs/yolov3_darknet_voc.yml index 8b848d77..08e00a53 100644 --- a/PaddleCV/PaddleDetection/configs/yolov3_darknet_voc.yml +++ b/PaddleCV/PaddleDetection/configs/yolov3_darknet_voc.yml @@ -71,6 +71,7 @@ YoloTrainFeed: YoloEvalFeed: batch_size: 8 + image_shape: [3, 608, 608] dataset: dataset_dir: dataset/voc annotation: VOCdevkit/VOC_all/ImageSets/Main/val.txt @@ -79,5 +80,6 @@ YoloEvalFeed: YoloTestFeed: batch_size: 1 + image_shape: [3, 608, 608] dataset: use_default_label: true diff --git a/PaddleCV/PaddleDetection/configs/yolov3_mobilenet_v1.yml b/PaddleCV/PaddleDetection/configs/yolov3_mobilenet_v1.yml index 54f40e7d..3e622025 100644 --- a/PaddleCV/PaddleDetection/configs/yolov3_mobilenet_v1.yml +++ b/PaddleCV/PaddleDetection/configs/yolov3_mobilenet_v1.yml @@ -70,6 +70,7 @@ YoloTrainFeed: YoloEvalFeed: batch_size: 8 + image_shape: [3, 608, 608] dataset: dataset_dir: dataset/coco annotation: annotations/instances_val2017.json @@ -77,5 +78,6 @@ YoloEvalFeed: YoloTestFeed: batch_size: 1 + image_shape: [3, 608, 608] dataset: annotation: dataset/coco/annotations/instances_val2017.json diff --git a/PaddleCV/PaddleDetection/configs/yolov3_mobilenet_v1_voc.yml b/PaddleCV/PaddleDetection/configs/yolov3_mobilenet_v1_voc.yml index 24945c57..4601f68f 100644 --- a/PaddleCV/PaddleDetection/configs/yolov3_mobilenet_v1_voc.yml +++ b/PaddleCV/PaddleDetection/configs/yolov3_mobilenet_v1_voc.yml @@ -72,6 +72,7 @@ YoloTrainFeed: YoloEvalFeed: batch_size: 8 + image_shape: [3, 608, 608] dataset: dataset_dir: dataset/voc annotation: VOCdevkit/VOC_all/ImageSets/Main/val.txt @@ -80,5 +81,6 @@ YoloEvalFeed: YoloTestFeed: batch_size: 1 + image_shape: [3, 608, 608] dataset: use_default_label: true diff --git a/PaddleCV/PaddleDetection/configs/yolov3_r34.yml b/PaddleCV/PaddleDetection/configs/yolov3_r34.yml index e7895318..e864f8fd 100644 --- a/PaddleCV/PaddleDetection/configs/yolov3_r34.yml +++ b/PaddleCV/PaddleDetection/configs/yolov3_r34.yml @@ -72,6 +72,7 @@ YoloTrainFeed: YoloEvalFeed: batch_size: 8 + image_shape: [3, 608, 608] dataset: dataset_dir: dataset/coco annotation: annotations/instances_val2017.json @@ -79,5 +80,6 @@ YoloEvalFeed: YoloTestFeed: batch_size: 1 + image_shape: [3, 608, 608] dataset: annotation: dataset/coco/annotations/instances_val2017.json diff --git a/PaddleCV/PaddleDetection/configs/yolov3_r34_voc.yml b/PaddleCV/PaddleDetection/configs/yolov3_r34_voc.yml index fade2a30..cb8e370b 100644 --- a/PaddleCV/PaddleDetection/configs/yolov3_r34_voc.yml +++ b/PaddleCV/PaddleDetection/configs/yolov3_r34_voc.yml @@ -74,6 +74,7 @@ YoloTrainFeed: YoloEvalFeed: batch_size: 8 + image_shape: [3, 608, 608] dataset: dataset_dir: dataset/voc annotation: VOCdevkit/VOC_all/ImageSets/Main/val.txt @@ -82,5 +83,6 @@ YoloEvalFeed: YoloTestFeed: batch_size: 1 + image_shape: [3, 608, 608] dataset: use_default_label: true diff --git a/PaddleCV/PaddleDetection/ppdet/data/data_feed.py b/PaddleCV/PaddleDetection/ppdet/data/data_feed.py index 9c0357c3..0d6629c1 100644 --- a/PaddleCV/PaddleDetection/ppdet/data/data_feed.py +++ b/PaddleCV/PaddleDetection/ppdet/data/data_feed.py @@ -942,6 +942,13 @@ class YoloEvalFeed(DataFeed): self.mode = 'VAL' self.bufsize = 128 + # support image shape config, resize image with image_shape + for i, trans in enumerate(sample_transforms): + if isinstance(trans, ResizeImage): + sample_transforms[i] = ResizeImage( + target_size=self.image_shape[-1], + interp=trans.interp) + @register class YoloTestFeed(DataFeed): @@ -988,4 +995,11 @@ class YoloTestFeed(DataFeed): use_process=use_process) self.mode = 'TEST' self.bufsize = 128 + + # support image shape config, resize image with image_shape + for i, trans in enumerate(sample_transforms): + if isinstance(trans, ResizeImage): + sample_transforms[i] = ResizeImage( + target_size=self.image_shape[-1], + interp=trans.interp) # yapf: enable -- GitLab