Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
8ceb9849
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看板
提交
8ceb9849
编写于
2月 01, 2019
作者:
D
dengkaipeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove center constraint in box_crop
上级
3be84530
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
12 addition
and
8 deletion
+12
-8
fluid/PaddleCV/yolov3/box_utils.py
fluid/PaddleCV/yolov3/box_utils.py
+6
-3
fluid/PaddleCV/yolov3/image_utils.py
fluid/PaddleCV/yolov3/image_utils.py
+1
-1
fluid/PaddleCV/yolov3/learning_rate.py
fluid/PaddleCV/yolov3/learning_rate.py
+1
-1
fluid/PaddleCV/yolov3/reader.py
fluid/PaddleCV/yolov3/reader.py
+3
-2
fluid/PaddleCV/yolov3/train.py
fluid/PaddleCV/yolov3/train.py
+1
-1
未找到文件。
fluid/PaddleCV/yolov3/box_utils.py
浏览文件 @
8ceb9849
...
...
@@ -138,6 +138,8 @@ def rescale_box_in_input_image(boxes, im_shape, input_size):
boxes
[:,
2
]
*=
fx
boxes
[:,
3
]
*=
fy
boxes
[
boxes
<
0
]
=
0
boxes
[:,
2
][
boxes
[:,
2
]
>
(
w
-
1
)]
=
w
-
1
boxes
[:,
3
][
boxes
[:,
3
]
>
(
h
-
1
)]
=
h
-
1
return
boxes
def
box_crop
(
boxes
,
labels
,
scores
,
crop
,
img_shape
):
...
...
@@ -149,15 +151,16 @@ def box_crop(boxes, labels, scores, crop, img_shape):
boxes
[:,
1
],
boxes
[:,
3
]
=
(
boxes
[:,
1
]
-
boxes
[:,
3
]
/
2
)
*
im_h
,
(
boxes
[:,
1
]
+
boxes
[:,
3
]
/
2
)
*
im_h
crop_box
=
np
.
array
([
x
,
y
,
x
+
w
,
y
+
h
])
centers
=
(
boxes
[:,
:
2
]
+
boxes
[:,
2
:])
/
2.0
mask
=
np
.
logical_and
(
crop_box
[:
2
]
<=
centers
,
centers
<=
crop_box
[
2
:]).
all
(
axis
=
1
)
#
centers = (boxes[:, :2] + boxes[:, 2:]) / 2.0
#
mask = np.logical_and(crop_box[:2] <= centers, centers <= crop_box[2:]).all(axis=1)
boxes
[:,
:
2
]
=
np
.
maximum
(
boxes
[:,
:
2
],
crop_box
[:
2
])
boxes
[:,
2
:]
=
np
.
minimum
(
boxes
[:,
2
:],
crop_box
[
2
:])
boxes
[:,
:
2
]
-=
crop_box
[:
2
]
boxes
[:,
2
:]
-=
crop_box
[:
2
]
mask
=
np
.
logical_and
(
mask
,
(
boxes
[:,
:
2
]
<
boxes
[:,
2
:]).
all
(
axis
=
1
))
# mask = np.logical_and(mask, (boxes[:, :2] < boxes[:, 2:]).all(axis=1))
mask
=
(
boxes
[:,
:
2
]
<
boxes
[:,
2
:]).
all
(
axis
=
1
)
boxes
=
boxes
*
np
.
expand_dims
(
mask
.
astype
(
'float32'
),
axis
=
1
)
labels
=
labels
*
mask
.
astype
(
'float32'
)
scores
=
scores
*
mask
.
astype
(
'float32'
)
...
...
fluid/PaddleCV/yolov3/image_utils.py
浏览文件 @
8ceb9849
...
...
@@ -121,7 +121,7 @@ def random_interp(img, size, interp=None):
img
=
cv2
.
resize
(
img
,
None
,
None
,
fx
=
im_scale_x
,
fy
=
im_scale_y
,
interpolation
=
interp
)
return
img
def
random_expand
(
img
,
gtboxes
,
max_ratio
=
2
.
,
fill
=
None
,
keep_ratio
=
True
,
thresh
=
0.5
):
def
random_expand
(
img
,
gtboxes
,
max_ratio
=
4
.
,
fill
=
None
,
keep_ratio
=
True
,
thresh
=
0.5
):
if
random
.
random
()
>
thresh
:
return
img
,
gtboxes
...
...
fluid/PaddleCV/yolov3/learning_rate.py
浏览文件 @
8ceb9849
...
...
@@ -23,7 +23,7 @@ from paddle.fluid.layers import control_flow
def
exponential_with_warmup_decay
(
learning_rate
,
boundaries
,
values
,
warmup_iter
,
warmup_factor
,
start_step
):
global_step
=
lr_scheduler
.
_decay_step_counter
()
+
start_step
global_step
=
lr_scheduler
.
_decay_step_counter
()
lr
=
fluid
.
layers
.
create_global_var
(
shape
=
[
1
],
...
...
fluid/PaddleCV/yolov3/reader.py
浏览文件 @
8ceb9849
...
...
@@ -267,8 +267,8 @@ def train(size=416,
interval
=
10
,
pyreader_num
=
1
,
use_multiprocessing
=
True
,
num_workers
=
8
,
max_queue
=
24
):
num_workers
=
12
,
max_queue
=
32
):
generator
=
dsr
.
get_reader
(
'train'
,
size
,
batch_size
,
shuffle
,
mixup_iter
,
random_sizes
)
if
not
use_multiprocessing
:
...
...
@@ -302,6 +302,7 @@ def train(size=416,
cnt
+=
1
if
cnt
%
intervals
==
0
:
idx
=
np
.
random
.
randint
(
len
(
random_sizes
))
print
(
"Resizing: "
,
(
idx
+
10
)
*
32
)
finally
:
if
enqueuer
is
not
None
:
enqueuer
.
stop
()
...
...
fluid/PaddleCV/yolov3/train.py
浏览文件 @
8ceb9849
...
...
@@ -96,7 +96,7 @@ def train():
mixup_iter
=
cfg
.
max_iter
-
cfg
.
start_iter
-
cfg
.
no_mixup_iter
if
cfg
.
use_pyreader
:
train_reader
=
reader
.
train
(
input_size
,
batch_size
=
int
(
hyperparams
[
'batch'
])
/
devices_num
,
shuffle
=
True
,
mixup_iter
=
mixup_iter
,
random_sizes
=
random_sizes
,
interval
=
10
,
pyreader_num
=
devices
,
use_multiprocessing
=
cfg
.
use_multiprocess
)
train_reader
=
reader
.
train
(
input_size
,
batch_size
=
int
(
hyperparams
[
'batch'
])
/
devices_num
,
shuffle
=
True
,
mixup_iter
=
mixup_iter
,
random_sizes
=
random_sizes
,
interval
=
10
,
pyreader_num
=
devices
_num
,
use_multiprocessing
=
cfg
.
use_multiprocess
)
py_reader
=
model
.
py_reader
py_reader
.
decorate_paddle_reader
(
train_reader
)
else
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录