Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Jeffcarl
fcos
提交
18c3934d
F
fcos
项目概览
Jeffcarl
/
fcos
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fcos
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
18c3934d
编写于
11月 20, 2019
作者:
Z
Zhi Tian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
onnx done
上级
cd4be13c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
7 deletion
+17
-7
fcos_core/modeling/backbone/fpn.py
fcos_core/modeling/backbone/fpn.py
+4
-3
fcos_core/modeling/rpn/fcos/inference.py
fcos_core/modeling/rpn/fcos/inference.py
+8
-1
tools/test_fcos_onnx_model.py
tools/test_fcos_onnx_model.py
+5
-3
未找到文件。
fcos_core/modeling/backbone/fpn.py
浏览文件 @
18c3934d
...
@@ -56,11 +56,12 @@ class FPN(nn.Module):
...
@@ -56,11 +56,12 @@ class FPN(nn.Module):
):
):
if
not
inner_block
:
if
not
inner_block
:
continue
continue
inner_top_down
=
F
.
interpolate
(
last_inner
,
scale_factor
=
2
,
mode
=
"nearest"
)
#
inner_top_down = F.interpolate(last_inner, scale_factor=2, mode="nearest")
inner_lateral
=
getattr
(
self
,
inner_block
)(
feature
)
inner_lateral
=
getattr
(
self
,
inner_block
)(
feature
)
# TODO use size instead of scale to make it robust to different sizes
# TODO use size instead of scale to make it robust to different sizes
# inner_top_down = F.upsample(last_inner, size=inner_lateral.shape[-2:],
inner_top_down
=
F
.
upsample
(
# mode='bilinear', align_corners=False)
last_inner
,
size
=
(
int
(
inner_lateral
.
shape
[
-
2
])
+
1
-
1
,
int
(
inner_lateral
.
shape
[
-
1
])),
mode
=
'nearest'
)
last_inner
=
inner_lateral
+
inner_top_down
last_inner
=
inner_lateral
+
inner_top_down
results
.
insert
(
0
,
getattr
(
self
,
layer_block
)(
last_inner
))
results
.
insert
(
0
,
getattr
(
self
,
layer_block
)(
last_inner
))
...
...
fcos_core/modeling/rpn/fcos/inference.py
浏览文件 @
18c3934d
...
@@ -9,6 +9,7 @@ from fcos_core.structures.bounding_box import BoxList
...
@@ -9,6 +9,7 @@ from fcos_core.structures.bounding_box import BoxList
from
fcos_core.structures.boxlist_ops
import
cat_boxlist
from
fcos_core.structures.boxlist_ops
import
cat_boxlist
from
fcos_core.structures.boxlist_ops
import
boxlist_ml_nms
from
fcos_core.structures.boxlist_ops
import
boxlist_ml_nms
from
fcos_core.structures.boxlist_ops
import
remove_small_boxes
from
fcos_core.structures.boxlist_ops
import
remove_small_boxes
from
torchvision.ops.boxes
import
batched_nms
class
FCOSPostProcessor
(
torch
.
nn
.
Module
):
class
FCOSPostProcessor
(
torch
.
nn
.
Module
):
...
@@ -147,7 +148,13 @@ class FCOSPostProcessor(torch.nn.Module):
...
@@ -147,7 +148,13 @@ class FCOSPostProcessor(torch.nn.Module):
results
=
[]
results
=
[]
for
i
in
range
(
num_images
):
for
i
in
range
(
num_images
):
# multiclass nms
# multiclass nms
result
=
boxlist_ml_nms
(
boxlists
[
i
],
self
.
nms_thresh
)
keep
=
batched_nms
(
boxlists
[
i
].
bbox
,
boxlists
[
i
].
get_field
(
"scores"
),
boxlists
[
i
].
get_field
(
"labels"
),
self
.
nms_thresh
)
result
=
boxlists
[
i
][
keep
]
number_of_detections
=
len
(
result
)
number_of_detections
=
len
(
result
)
# Limit to max_per_image detections **over all classes**
# Limit to max_per_image detections **over all classes**
...
...
tools/test_fcos_onnx_model.py
浏览文件 @
18c3934d
...
@@ -21,6 +21,7 @@ from fcos_core.utils.miscellaneous import mkdir
...
@@ -21,6 +21,7 @@ from fcos_core.utils.miscellaneous import mkdir
from
fcos_core.modeling.rpn.fcos.inference
import
make_fcos_postprocessor
from
fcos_core.modeling.rpn.fcos.inference
import
make_fcos_postprocessor
import
caffe2.python.onnx.backend
as
backend
import
caffe2.python.onnx.backend
as
backend
import
numpy
as
np
import
numpy
as
np
from
fcos_core.structures.image_list
import
to_image_list
class
ONNX_FCOS
(
nn
.
Module
):
class
ONNX_FCOS
(
nn
.
Module
):
...
@@ -37,9 +38,10 @@ class ONNX_FCOS(nn.Module):
...
@@ -37,9 +38,10 @@ class ONNX_FCOS(nn.Module):
def
forward
(
self
,
images
):
def
forward
(
self
,
images
):
outputs
=
self
.
onnx_model
.
run
(
images
.
tensors
.
cpu
().
numpy
())
outputs
=
self
.
onnx_model
.
run
(
images
.
tensors
.
cpu
().
numpy
())
outputs
=
[
torch
.
from_numpy
(
o
).
to
(
self
.
cfg
.
MODEL
.
DEVICE
)
for
o
in
outputs
]
outputs
=
[
torch
.
from_numpy
(
o
).
to
(
self
.
cfg
.
MODEL
.
DEVICE
)
for
o
in
outputs
]
logits
=
outputs
[::
3
]
num_outputs
=
len
(
outputs
)
//
3
bbox_reg
=
outputs
[
1
::
3
]
logits
=
outputs
[:
num_outputs
]
centerness
=
outputs
[
2
::
3
]
bbox_reg
=
outputs
[
num_outputs
:
2
*
num_outputs
]
centerness
=
outputs
[
2
*
num_outputs
:]
locations
=
self
.
compute_locations
(
logits
)
locations
=
self
.
compute_locations
(
logits
)
boxes
=
self
.
postprocessing
(
locations
,
logits
,
bbox_reg
,
centerness
,
images
.
image_sizes
)
boxes
=
self
.
postprocessing
(
locations
,
logits
,
bbox_reg
,
centerness
,
images
.
image_sizes
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录