Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
e40b5907
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看板
未验证
提交
e40b5907
编写于
8月 22, 2018
作者:
Q
Qiyang Min
提交者:
GitHub
8月 22, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1174 from baiyfbupt/python3
Port face_detection to python3
上级
128ae283
cc914743
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
43 addition
and
10 deletion
+43
-10
fluid/face_detection/data_util.py
fluid/face_detection/data_util.py
+3
-0
fluid/face_detection/image_util.py
fluid/face_detection/image_util.py
+4
-0
fluid/face_detection/profile.py
fluid/face_detection/profile.py
+5
-1
fluid/face_detection/pyramidbox.py
fluid/face_detection/pyramidbox.py
+9
-5
fluid/face_detection/reader.py
fluid/face_detection/reader.py
+6
-1
fluid/face_detection/train.py
fluid/face_detection/train.py
+6
-2
fluid/face_detection/utility.py
fluid/face_detection/utility.py
+2
-1
fluid/face_detection/visualize.py
fluid/face_detection/visualize.py
+4
-0
fluid/face_detection/widerface_eval.py
fluid/face_detection/widerface_eval.py
+4
-0
未找到文件。
fluid/face_detection/data_util.py
浏览文件 @
e40b5907
"""
This code is based on https://github.com/fchollet/keras/blob/master/keras/utils/data_utils.py
"""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
time
import
numpy
as
np
...
...
fluid/face_detection/image_util.py
浏览文件 @
e40b5907
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
PIL
import
Image
,
ImageEnhance
,
ImageDraw
from
PIL
import
ImageFile
import
numpy
as
np
...
...
fluid/face_detection/profile.py
浏览文件 @
e40b5907
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
os
import
shutil
import
numpy
as
np
...
...
@@ -59,7 +63,7 @@ def train(args, config, train_file_list, optimizer_method):
loss
=
network
.
vgg_ssd_loss
()
fetches
=
[
loss
]
epocs
=
12880
/
batch_size
epocs
=
12880
/
/
batch_size
boundaries
=
[
epocs
*
40
,
epocs
*
60
,
epocs
*
80
,
epocs
*
100
]
values
=
[
learning_rate
,
learning_rate
*
0.5
,
learning_rate
*
0.25
,
...
...
fluid/face_detection/pyramidbox.py
浏览文件 @
e40b5907
import
numpy
as
np
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
numpy
as
np
import
six
import
paddle.fluid
as
fluid
from
paddle.fluid.param_attr
import
ParamAttr
from
paddle.fluid.initializer
import
Xavier
...
...
@@ -27,13 +31,13 @@ def conv_block(input, groups, filters, ksizes, strides=None, with_pool=True):
w_attr
=
ParamAttr
(
learning_rate
=
1.
,
initializer
=
Xavier
())
b_attr
=
ParamAttr
(
learning_rate
=
2.
,
regularizer
=
L2Decay
(
0.
))
conv
=
input
for
i
in
xrange
(
groups
):
for
i
in
six
.
moves
.
xrange
(
groups
):
conv
=
fluid
.
layers
.
conv2d
(
input
=
conv
,
num_filters
=
filters
[
i
],
filter_size
=
ksizes
[
i
],
stride
=
strides
[
i
],
padding
=
(
ksizes
[
i
]
-
1
)
/
2
,
padding
=
(
ksizes
[
i
]
-
1
)
/
/
2
,
param_attr
=
w_attr
,
bias_attr
=
b_attr
,
act
=
'relu'
)
...
...
@@ -220,7 +224,7 @@ class PyramidBox(object):
def
permute_and_reshape
(
input
,
last_dim
):
trans
=
fluid
.
layers
.
transpose
(
input
,
perm
=
[
0
,
2
,
3
,
1
])
compile_shape
=
[
trans
.
shape
[
0
],
np
.
prod
(
trans
.
shape
[
1
:])
/
last_dim
,
last_dim
trans
.
shape
[
0
],
np
.
prod
(
trans
.
shape
[
1
:])
/
/
last_dim
,
last_dim
]
run_shape
=
fluid
.
layers
.
assign
(
np
.
array
([
0
,
-
1
,
last_dim
]).
astype
(
"int32"
))
...
...
@@ -291,7 +295,7 @@ class PyramidBox(object):
def
permute_and_reshape
(
input
,
last_dim
):
trans
=
fluid
.
layers
.
transpose
(
input
,
perm
=
[
0
,
2
,
3
,
1
])
compile_shape
=
[
trans
.
shape
[
0
],
np
.
prod
(
trans
.
shape
[
1
:])
/
last_dim
,
last_dim
trans
.
shape
[
0
],
np
.
prod
(
trans
.
shape
[
1
:])
/
/
last_dim
,
last_dim
]
run_shape
=
fluid
.
layers
.
assign
(
np
.
array
([
0
,
-
1
,
last_dim
]).
astype
(
"int32"
))
...
...
fluid/face_detection/reader.py
浏览文件 @
e40b5907
...
...
@@ -12,6 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
image_util
from
paddle.utils.image_util
import
*
import
random
...
...
@@ -24,6 +28,7 @@ import time
import
copy
import
random
import
cv2
import
six
from
data_util
import
GeneratorEnqueuer
...
...
@@ -151,7 +156,7 @@ def preprocess(img, bbox_labels, mode, settings, image_path):
mirror
=
int
(
random
.
uniform
(
0
,
2
))
if
mirror
==
1
:
img
=
img
[:,
::
-
1
,
:]
for
i
in
xrange
(
len
(
sampled_labels
)):
for
i
in
six
.
moves
.
xrange
(
len
(
sampled_labels
)):
tmp
=
sampled_labels
[
i
][
1
]
sampled_labels
[
i
][
1
]
=
1
-
sampled_labels
[
i
][
3
]
sampled_labels
[
i
][
3
]
=
1
-
tmp
...
...
fluid/face_detection/train.py
浏览文件 @
e40b5907
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
os
import
shutil
import
numpy
as
np
...
...
@@ -57,7 +61,7 @@ def train(args, config, train_file_list, optimizer_method):
loss
=
network
.
vgg_ssd_loss
()
fetches
=
[
loss
]
steps_per_pass
=
12880
/
batch_size
steps_per_pass
=
12880
/
/
batch_size
boundaries
=
[
steps_per_pass
*
50
,
steps_per_pass
*
80
,
steps_per_pass
*
120
,
steps_per_pass
*
140
]
values
=
[
...
...
@@ -110,7 +114,7 @@ def train(args, config, train_file_list, optimizer_method):
model_path
=
os
.
path
.
join
(
model_save_dir
,
postfix
)
if
os
.
path
.
isdir
(
model_path
):
shutil
.
rmtree
(
model_path
)
print
'save models to %s'
%
(
model_path
)
print
(
'save models to %s'
%
(
model_path
)
)
fluid
.
io
.
save_persistables
(
exe
,
model_path
)
def
tensor
(
data
,
place
,
lod
=
None
):
...
...
fluid/face_detection/utility.py
浏览文件 @
e40b5907
...
...
@@ -16,6 +16,7 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
distutils.util
import
six
def
print_arguments
(
args
):
...
...
@@ -34,7 +35,7 @@ def print_arguments(args):
:type args: argparse.Namespace
"""
print
(
"----------- Configuration Arguments -----------"
)
for
arg
,
value
in
sorted
(
vars
(
args
).
iteritems
(
)):
for
arg
,
value
in
sorted
(
six
.
iteritems
(
vars
(
args
)
)):
print
(
"%s: %s"
%
(
arg
,
value
))
print
(
"------------------------------------------------"
)
...
...
fluid/face_detection/visualize.py
浏览文件 @
e40b5907
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
os
from
PIL
import
Image
from
PIL
import
ImageDraw
...
...
fluid/face_detection/widerface_eval.py
浏览文件 @
e40b5907
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
os
import
time
import
numpy
as
np
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录