Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
bb7ae5d9
M
models
项目概览
PaddlePaddle
/
models
1 年多 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
bb7ae5d9
编写于
1月 21, 2019
作者:
D
dengkaipeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fit for darknet
上级
ca44df94
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
32 deletion
+36
-32
fluid/PaddleCV/yolov3/config/config.py
fluid/PaddleCV/yolov3/config/config.py
+3
-3
fluid/PaddleCV/yolov3/image_utils.py
fluid/PaddleCV/yolov3/image_utils.py
+12
-3
fluid/PaddleCV/yolov3/reader.py
fluid/PaddleCV/yolov3/reader.py
+18
-23
fluid/PaddleCV/yolov3/utility.py
fluid/PaddleCV/yolov3/utility.py
+3
-3
未找到文件。
fluid/PaddleCV/yolov3/config/config.py
浏览文件 @
bb7ae5d9
...
...
@@ -72,15 +72,15 @@ _C.pixel_stds = [0.229, 0.224, 0.225]
_C
.
learning_rate
=
0.001
# maximum number of iterations
_C
.
max_iter
=
500
2
00
_C
.
max_iter
=
500
0
00
# warm up to learning rate
_C
.
warm_up_iter
=
4000
_C
.
warm_up_factor
=
0.
# lr steps_with_decay
_C
.
lr_steps
=
[
400000
,
450000
]
_C
.
lr_gamma
=
0.1
_C
.
lr_steps
=
[
300000
,
400000
,
450000
]
_C
.
lr_gamma
=
[
0.2
,
0.5
,
0.1
]
# L2 regularization hyperparameter
_C
.
weight_decay
=
0.0005
...
...
fluid/PaddleCV/yolov3/image_utils.py
浏览文件 @
bb7ae5d9
...
...
@@ -105,7 +105,7 @@ def random_flip(img, gtboxes, thresh=0.5):
gtboxes
[:,
0
]
=
1.0
-
gtboxes
[:,
0
]
return
img
,
gtboxes
def
random_interp
(
img
,
size
):
def
random_interp
(
img
,
size
,
interp
=
None
):
interp_method
=
[
cv2
.
INTER_NEAREST
,
cv2
.
INTER_LINEAR
,
...
...
@@ -113,7 +113,8 @@ def random_interp(img, size):
cv2
.
INTER_CUBIC
,
cv2
.
INTER_LANCZOS4
,
]
interp
=
interp_method
[
random
.
randint
(
0
,
len
(
interp_method
)
-
1
)]
if
not
interp
or
interp
not
in
interp_method
:
interp
=
interp_method
[
random
.
randint
(
0
,
len
(
interp_method
)
-
1
)]
h
,
w
,
_
=
img
.
shape
im_scale_x
=
size
/
float
(
w
)
im_scale_y
=
size
/
float
(
h
)
...
...
@@ -151,6 +152,13 @@ def random_expand(img, gtboxes, max_ratio=4., fill=None, keep_ratio=True, thresh
return
out_img
.
astype
(
'uint8'
),
gtboxes
def
shuffle_gtbox
(
gtbox
,
gtlabel
,
gtscore
):
gt
=
np
.
concatenate
([
gtbox
,
gtlabel
[:,
np
.
newaxis
],
gtscore
[:,
np
.
newaxis
]],
axis
=
1
)
idx
=
np
.
arange
(
gt
.
shape
[
1
])
np
.
random
.
shuffle
(
idx
)
gt
=
gt
[
idx
,
:]
return
gt
[:,
:
4
],
gt
[:,
4
],
gt
[:,
5
]
def
image_mixup
(
img1
,
gtboxes1
,
gtlabels1
,
gtscores1
,
img2
,
gtboxes2
,
gtlabels2
,
gtscores2
):
factor
=
np
.
random
.
beta
(
1.5
,
1.5
)
factor
=
max
(
0.0
,
min
(
1.0
,
factor
))
...
...
@@ -201,8 +209,9 @@ def image_augment(img, gtboxes, gtlabels, gtscores, size, means=None):
img
=
random_distort
(
img
)
img
,
gtboxes
=
random_expand
(
img
,
gtboxes
,
fill
=
means
)
img
,
gtboxes
,
gtlabels
,
gtscores
=
random_crop
(
img
,
gtboxes
,
gtlabels
,
gtscores
)
img
=
random_interp
(
img
,
size
)
img
=
random_interp
(
img
,
size
,
cv2
.
INTER_LINEAR
)
img
,
gtboxes
=
random_flip
(
img
,
gtboxes
)
gtboxes
,
gtlabels
,
gtscores
=
shuffle_gtbox
(
gtboxes
,
gtlabels
,
gtscores
)
return
img
.
astype
(
'float32'
),
gtboxes
.
astype
(
'float32'
),
\
gtlabels
.
astype
(
'int32'
),
gtscores
.
astype
(
'float32'
)
...
...
fluid/PaddleCV/yolov3/reader.py
浏览文件 @
bb7ae5d9
...
...
@@ -38,23 +38,23 @@ class DataSetReader(object):
self
.
has_parsed_categpry
=
False
def
_parse_dataset_dir
(
self
,
mode
):
#
cfg.data_dir = "dataset/coco"
#
cfg.train_file_list = 'annotations/instances_val2017.json'
#
cfg.train_data_dir = 'val2017'
#
cfg.dataset = "coco2017"
if
'coco2014'
in
cfg
.
dataset
:
cfg
.
train_file_list
=
'annotations/instances_train2014.json'
cfg
.
train_data_dir
=
'train2014'
cfg
.
val_file_list
=
'annotations/instances_val2014.json'
cfg
.
val_data_dir
=
'val2014'
elif
'coco2017'
in
cfg
.
dataset
:
cfg
.
train_file_list
=
'annotations/instances_train2017.json'
cfg
.
train_data_dir
=
'train2017'
cfg
.
val_file_list
=
'annotations/instances_val2017.json'
cfg
.
val_data_dir
=
'val2017'
else
:
raise
NotImplementedError
(
'Dataset {} not supported'
.
format
(
cfg
.
dataset
))
cfg
.
data_dir
=
"dataset/coco"
cfg
.
train_file_list
=
'annotations/instances_val2017.json'
cfg
.
train_data_dir
=
'val2017'
cfg
.
dataset
=
"coco2017"
#
if 'coco2014' in cfg.dataset:
#
cfg.train_file_list = 'annotations/instances_train2014.json'
#
cfg.train_data_dir = 'train2014'
#
cfg.val_file_list = 'annotations/instances_val2014.json'
#
cfg.val_data_dir = 'val2014'
#
elif 'coco2017' in cfg.dataset:
#
cfg.train_file_list = 'annotations/instances_train2017.json'
#
cfg.train_data_dir = 'train2017'
#
cfg.val_file_list = 'annotations/instances_val2017.json'
#
cfg.val_data_dir = 'val2017'
#
else:
#
raise NotImplementedError('Dataset {} not supported'.format(
#
cfg.dataset))
if
mode
==
'train'
:
cfg
.
train_file_list
=
os
.
path
.
join
(
cfg
.
data_dir
,
cfg
.
train_file_list
)
...
...
@@ -156,7 +156,7 @@ class DataSetReader(object):
h
,
w
,
_
=
im
.
shape
im_scale_x
=
size
/
float
(
w
)
im_scale_y
=
size
/
float
(
h
)
out_img
=
cv2
.
resize
(
im
,
None
,
None
,
fx
=
im_scale_x
,
fy
=
im_scale_y
,
interpolation
=
cv2
.
INTER_
CUBIC
)
out_img
=
cv2
.
resize
(
im
,
None
,
None
,
fx
=
im_scale_x
,
fy
=
im_scale_y
,
interpolation
=
cv2
.
INTER_
LINEAR
)
mean
=
np
.
array
(
mean
).
reshape
((
1
,
1
,
-
1
))
std
=
np
.
array
(
std
).
reshape
((
1
,
1
,
-
1
))
out_img
=
(
out_img
/
255.0
-
mean
)
/
std
...
...
@@ -184,11 +184,6 @@ class DataSetReader(object):
im
,
gt_boxes
,
gt_labels
,
gt_scores
=
image_utils
.
image_augment
(
im
,
gt_boxes
,
gt_labels
,
gt_scores
,
size
,
mean
)
# h, w, _ = im.shape
# im_scale_x = size / float(w)
# im_scale_y = size / float(h)
# im = cv2.resize(im, None, None, fx=im_scale_x, fy=im_scale_y, interpolation=cv2.INTER_CUBIC)
mean
=
np
.
array
(
mean
).
reshape
((
1
,
1
,
-
1
))
std
=
np
.
array
(
std
).
reshape
((
1
,
1
,
-
1
))
out_img
=
(
im
/
255.0
-
mean
)
/
std
...
...
fluid/PaddleCV/yolov3/utility.py
浏览文件 @
bb7ae5d9
...
...
@@ -115,9 +115,9 @@ def parse_args():
# TRAIN TEST INFER
add_arg
(
'input_size'
,
int
,
608
,
"Image input size of YOLOv3."
)
add_arg
(
'random_shape'
,
bool
,
True
,
"Resize to random shape for train reader."
)
add_arg
(
'label_smooth'
,
bool
,
Tru
e
,
"Use label smooth in class label."
)
add_arg
(
'no_mixup_iter'
,
int
,
400
00
,
"Disable mixup in last N iter."
)
add_arg
(
'valid_thresh'
,
float
,
0.0
1
,
"Valid confidence score for NMS."
)
add_arg
(
'label_smooth'
,
bool
,
Fals
e
,
"Use label smooth in class label."
)
add_arg
(
'no_mixup_iter'
,
int
,
5002
00
,
"Disable mixup in last N iter."
)
add_arg
(
'valid_thresh'
,
float
,
0.0
05
,
"Valid confidence score for NMS."
)
add_arg
(
'nms_thresh'
,
float
,
0.45
,
"NMS threshold."
)
add_arg
(
'nms_topk'
,
int
,
400
,
"The number of boxes to perform NMS."
)
add_arg
(
'nms_posk'
,
int
,
100
,
"The number of boxes of NMS output."
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录