Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
Models
提交
70c98b36
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看板
未验证
提交
70c98b36
编写于
7月 15, 2020
作者:
J
Jianfeng Wang
提交者:
GitHub
7月 15, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(detection): support models with res101 backbone (#48)
上级
8940da38
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
106 addition
and
21 deletion
+106
-21
README.md
README.md
+8
-7
hubconf.py
hubconf.py
+2
-0
official/vision/detection/README.md
official/vision/detection/README.md
+3
-1
official/vision/detection/configs/__init__.py
official/vision/detection/configs/__init__.py
+2
-0
official/vision/detection/configs/faster_rcnn_res101_coco_2x_800size.py
...n/detection/configs/faster_rcnn_res101_coco_2x_800size.py
+40
-0
official/vision/detection/configs/retinanet_res101_coco_2x_800size.py
...ion/detection/configs/retinanet_res101_coco_2x_800size.py
+40
-0
official/vision/detection/tools/inference.py
official/vision/detection/tools/inference.py
+3
-1
official/vision/detection/tools/test.py
official/vision/detection/tools/test.py
+8
-12
未找到文件。
README.md
浏览文件 @
70c98b36
...
...
@@ -70,16 +70,18 @@ export PYTHONPATH=/path/to/models:$PYTHONPATH
| ShuffleNetV2 x1.5 | 72.806 | 90.792 |
| ShuffleNetV2 x2.0 | 75.074 | 92.278 |
### 目标检测
目标检测同样是计算机视觉中的常见任务,我们提供了两个经典的目标检测模型
[
Retinanet
](
./official/vision/detection/model/retinanet
)
和
[
Faster R-CNN
](
./official/vision/detection/model/faster_rcnn
)
,这两个模型在
**COCO验证集**
上的测试结果如下:
| 模型 | mAP
<br>
@5-95 |
| :---: | :---: |
| retinanet-res50-1x-800size | 36.4 |
| faster-rcnn-res50-1x-800size | 38.8 |
| 模型 | mAP
<br>
@5-95 |
| :---: | :---: |
| retinanet-res50-coco-1x-800size | 36.4 |
| retinanet-res50-coco-1x-800size-syncbn | 37.1 |
| retinanet-res101-coco-2x-800size | 40.8 |
| faster-rcnn-res50-coco-1x-800size | 38.8 |
| faster-rcnn-res50-coco-1x-800size-syncbn | 39.3 |
| faster-rcnn-res101-coco-2x-800size | 43.0 |
### 图像分割
...
...
@@ -117,7 +119,6 @@ export PYTHONPATH=/path/to/models:$PYTHONPATH
| chinese_L-12_H-768_A-12|
[
link
](
https://data.megengine.org.cn/models/weights/bert/chinese_L-12_H-768_A-12/vocab.txt
)
|
[
link
](
https://data.megengine.org.cn/models/weights/bert/chinese_L-12_H-768_A-12/bert_config.json
)
| multi_cased_L-12_H-768_A-12|
[
link
](
https://data.megengine.org.cn/models/weights/bert/multi_cased_L-12_H-768_A-12/vocab.txt
)
|
[
link
](
https://data.megengine.org.cn/models/weights/bert/multi_cased_L-12_H-768_A-12/bert_config.json
)
在glue_data/MRPC数据集中使用默认的超参数进行微调和评估,评估结果介于84%和88%之间。
| Dataset | pretrained_bert | acc |
...
...
hubconf.py
浏览文件 @
70c98b36
...
...
@@ -30,8 +30,10 @@ from official.vision.classification.shufflenet.model import (
from
official.vision.detection.configs
import
(
faster_rcnn_res50_coco_1x_800size
,
faster_rcnn_res50_coco_1x_800size_syncbn
,
faster_rcnn_res101_coco_2x_800size
,
retinanet_res50_coco_1x_800size
,
retinanet_res50_coco_1x_800size_syncbn
,
retinanet_res101_coco_2x_800size
,
)
from
official.vision.detection.models
import
FasterRCNN
,
RetinaNet
from
official.vision.detection.tools.utils
import
DetEvaluator
...
...
official/vision/detection/README.md
浏览文件 @
70c98b36
...
...
@@ -10,10 +10,12 @@
| --- | :---: | :---: | :---: | :---: |
| retinanet-res50-coco-1x-800size | 36.4 | 2 | 2080Ti | 3.1(it/s) |
| retinanet-res50-coco-1x-800size-syncbn | 37.1 | 2 | 2080Ti | 1.7(it/s) |
| retinanet-res101-coco-2x-800size | 40.8 | 2 | 2080Ti | 2.1(it/s) |
| faster-rcnn-res50-coco-1x-800size | 38.8 | 2 | 2080Ti | 3.3(it/s) |
| faster-rcnn-res50-coco-1x-800size-syncbn | 39.3 | 2 | 2080Ti | 1.8(it/s) |
| faster-rcnn-res101-coco-2x-800size | 43.0 | 2 | 2080Ti | 2.3(it/s) |
*
MegEngine v0.
4.0
*
MegEngine v0.
5.1
## 如何使用
...
...
official/vision/detection/configs/__init__.py
浏览文件 @
70c98b36
from
.faster_rcnn_res50_coco_1x_800size
import
faster_rcnn_res50_coco_1x_800size
from
.faster_rcnn_res50_coco_1x_800size_syncbn
import
faster_rcnn_res50_coco_1x_800size_syncbn
from
.faster_rcnn_res101_coco_2x_800size
import
faster_rcnn_res101_coco_2x_800size
from
.retinanet_res50_coco_1x_800size
import
retinanet_res50_coco_1x_800size
from
.retinanet_res50_coco_1x_800size_syncbn
import
retinanet_res50_coco_1x_800size_syncbn
from
.retinanet_res101_coco_2x_800size
import
retinanet_res101_coco_2x_800size
_EXCLUDE
=
{}
__all__
=
[
k
for
k
in
globals
().
keys
()
if
k
not
in
_EXCLUDE
and
not
k
.
startswith
(
"_"
)]
official/vision/detection/configs/faster_rcnn_res101_coco_2x_800size.py
0 → 100644
浏览文件 @
70c98b36
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
from
megengine
import
hub
from
official.vision.detection
import
models
class
CustomFasterRCNNConfig
(
models
.
FasterRCNNConfig
):
def
__init__
(
self
):
super
().
__init__
()
self
.
backbone
=
"resnet101"
# ------------------------ training cfg ---------------------- #
self
.
max_epoch
=
36
self
.
lr_decay_stages
=
[
24
,
32
,
34
]
@
hub
.
pretrained
(
"https://data.megengine.org.cn/models/weights/"
"faster_rcnn_res101_coco_2x_800size_43dot0_ee249359.pkl"
)
def
faster_rcnn_res101_coco_2x_800size
(
batch_size
=
1
,
**
kwargs
):
r
"""
Faster-RCNN FPN trained from COCO dataset.
`"Faster-RCNN" <https://arxiv.org/abs/1506.01497>`_
`"FPN" <https://arxiv.org/abs/1612.03144>`_
`"COCO" <https://arxiv.org/abs/1405.0312>`_
"""
return
models
.
FasterRCNN
(
CustomFasterRCNNConfig
(),
batch_size
=
batch_size
,
**
kwargs
)
Net
=
models
.
FasterRCNN
Cfg
=
CustomFasterRCNNConfig
official/vision/detection/configs/retinanet_res101_coco_2x_800size.py
0 → 100644
浏览文件 @
70c98b36
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
from
megengine
import
hub
from
official.vision.detection
import
models
class
CustomRetinaNetConfig
(
models
.
RetinaNetConfig
):
def
__init__
(
self
):
super
().
__init__
()
self
.
backbone
=
"resnet101"
# ------------------------ training cfg ---------------------- #
self
.
max_epoch
=
36
self
.
lr_decay_stages
=
[
24
,
32
,
34
]
@
hub
.
pretrained
(
"https://data.megengine.org.cn/models/weights/"
"retinanet_res101_coco_2x_800size_40dot8_661c3608.pkl"
)
def
retinanet_res101_coco_2x_800size
(
batch_size
=
1
,
**
kwargs
):
r
"""
RetinaNet trained from COCO dataset.
`"RetinaNet" <https://arxiv.org/abs/1708.02002>`_
`"FPN" <https://arxiv.org/abs/1612.03144>`_
`"COCO" <https://arxiv.org/abs/1405.0312>`_
"""
return
models
.
RetinaNet
(
CustomRetinaNetConfig
(),
batch_size
=
batch_size
,
**
kwargs
)
Net
=
models
.
RetinaNet
Cfg
=
CustomRetinaNetConfig
official/vision/detection/tools/inference.py
浏览文件 @
70c98b36
...
...
@@ -48,7 +48,9 @@ def main():
sys
.
path
.
insert
(
0
,
os
.
path
.
dirname
(
args
.
file
))
current_network
=
importlib
.
import_module
(
os
.
path
.
basename
(
args
.
file
).
split
(
"."
)[
0
])
model
=
current_network
.
Net
(
current_network
.
Cfg
(),
batch_size
=
1
)
cfg
=
current_network
.
Cfg
()
cfg
.
backbone_pretrained
=
False
model
=
current_network
.
Net
(
cfg
,
batch_size
=
1
)
model
.
eval
()
state_dict
=
mge
.
load
(
args
.
weight_file
)
if
"state_dict"
in
state_dict
:
...
...
official/vision/detection/tools/test.py
浏览文件 @
70c98b36
...
...
@@ -37,9 +37,6 @@ def make_parser():
parser
.
add_argument
(
"-n"
,
"--ngpus"
,
default
=
1
,
type
=
int
,
help
=
"total number of gpus for testing"
,
)
parser
.
add_argument
(
"-b"
,
"--batch_size"
,
default
=
1
,
type
=
int
,
help
=
"batchsize for testing"
,
)
parser
.
add_argument
(
"-d"
,
"--dataset_dir"
,
default
=
"/data/datasets"
,
type
=
str
,
)
...
...
@@ -56,6 +53,9 @@ def main():
parser
=
make_parser
()
args
=
parser
.
parse_args
()
sys
.
path
.
insert
(
0
,
os
.
path
.
dirname
(
args
.
file
))
current_network
=
importlib
.
import_module
(
os
.
path
.
basename
(
args
.
file
).
split
(
"."
)[
0
])
if
args
.
end_epoch
==
-
1
:
args
.
end_epoch
=
args
.
start_epoch
...
...
@@ -75,7 +75,7 @@ def main():
proc
=
Process
(
target
=
worker
,
args
=
(
args
.
file
,
current_network
,
model_file
,
args
.
dataset_dir
,
i
,
...
...
@@ -86,10 +86,6 @@ def main():
proc
.
start
()
procs
.
append
(
proc
)
sys
.
path
.
insert
(
0
,
os
.
path
.
dirname
(
args
.
file
))
current_network
=
importlib
.
import_module
(
os
.
path
.
basename
(
args
.
file
).
split
(
"."
)[
0
]
)
cfg
=
current_network
.
Cfg
()
num_imgs
=
dict
(
coco
=
5000
,
objects365
=
30000
)
...
...
@@ -139,7 +135,7 @@ def main():
def
worker
(
net_file
,
model_file
,
data_dir
,
worker_id
,
total_worker
,
result_queue
,
current_network
,
model_file
,
data_dir
,
worker_id
,
total_worker
,
result_queue
,
):
"""
:param net_file: network description file
...
...
@@ -156,9 +152,9 @@ def worker(
pred
=
model
(
model
.
inputs
)
return
pred
sys
.
path
.
insert
(
0
,
os
.
path
.
dirname
(
net_file
)
)
c
urrent_network
=
importlib
.
import_module
(
os
.
path
.
basename
(
net_file
).
split
(
"."
)[
0
])
model
=
current_network
.
Net
(
c
urrent_network
.
Cfg
()
,
batch_size
=
1
)
cfg
=
current_network
.
Cfg
(
)
c
fg
.
backbone_pretrained
=
False
model
=
current_network
.
Net
(
c
fg
,
batch_size
=
1
)
model
.
eval
()
evaluator
=
DetEvaluator
(
model
)
state_dict
=
mge
.
load
(
model_file
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录