diff --git a/.gitignore b/.gitignore
index 78dab759a0ae634fdb6817cbbeb57baddffa11a1..f1339d86a12490b114114bff72c465b3d4884182 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
__pycache__/
*log*/
*.so
+*.pkl
diff --git a/README.md b/README.md
index 0cd889e85e9816f1d698bf3fb3622c7f11cc0da6..b4cc66185b9dd45243661ce0a8d89ec2095bf745 100644
--- a/README.md
+++ b/README.md
@@ -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 |
### 图像分割
diff --git a/hubconf.py b/hubconf.py
index 588552d87753b4db1225892eeeb9106e5a38651a..a932bef4d00004ecc9d3b4cd60cbea7791870af1 100644
--- a/hubconf.py
+++ b/hubconf.py
@@ -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
diff --git a/official/vision/detection/README.md b/official/vision/detection/README.md
index f9bf699b7d9a837ba65227e2c4279286ff526bed..4fea8c3b9ec55e140b93dc978479b2f20901f529 100644
--- a/official/vision/detection/README.md
+++ b/official/vision/detection/README.md
@@ -6,14 +6,16 @@
网络的性能在COCO2017数据集上的测试结果如下:
-| 模型 | mAP
@5-95 | batch
/gpu | gpu | trainging speed
(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
@5-95 | batch
/gpu | gpu | trainging speed
(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
diff --git a/official/vision/detection/configs/__init__.py b/official/vision/detection/configs/__init__.py
index 9eadf38e8cbbde333866aa153d69e8495598526b..2abd428a8c0e75cb74a83219dafd82cc6e493f21 100644
--- a/official/vision/detection/configs/__init__.py
+++ b/official/vision/detection/configs/__init__.py
@@ -1,9 +1,11 @@
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("_")]
diff --git a/official/vision/detection/configs/faster_rcnn_resx101_coco_2x_800size.py b/official/vision/detection/configs/faster_rcnn_resx101_coco_2x_800size.py
new file mode 100644
index 0000000000000000000000000000000000000000..974d2f0d8bba8f2b614da8f5c61c49588d4f8863
--- /dev/null
+++ b/official/vision/detection/configs/faster_rcnn_resx101_coco_2x_800size.py
@@ -0,0 +1,40 @@
+# -*- 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" `_
+ `"FPN" `_
+ `"COCO" `_
+ """
+ return models.FasterRCNN(CustomFasterRCNNConfig(), batch_size=batch_size, **kwargs)
+
+
+Net = models.FasterRCNN
+Cfg = CustomFasterRCNNConfig
diff --git a/official/vision/detection/configs/retinanet_resx101_coco_2x_800size.py b/official/vision/detection/configs/retinanet_resx101_coco_2x_800size.py
new file mode 100644
index 0000000000000000000000000000000000000000..38c53169f32076a50a4395e3ef734e352835f414
--- /dev/null
+++ b/official/vision/detection/configs/retinanet_resx101_coco_2x_800size.py
@@ -0,0 +1,40 @@
+# -*- 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" `_
+ `"FPN" `_
+ `"COCO" `_
+ """
+ return models.RetinaNet(CustomRetinaNetConfig(), batch_size=batch_size, **kwargs)
+
+
+Net = models.RetinaNet
+Cfg = CustomRetinaNetConfig
diff --git a/official/vision/detection/layers/det/fpn.py b/official/vision/detection/layers/det/fpn.py
index eaebf0c5ba3a382c10640135a234385dc85c1c90..5ec310c4e62c02401b7550522359470c734f2d25 100644
--- a/official/vision/detection/layers/det/fpn.py
+++ b/official/vision/detection/layers/det/fpn.py
@@ -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):
diff --git a/official/vision/detection/tools/inference.py b/official/vision/detection/tools/inference.py
index d91cbd55ddde56141f4e726a6b890575321d4e54..01298c7983b1658bc701a64809d32bce2aa4ccc6 100644
--- a/official/vision/detection/tools/inference.py
+++ b/official/vision/detection/tools/inference.py
@@ -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)