未验证 提交 473ae5d9 编写于 作者: J Jianfeng Wang 提交者: GitHub

fix(detection): fix random features in py3.5 (#52)

* feat(detection): add new models and weights

* fix(detection): fix random features in py3.5
上级 79b64608
__pycache__/
*log*/
*.so
*.pkl
......@@ -79,9 +79,11 @@ export PYTHONPATH=/path/to/models:$PYTHONPATH
| retinanet-res50-coco-1x-800size | 36.4 |
| retinanet-res50-coco-1x-800size-syncbn | 37.1 |
| retinanet-res101-coco-2x-800size | 40.8 |
| retinanet-resx101-coco-2x-800size | 41.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 |
| faster-rcnn-resx101-coco-2x-800size | 44.7 |
### 图像分割
......
......@@ -31,9 +31,11 @@ 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,
faster_rcnn_resx101_coco_2x_800size,
retinanet_res50_coco_1x_800size,
retinanet_res50_coco_1x_800size_syncbn,
retinanet_res101_coco_2x_800size,
retinanet_resx101_coco_2x_800size,
)
from official.vision.detection.models import FasterRCNN, RetinaNet
from official.vision.detection.tools.utils import DetEvaluator
......
......@@ -6,14 +6,16 @@
网络的性能在COCO2017数据集上的测试结果如下:
| 模型 | mAP<br>@5-95 | batch<br>/gpu | gpu | trainging speed<br>(8gpu) |
| --- | :---: | :---: | :---: | :---: |
| 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) |
| 模型 | mAP<br>@5-95 | batch<br>/gpu | gpu | trainging speed<br>(8gpu) |
| --- | :---: | :---: | :---: | :---: |
| 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) |
| retinanet-resx101-coco-2x-800size | 41.8 | 2 | 2080Ti | 0.8(it/s) (enable sublinear) |
| 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) |
| faster-rcnn-resx101-coco-2x-800size | 44.7 | 2 | 2080Ti | 0.9(it/s) (enable sublinear) |
* MegEngine v0.5.1
......
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 .faster_rcnn_resx101_coco_2x_800size import faster_rcnn_resx101_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
from .retinanet_resx101_coco_2x_800size import retinanet_resx101_coco_2x_800size
_EXCLUDE = {}
__all__ = [k for k in globals().keys() if k not in _EXCLUDE and not k.startswith("_")]
# -*- 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 = "resnext101_32x8d"
# ------------------------ training cfg ---------------------- #
self.max_epoch = 36
self.lr_decay_stages = [24, 32, 34]
@hub.pretrained(
"https://data.megengine.org.cn/models/weights/"
"faster_rcnn_resx101_coco_2x_800size_44dot7_d03b05b2.pkl"
)
def faster_rcnn_resx101_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
# -*- 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 = "resnext101_32x8d"
# ------------------------ training cfg ---------------------- #
self.max_epoch = 36
self.lr_decay_stages = [24, 32, 34]
@hub.pretrained(
"https://data.megengine.org.cn/models/weights/"
"retinanet_resx101_coco_2x_800size_41dot8_f92909a1.pkl"
)
def retinanet_resx101_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
......@@ -121,7 +121,7 @@ class FPN(M.Module):
for s in range(stage, stage + self.top_block.num_levels):
self._out_feature_strides["p{}".format(s + 1)] = 2 ** (s + 1)
self._out_features = list(self._out_feature_strides.keys())
self._out_features = list(sorted(self._out_feature_strides.keys()))
self._out_feature_channels = {k: out_channels for k in self._out_features}
def forward(self, x):
......
......@@ -25,13 +25,9 @@ logger = mge.get_logger(__name__)
def make_parser():
parser = argparse.ArgumentParser()
parser.add_argument(
"-f", "--file", default="net.py", type=str, help="net description file"
)
parser.add_argument(
"-w", "--weight_file", default=None, type=str, help="weights file",
)
parser.add_argument("-i", "--image", default="example.jpg", type=str)
parser.add_argument("-f", "--file", type=str, help="net description file")
parser.add_argument("-w", "--weight_file", type=str, help="weights file")
parser.add_argument("-i", "--image", type=str)
return parser
......@@ -39,8 +35,6 @@ def main():
parser = make_parser()
args = parser.parse_args()
logger.info("Load Model : %s completed", args.weight_file)
@jit.trace(symbolic=True)
def val_func():
pred = model(model.inputs)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册