Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
e2b98dc5
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看板
未验证
提交
e2b98dc5
编写于
10月 31, 2018
作者:
Q
qingqing01
提交者:
GitHub
10月 31, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add clipping before visulization in detection model. (#1415)
* Fix label lists for inference. * Add clipping before visulization.
上级
e277fed6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
8 deletion
+17
-8
fluid/PaddleCV/object_detection/README_quant.md
fluid/PaddleCV/object_detection/README_quant.md
+4
-3
fluid/PaddleCV/object_detection/infer.py
fluid/PaddleCV/object_detection/infer.py
+11
-3
fluid/PaddleCV/object_detection/main_quant.py
fluid/PaddleCV/object_detection/main_quant.py
+2
-2
未找到文件。
fluid/PaddleCV/object_detection/README_quant.md
浏览文件 @
e2b98dc5
...
...
@@ -43,7 +43,7 @@ A Python transpiler is used to rewrite Fluid training program or evaluation prog
The training is fine-tuned on the well-trained MobileNet-SSD model. So download model at first:
```
bash
```
wget http://paddlemodels.bj.bcebos.com/ssd_mobilenet_v1_pascalvoc.tar.gz
```
...
...
@@ -111,7 +111,7 @@ A Python transpiler is used to rewrite Fluid training program or evaluation prog
Users can evaluate the converted model by:
```
bash
```
python main_quant.py \
--data_dir=$PascalVOC_DIR$ \
--mode='test' \
...
...
@@ -121,10 +121,11 @@ A Python transpiler is used to rewrite Fluid training program or evaluation prog
You also can check the 8-bit model by the inference scripts
```
bash
```
python main_quant.py \
--mode='infer' \
--init_model=$MobileNet_SSD_8BIT_MODEL$ \
--confs_threshold=0.5 \
--image_path='/data/PascalVOC/VOCdevkit/VOC2007/JPEGImages/002271.jpg'
```
See 002271.jpg for the visualized image with bbouding boxes.
...
...
fluid/PaddleCV/object_detection/infer.py
浏览文件 @
e2b98dc5
...
...
@@ -85,11 +85,11 @@ def draw_bounding_box_on_image(image_path, nms_out, confs_threshold,
im_width
,
im_height
=
image
.
size
for
dt
in
nms_out
:
category_id
,
score
,
xmin
,
ymin
,
xmax
,
ymax
=
dt
.
tolist
()
if
score
<
confs_threshold
:
if
dt
[
1
]
<
confs_threshold
:
continue
category_id
=
dt
[
0
]
bbox
=
dt
[
2
:]
xmin
,
ymin
,
xmax
,
ymax
=
bbox
xmin
,
ymin
,
xmax
,
ymax
=
clip_bbox
(
dt
[
2
:])
(
left
,
right
,
top
,
bottom
)
=
(
xmin
*
im_width
,
xmax
*
im_width
,
ymin
*
im_height
,
ymax
*
im_height
)
draw
.
line
(
...
...
@@ -104,6 +104,14 @@ def draw_bounding_box_on_image(image_path, nms_out, confs_threshold,
image
.
save
(
image_name
)
def
clip_bbox
(
bbox
):
xmin
=
max
(
min
(
bbox
[
0
],
1.
),
0.
)
ymin
=
max
(
min
(
bbox
[
1
],
1.
),
0.
)
xmax
=
max
(
min
(
bbox
[
2
],
1.
),
0.
)
ymax
=
max
(
min
(
bbox
[
3
],
1.
),
0.
)
return
xmin
,
ymin
,
xmax
,
ymax
if
__name__
==
'__main__'
:
args
=
parser
.
parse_args
()
print_arguments
(
args
)
...
...
fluid/PaddleCV/object_detection/main_quant.py
浏览文件 @
e2b98dc5
...
...
@@ -227,8 +227,8 @@ def infer(args, data_args):
executor
=
exe
,
model_filename
=
'__model__'
)
print
(
np
.
array
(
fluid
.
global_scope
().
find_var
(
'conv2d_20.w_0'
).
get_tensor
()))
print
(
np
.
max
(
np
.
array
(
fluid
.
global_scope
().
find_var
(
'conv2d_20.w_0'
).
get_tensor
())))
#
print(np.array(fluid.global_scope().find_var('conv2d_20.w_0').get_tensor()))
#
print(np.max(np.array(fluid.global_scope().find_var('conv2d_20.w_0').get_tensor())))
infer_reader
=
reader
.
infer
(
data_args
,
image_path
)
data
=
infer_reader
()
data
=
data
.
reshape
((
1
,)
+
data
.
shape
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录