Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
Models
提交
31a9096c
M
Models
项目概览
MegEngine 天元
/
Models
通知
6
Star
3
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
31a9096c
编写于
8月 15, 2020
作者:
J
Jianfeng Wang
提交者:
GitHub
8月 15, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(detection): pad before norm in preparing (#57)
上级
a25570d6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
14 addition
and
9 deletion
+14
-9
official/vision/detection/models/faster_rcnn.py
official/vision/detection/models/faster_rcnn.py
+4
-2
official/vision/detection/models/retinanet.py
official/vision/detection/models/retinanet.py
+6
-3
official/vision/detection/tools/inference.py
official/vision/detection/tools/inference.py
+1
-1
official/vision/detection/tools/test.py
official/vision/detection/tools/test.py
+1
-1
official/vision/detection/tools/utils.py
official/vision/detection/tools/utils.py
+2
-2
未找到文件。
official/vision/detection/models/faster_rcnn.py
浏览文件 @
31a9096c
...
...
@@ -67,10 +67,12 @@ class FasterRCNN(M.Module):
}
def
preprocess_image
(
self
,
image
):
padded_image
=
layers
.
get_padded_tensor
(
image
,
32
,
0.0
)
normed_image
=
(
image
-
np
.
array
(
self
.
cfg
.
img_mean
,
dtype
=
np
.
float32
)[
None
,
:,
None
,
None
]
padded_image
-
np
.
array
(
self
.
cfg
.
img_mean
,
dtype
=
np
.
float32
)[
None
,
:,
None
,
None
]
)
/
np
.
array
(
self
.
cfg
.
img_std
,
dtype
=
np
.
float32
)[
None
,
:,
None
,
None
]
return
layers
.
get_padded_tensor
(
normed_image
,
32
,
0.0
)
return
normed_image
def
forward
(
self
,
inputs
):
images
=
inputs
[
"image"
]
...
...
official/vision/detection/models/retinanet.py
浏览文件 @
31a9096c
...
...
@@ -81,10 +81,12 @@ class RetinaNet(M.Module):
self
.
loss_normalizer
=
mge
.
tensor
(
100.0
)
def
preprocess_image
(
self
,
image
):
padded_image
=
layers
.
get_padded_tensor
(
image
,
32
,
0.0
)
normed_image
=
(
image
-
np
.
array
(
self
.
cfg
.
img_mean
,
dtype
=
np
.
float32
)[
None
,
:,
None
,
None
]
padded_image
-
np
.
array
(
self
.
cfg
.
img_mean
,
dtype
=
np
.
float32
)[
None
,
:,
None
,
None
]
)
/
np
.
array
(
self
.
cfg
.
img_std
,
dtype
=
np
.
float32
)[
None
,
:,
None
,
None
]
return
layers
.
get_padded_tensor
(
normed_image
,
32
,
0.0
)
return
normed_image
def
forward
(
self
,
inputs
):
image
=
self
.
preprocess_image
(
inputs
[
"image"
])
...
...
@@ -98,7 +100,8 @@ class RetinaNet(M.Module):
for
_
in
box_logits
]
box_offsets_list
=
[
_
.
dimshuffle
(
0
,
2
,
3
,
1
).
reshape
(
self
.
batch_size
,
-
1
,
4
)
for
_
in
box_offsets
_
.
dimshuffle
(
0
,
2
,
3
,
1
).
reshape
(
self
.
batch_size
,
-
1
,
4
)
for
_
in
box_offsets
]
anchors_list
=
[
...
...
official/vision/detection/tools/inference.py
浏览文件 @
31a9096c
...
...
@@ -57,8 +57,8 @@ def main():
data
,
im_info
=
DetEvaluator
.
process_inputs
(
ori_img
.
copy
(),
model
.
cfg
.
test_image_short_size
,
model
.
cfg
.
test_image_max_size
,
)
model
.
inputs
[
"image"
].
set_value
(
data
)
model
.
inputs
[
"im_info"
].
set_value
(
im_info
)
model
.
inputs
[
"image"
].
set_value
(
data
.
astype
(
np
.
float32
))
pred_res
=
evaluator
.
predict
(
val_func
)
res_img
=
DetEvaluator
.
vis_det
(
ori_img
,
pred_res
,
is_show_label
=
True
,
classes
=
COCO
.
class_names
,
...
...
official/vision/detection/tools/test.py
浏览文件 @
31a9096c
...
...
@@ -175,8 +175,8 @@ def worker(
model
.
cfg
.
test_image_short_size
,
model
.
cfg
.
test_image_max_size
,
)
model
.
inputs
[
"image"
].
set_value
(
data
)
model
.
inputs
[
"im_info"
].
set_value
(
im_info
)
model
.
inputs
[
"image"
].
set_value
(
data
.
astype
(
np
.
float32
))
pred_res
=
evaluator
.
predict
(
val_func
)
result_queue
.
put_nowait
(
...
...
official/vision/detection/tools/utils.py
浏览文件 @
31a9096c
...
...
@@ -89,7 +89,7 @@ class DetectionPadCollator(Collator):
batch_data
=
defaultdict
(
list
)
for
image
,
boxes
,
boxes_category
,
info
in
inputs
:
batch_data
[
"data"
].
append
(
image
)
batch_data
[
"data"
].
append
(
image
.
astype
(
np
.
float32
)
)
batch_data
[
"gt_boxes"
].
append
(
np
.
concatenate
([
boxes
,
boxes_category
[:,
np
.
newaxis
]],
axis
=
1
).
astype
(
np
.
float32
...
...
@@ -172,7 +172,7 @@ class DetEvaluator:
)
resized_img
=
cv2
.
flip
(
resized_img
,
1
)
if
flip
else
resized_img
trans_img
=
np
.
ascontiguousarray
(
resized_img
.
transpose
(
2
,
0
,
1
)[
None
,
:,
:,
:],
dtype
=
np
.
uint8
resized_img
.
transpose
(
2
,
0
,
1
)[
None
,
:,
:,
:],
dtype
=
np
.
float32
)
im_info
=
np
.
array
(
[(
resized_height
,
resized_width
,
original_height
,
original_width
)],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录