Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
26b3788b
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
26b3788b
编写于
4月 12, 2018
作者:
Y
Yuan Gao
提交者:
qingqing01
4月 12, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix data aug (#829)
* fix expand data aug * fix expand data aug
上级
6fa30500
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
6 addition
and
9 deletion
+6
-9
fluid/object_detection/image_util.py
fluid/object_detection/image_util.py
+5
-6
fluid/object_detection/reader.py
fluid/object_detection/reader.py
+1
-3
未找到文件。
fluid/object_detection/image_util.py
浏览文件 @
26b3788b
...
...
@@ -85,8 +85,7 @@ def satisfy_sample_constraint(sampler, sample_bbox, bbox_labels):
return
False
def
generate_batch_samples
(
batch_sampler
,
bbox_labels
,
image_width
,
image_height
):
def
generate_batch_samples
(
batch_sampler
,
bbox_labels
):
sampled_bbox
=
[]
index
=
[]
c
=
0
...
...
@@ -217,8 +216,8 @@ def distort_image(img, settings):
def
expand_image
(
img
,
bbox_labels
,
img_width
,
img_height
,
settings
):
prob
=
random
.
uniform
(
0
,
1
)
if
prob
<
settings
.
_expand_prob
:
expand_ratio
=
random
.
uniform
(
1
,
settings
.
_expand_max_ratio
)
if
expand_ratio
-
1
>=
0.01
:
if
_expand_max_ratio
-
1
>=
0.01
:
expand_ratio
=
random
.
uniform
(
1
,
settings
.
_expand_max_ratio
)
height
=
int
(
img_height
*
expand_ratio
)
width
=
int
(
img_width
*
expand_ratio
)
h_off
=
math
.
floor
(
random
.
uniform
(
0
,
height
-
img_height
))
...
...
@@ -231,5 +230,5 @@ def expand_image(img, bbox_labels, img_width, img_height, settings):
expand_img
=
Image
.
fromarray
(
expand_img
)
expand_img
.
paste
(
img
,
(
int
(
w_off
),
int
(
h_off
)))
bbox_labels
=
transform_labels
(
bbox_labels
,
expand_bbox
)
return
expand_img
,
bbox_labels
return
img
,
bbox_labels
return
expand_img
,
bbox_labels
,
width
,
height
return
img
,
bbox_labels
,
img_width
,
img_height
fluid/object_detection/reader.py
浏览文件 @
26b3788b
...
...
@@ -193,7 +193,7 @@ def _reader_creator(settings, file_list, mode, shuffle):
if
settings
.
_apply_distort
:
img
=
image_util
.
distort_image
(
img
,
settings
)
if
settings
.
_apply_expand
:
img
,
bbox_labels
=
image_util
.
expand_image
(
img
,
bbox_labels
,
img_width
,
img_height
=
image_util
.
expand_image
(
img
,
bbox_labels
,
img_width
,
img_height
,
settings
)
batch_sampler
=
[]
# hard-code here
...
...
@@ -236,7 +236,6 @@ def _reader_creator(settings, file_list, mode, shuffle):
sample_labels
[
i
][
1
]
=
1
-
sample_labels
[
i
][
3
]
sample_labels
[
i
][
3
]
=
1
-
tmp
#draw_bounding_box_on_image(img, sample_labels, image_name, category_names, normalized=True)
# HWC to CHW
if
len
(
img
.
shape
)
==
3
:
img
=
np
.
swapaxes
(
img
,
1
,
2
)
...
...
@@ -287,7 +286,6 @@ def draw_bounding_box_on_image(image,
(
left
,
top
)],
width
=
thickness
,
fill
=
color
)
#draw.rectangle([xmin, ymin, xmax, ymax], outline=color)
if
with_text
:
if
image
.
mode
==
'RGB'
:
draw
.
text
((
left
,
top
),
category_name
,
(
255
,
255
,
0
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录