From d67b5efe43b909b565347b1b804aba603449046e Mon Sep 17 00:00:00 2001 From: Yizhuang Zhou Date: Tue, 24 Mar 2020 19:35:24 +0800 Subject: [PATCH] update pretrained models & fix pycocotools 1. add pretrained resnet152, snetv2_0.5x, 1.5x and 2.0x 2. move `import pycocotools` inside `main` to prevernt import error --- README.md | 6 +++++- official/vision/classification/resnet/README.md | 1 + official/vision/classification/resnet/model.py | 3 +++ official/vision/classification/shufflenet/README.md | 5 ++++- official/vision/classification/shufflenet/model.py | 9 +++++++++ official/vision/detection/tools/test.py | 5 +++-- 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ac8a18d..460bad5 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,12 @@ export PYTHONPATH=/path/to/models:$PYTHONPATH | ResNet34 | 73.960 | 91.630 | | ResNet50 | 76.254 | 93.056 | | ResNet101 | 77.944 | 93.844 | +| ResNet152 | 78.582 | 94.130 | | ResNeXt50 32x4d | 77.592 | 93.644 | -| ShuffleNetV2 x1.0 | 69.369 | 88.793 | +| ShuffleNetV2 x0.5 | 60.696 | 82.190 | +| ShuffleNetV2 x1.0 | 69.372 | 88.764 | +| ShuffleNetV2 x1.5 | 72.806 | 90.792 | +| ShuffleNetV2 x2.0 | 75.074 | 92.278 | ### 目标检测 diff --git a/official/vision/classification/resnet/README.md b/official/vision/classification/resnet/README.md index c00e575..c418db1 100644 --- a/official/vision/classification/resnet/README.md +++ b/official/vision/classification/resnet/README.md @@ -12,6 +12,7 @@ | ResNet34 | 73.960 | 91.630 | | ResNet50 | 76.254 | 93.056 | | ResNet101 | 77.944 | 93.844 | +| ResNet152 | 78.582 | 94.130 | | ResNeXt50 32x4d | 77.592 | 93.644 | 用户可以通过`megengine.hub`直接加载本目录下定义好的模型,例如: diff --git a/official/vision/classification/resnet/model.py b/official/vision/classification/resnet/model.py index 0022bcd..8321082 100644 --- a/official/vision/classification/resnet/model.py +++ b/official/vision/classification/resnet/model.py @@ -341,6 +341,9 @@ def resnet101(**kwargs): return ResNet(Bottleneck, [3, 4, 23, 3], **kwargs) +@hub.pretrained( + "https://data.megengine.org.cn/models/weights/resnet152_fbaug_78582_7551aff3.pkl" +) def resnet152(**kwargs): r"""ResNet-152 model from `"Deep Residual Learning for Image Recognition" `_ diff --git a/official/vision/classification/shufflenet/README.md b/official/vision/classification/shufflenet/README.md index f132137..e60648e 100644 --- a/official/vision/classification/shufflenet/README.md +++ b/official/vision/classification/shufflenet/README.md @@ -8,7 +8,10 @@ | 模型 | top1 acc | top5 acc | | --- | --- | --- | -| shufflenet_v2_x1_0 | 69.369 | 88.793 | +| ShuffleNetV2 x0.5 | 60.696 | 82.190 | +| ShuffleNetV2 x1.0 | 69.372 | 88.764 | +| ShuffleNetV2 x1.5 | 72.806 | 90.792 | +| ShuffleNetV2 x2.0 | 75.074 | 92.278 | 用户可以通过`megengine.hub`直接加载本目录下定义好的模型,例如: diff --git a/official/vision/classification/shufflenet/model.py b/official/vision/classification/shufflenet/model.py index 096a6a6..fcd6545 100644 --- a/official/vision/classification/shufflenet/model.py +++ b/official/vision/classification/shufflenet/model.py @@ -216,10 +216,16 @@ class ShuffleNetV2(M.Module): M.init.fill_(m.bias, 0) +@hub.pretrained( + "https://data.megengine.org.cn/models/weights/snetv2_x2_0_75115_497d4601.pkl" +) def shufflenet_v2_x2_0(num_classes=1000): return ShuffleNetV2(num_classes=num_classes, model_size="2.0x") +@hub.pretrained( + "https://data.megengine.org.cn/models/weights/snetv2_x1_5_72775_38ac4273.pkl" +) def shufflenet_v2_x1_5(num_classes=1000): return ShuffleNetV2(num_classes=num_classes, model_size="1.5x") @@ -231,5 +237,8 @@ def shufflenet_v2_x1_0(num_classes=1000): return ShuffleNetV2(num_classes=num_classes, model_size="1.0x") +@hub.pretrained( + "https://data.megengine.org.cn/models/weights/snetv2_x0_5_60750_c28db1a2.pkl" +) def shufflenet_v2_x0_5(num_classes=1000): return ShuffleNetV2(num_classes=num_classes, model_size="0.5x") diff --git a/official/vision/detection/tools/test.py b/official/vision/detection/tools/test.py index 0d55fe5..27f30de 100644 --- a/official/vision/detection/tools/test.py +++ b/official/vision/detection/tools/test.py @@ -21,8 +21,6 @@ from megengine import jit from megengine.data import DataLoader, SequentialSampler from megengine.data.dataset import COCO as COCODataset from tqdm import tqdm -from pycocotools.coco import COCO -from pycocotools.cocoeval import COCOeval from official.vision.detection.tools.nms import py_cpu_nms @@ -272,6 +270,9 @@ def make_parser(): def main(): + from pycocotools.coco import COCO + from pycocotools.cocoeval import COCOeval + parser = make_parser() args = parser.parse_args() -- GitLab