From 04a928c151f8c3834b502e8c82415034dc187365 Mon Sep 17 00:00:00 2001
From: dengkaipeng
@@ -95,7 +95,7 @@ To train the model, [cocoapi](https://github.com/cocodataset/cocoapi) is needed.
**training strategy:**
* Use momentum optimizer with momentum=0.9.
-* In first 1000 iteration, the learning rate increases linearly from 0.0 to 0.01. Then lr is decayed at 450000, 500000 iteration with multiplier 0.1, 0.1. The maximum iteration is 500000.
+* In first 1000 iteration, the learning rate increases linearly from 0.0 to 0.01. Then lr is decayed at 450000, 500000 iteration with multiplier 0.1, 0.01. The maximum iteration is 500000.
Training result is shown as below:
diff --git a/fluid/PaddleCV/yolov3/README_cn.md b/fluid/PaddleCV/yolov3/README_cn.md index 99e6e592..60a4a3cc 100644 --- a/fluid/PaddleCV/yolov3/README_cn.md +++ b/fluid/PaddleCV/yolov3/README_cn.md @@ -23,7 +23,7 @@ YOLOv3检测原理
-YOLOv3将输入图像分成S\*S个格子,每个格子预测B个bounding box,每个bounding box预测内容包括: Location(x, y, w, h)、Confidence Score和C个类别的概率,因此YOLOv3输出层的channel数为S\*S\*B\*(5 + C)。YOLOv3的loss函数也有三部分组成:坐标误差,IOU误差和分类误差。 +YOLOv3将输入图像分成S\*S个格子,每个格子预测B个bounding box,每个bounding box预测内容包括: Location(x, y, w, h)、Confidence Score和C个类别的概率,因此YOLOv3输出层的channel数为S\*S\*B\*(5 + C)。YOLOv3的loss函数也有三部分组成:Location误差,Confidence误差和分类误差。 YOLOv3的网络结构如下图所示:diff --git a/fluid/PaddleCV/yolov3/box_utils.py b/fluid/PaddleCV/yolov3/box_utils.py index e7991488..fb8918dc 100644 --- a/fluid/PaddleCV/yolov3/box_utils.py +++ b/fluid/PaddleCV/yolov3/box_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/fluid/PaddleCV/yolov3/config.py b/fluid/PaddleCV/yolov3/config.py index 07adfdb7..1f082c90 100644 --- a/fluid/PaddleCV/yolov3/config.py +++ b/fluid/PaddleCV/yolov3/config.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. #You may obtain a copy of the License at diff --git a/fluid/PaddleCV/yolov3/edict.py b/fluid/PaddleCV/yolov3/edict.py index 415cc6f7..552ede8e 100644 --- a/fluid/PaddleCV/yolov3/edict.py +++ b/fluid/PaddleCV/yolov3/edict.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve. # #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. diff --git a/fluid/PaddleCV/yolov3/eval.py b/fluid/PaddleCV/yolov3/eval.py index 31463fc3..9a0ceae2 100644 --- a/fluid/PaddleCV/yolov3/eval.py +++ b/fluid/PaddleCV/yolov3/eval.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve. # #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. diff --git a/fluid/PaddleCV/yolov3/image_utils.py b/fluid/PaddleCV/yolov3/image_utils.py index 73825505..6933721e 100644 --- a/fluid/PaddleCV/yolov3/image_utils.py +++ b/fluid/PaddleCV/yolov3/image_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/fluid/PaddleCV/yolov3/infer.py b/fluid/PaddleCV/yolov3/infer.py index 1b6958e1..58615ccf 100644 --- a/fluid/PaddleCV/yolov3/infer.py +++ b/fluid/PaddleCV/yolov3/infer.py @@ -1,3 +1,18 @@ +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + import os import time import numpy as np diff --git a/fluid/PaddleCV/yolov3/learning_rate.py b/fluid/PaddleCV/yolov3/learning_rate.py index a4c9dfb6..d712832d 100644 --- a/fluid/PaddleCV/yolov3/learning_rate.py +++ b/fluid/PaddleCV/yolov3/learning_rate.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve. # #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. diff --git a/fluid/PaddleCV/yolov3/models/yolov3.py b/fluid/PaddleCV/yolov3/models/yolov3.py index 74b9c782..99ce2769 100644 --- a/fluid/PaddleCV/yolov3/models/yolov3.py +++ b/fluid/PaddleCV/yolov3/models/yolov3.py @@ -1,5 +1,4 @@ - -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve. # #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. @@ -68,11 +67,40 @@ class YOLOv3(object): self.ignore_thresh = .7 self.class_num = 80 - def build_model(self): - - self.img_height = cfg.input_size - self.img_width = cfg.input_size + def build_input(self): + self.image_shape = [3, cfg.input_size, cfg.input_size] + if self.use_pyreader and self.is_train: + self.py_reader = fluid.layers.py_reader( + capacity=64, + shapes = [[-1] + self.image_shape, [-1, cfg.max_box_num, 4], [-1, cfg.max_box_num], [-1, cfg.max_box_num]], + lod_levels=[0, 0, 0, 0], + dtypes=['float32'] * 2 + ['int32'] + ['float32'], + use_double_buffer=True) + self.image, self.gtbox, self.gtlabel, self.gtscore = fluid.layers.read_file(self.py_reader) + else: + self.image = fluid.layers.data( + name='image', shape=self.image_shape, dtype='float32' + ) + self.gtbox = fluid.layers.data( + name='gtbox', shape=[cfg.max_box_num, 4], dtype='float32' + ) + self.gtlabel = fluid.layers.data( + name='gtlabel', shape=[cfg.max_box_num], dtype='int32' + ) + self.gtscore = fluid.layers.data( + name='gtscore', shape=[cfg.max_box_num], dtype='float32' + ) + self.im_shape = fluid.layers.data( + name="im_shape", shape=[2], dtype='int32') + self.im_id = fluid.layers.data( + name="im_id", shape=[1], dtype='int32') + + def feeds(self): + if not self.is_train: + return [self.image, self.im_id, self.im_shape] + return [self.image, self.gtbox, self.gtlabel, self.gtscore] + def build_model(self): self.build_input() self.outputs = [] @@ -172,36 +200,3 @@ class YOLOv3(object): background_label=-1, name="multiclass_nms") - def build_input(self): - self.image_shape = [3, self.img_height, self.img_width] - if self.use_pyreader and self.is_train: - self.py_reader = fluid.layers.py_reader( - capacity=64, - shapes = [[-1] + self.image_shape, [-1, cfg.max_box_num, 4], [-1, cfg.max_box_num], [-1, cfg.max_box_num]], - lod_levels=[0, 0, 0, 0], - dtypes=['float32'] * 2 + ['int32'] + ['float32'], - use_double_buffer=True) - self.image, self.gtbox, self.gtlabel, self.gtscore = fluid.layers.read_file(self.py_reader) - else: - self.image = fluid.layers.data( - name='image', shape=self.image_shape, dtype='float32' - ) - self.gtbox = fluid.layers.data( - name='gtbox', shape=[cfg.max_box_num, 4], dtype='float32' - ) - self.gtlabel = fluid.layers.data( - name='gtlabel', shape=[cfg.max_box_num], dtype='int32' - ) - self.gtscore = fluid.layers.data( - name='gtscore', shape=[cfg.max_box_num], dtype='float32' - ) - self.im_shape = fluid.layers.data( - name="im_shape", shape=[2], dtype='int32') - self.im_id = fluid.layers.data( - name="im_id", shape=[1], dtype='int32') - - def feeds(self): - if not self.is_train: - return [self.image, self.im_id, self.im_shape] - return [self.image, self.gtbox, self.gtlabel, self.gtscore] - diff --git a/fluid/PaddleCV/yolov3/profile.py b/fluid/PaddleCV/yolov3/profile.py index 01e97e6e..34c5231d 100644 --- a/fluid/PaddleCV/yolov3/profile.py +++ b/fluid/PaddleCV/yolov3/profile.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve. # #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. diff --git a/fluid/PaddleCV/yolov3/reader.py b/fluid/PaddleCV/yolov3/reader.py index 5427483b..5d37402d 100644 --- a/fluid/PaddleCV/yolov3/reader.py +++ b/fluid/PaddleCV/yolov3/reader.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/fluid/PaddleCV/yolov3/train.py b/fluid/PaddleCV/yolov3/train.py index 675441aa..2ebc536a 100644 --- a/fluid/PaddleCV/yolov3/train.py +++ b/fluid/PaddleCV/yolov3/train.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve. # #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. diff --git a/fluid/PaddleCV/yolov3/utility.py b/fluid/PaddleCV/yolov3/utility.py index 55ea4b02..436b2a98 100644 --- a/fluid/PaddleCV/yolov3/utility.py +++ b/fluid/PaddleCV/yolov3/utility.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve. # #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. -- GitLab