Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hub.load导入"retinanet_res50_1x_800size"报错 #35

Closed
davidishere opened this issue Jun 18, 2020 · 10 comments
Closed

hub.load导入"retinanet_res50_1x_800size"报错 #35

davidishere opened this issue Jun 18, 2020 · 10 comments

Comments

@davidishere
Copy link

环境

1.系统环境:Ubuntu 18.04
2.MegEngine版本:0.4.0
3.python版本:3.6.8
4.模型名称:retinanet_res50_1x_800size

复现步骤

请提供关键的代码片段便于追查问题

from megengine import hub
model = hub.load(
"megengine/models",
"retinanet_res50_1x_800size",
pretrained=True,
)

请提供完整的日志及报错信息

Traceback (most recent call last):
File "", line 4, in
File "/usr/local/lib/python3.6/dist-packages/megengine/hub/hub.py", line 202, in load
raise RuntimeError("Cannot find callable {} in hubconf.py".format(entry))
RuntimeError: Cannot find callable retinanet_res50_1x_800size in hubconf.py

@FateScript
Copy link
Collaborator

环境

1.系统环境:Ubuntu 18.04
2.MegEngine版本:0.4.0
3.python版本:3.6.8
4.模型名称:retinanet_res50_1x_800size

复现步骤

请提供关键的代码片段便于追查问题

from megengine import hub
model = hub.load(
"megengine/models",
"retinanet_res50_1x_800size",
pretrained=True,
)

请提供完整的日志及报错信息

Traceback (most recent call last):
File "", line 4, in
File "/usr/local/lib/python3.6/dist-packages/megengine/hub/hub.py", line 202, in load
raise RuntimeError("Cannot find callable {} in hubconf.py".format(entry))
RuntimeError: Cannot find callable retinanet_res50_1x_800size in hubconf.py

看起来是cache没更新的问题,可以使用

model = hub.load(
    "megengine/models", "retinanet_res50_1x_800size",
    pretrained=True, use_cache=False
)

试一下,应该会重新download一份新的retinanet

@davidishere
Copy link
Author

修改后报下面的错误:

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/dist-packages/megengine/hub/hub.py", line 206, in load
module = getattr(hubmodule, entry)(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/megengine/hub/hub.py", line 317, in pretrained_model_func
model = func(**kwargs)
File "/root/.cache/megengine/hub/e093aa62cdf8f313/official/vision/detection/retinanet_res50_coco_1x_800size.py", line 23, in retinanet_res50_coco_1x_800size
return models.RetinaNet(models.RetinaNetConfig(), batch_size=batch_size, **kwargs)
File "/root/.cache/megengine/hub/e093aa62cdf8f313/official/vision/detection/models/retinanet.py", line 39, in init
bottom_up = resnet50(norm=layers.get_norm(self.cfg.resnet_norm))
File "/root/.cache/megengine/hub/e093aa62cdf8f313/official/vision/detection/layers/basic/norm.py", line 71, in get_norm
"SyncBN": M.SyncBatchNorm,
AttributeError: module 'megengine.module' has no attribute 'SyncBatchNorm'

@FateScript
Copy link
Collaborator

修改后报下面的错误:

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/dist-packages/megengine/hub/hub.py", line 206, in load
module = getattr(hubmodule, entry)(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/megengine/hub/hub.py", line 317, in pretrained_model_func
model = func(**kwargs)
File "/root/.cache/megengine/hub/e093aa62cdf8f313/official/vision/detection/retinanet_res50_coco_1x_800size.py", line 23, in retinanet_res50_coco_1x_800size
return models.RetinaNet(models.RetinaNetConfig(), batch_size=batch_size, **kwargs)
File "/root/.cache/megengine/hub/e093aa62cdf8f313/official/vision/detection/models/retinanet.py", line 39, in init
bottom_up = resnet50(norm=layers.get_norm(self.cfg.resnet_norm))
File "/root/.cache/megengine/hub/e093aa62cdf8f313/official/vision/detection/layers/basic/norm.py", line 71, in get_norm
"SyncBN": M.SyncBatchNorm,
AttributeError: module 'megengine.module' has no attribute 'SyncBatchNorm'

哦哦,这个是0.5.0里面即将发布的Sync bn,目前0.4.0还不支持,可以把这一行注释掉

@davidishere
Copy link
Author

davidishere commented Jun 18, 2020

您好,我看了retinanet的配置,并没有用Sync bn
class RetinaNetConfig:
def init(self):
self.resnet_norm = "FrozenBN"
self.backbone_freeze_at = 2

retinanet_res50_coco_1x_800size.py

from megengine import hub

from official.vision.detection import models

@hub.pretrained(
"https://data.megengine.org.cn/models/weights/"
"retinanet_d3f58dce_res50_1x_800size_36dot0.pkl"
)
def retinanet_res50_coco_1x_800size(batch_size=1, **kwargs):
r"""
RetinaNet trained from COCO dataset.
"RetinaNet" <https://arxiv.org/abs/1708.02002>_
"""
return models.RetinaNet(models.RetinaNetConfig(), batch_size=batch_size, **kwargs)

Net = models.RetinaNet
Cfg = models.RetinaNetConfig

并没有调用retinanet_res50_coco_1x_800size_syncbn.py

@FateScript
Copy link
Collaborator

您好,我看了retinanet的配置,并没有用Sync bn
class RetinaNetConfig:
def init(self):
self.resnet_norm = "FrozenBN"
self.backbone_freeze_at = 2

retinanet_res50_coco_1x_800size.py

from megengine import hub

from official.vision.detection import models

@hub.pretrained(
"https://data.megengine.org.cn/models/weights/"
"retinanet_d3f58dce_res50_1x_800size_36dot0.pkl"
)
def retinanet_res50_coco_1x_800size(batch_size=1, **kwargs):
r"""
RetinaNet trained from COCO dataset.
"RetinaNet" <https://arxiv.org/abs/1708.02002>_
"""
return models.RetinaNet(models.RetinaNetConfig(), batch_size=batch_size, **kwargs)

Net = models.RetinaNet
Cfg = models.RetinaNetConfig

并没有调用retinanet_res50_coco_1x_800size_syncbn.py

没有使用sync bn的原因是相关的模型还在训练中,另外模型提交到hub也需要一定时间

@davidishere
Copy link
Author

那是不是现在retinanet模型的预训练权重还无法使用?需要自己重新训练

@FateScript
Copy link
Collaborator

那是不是现在retinanet模型的预训练权重还无法使用?需要自己重新训练

可以使用啊,只不过是sync bn的功能不支持而已,正常RetinaNet使用的是Frozen BN

@davidishere
Copy link
Author

您好,现在的代码中就是使用的Frozen BN,不知道为什么说用了sync bn,您可以试一下看看是不是有问题?

@FateScript
Copy link
Collaborator

您好,现在的代码中就是使用的Frozen BN,不知道为什么说用了sync bn,您可以试一下看看是不是有问题?

您好,这个地方多了一个SyncBn,而现在0.4.0版本的MegEngine并不支持,我的意思是注释掉这一行你就可以正常使用RetinaNet了,您可以试一下

@davidishere
Copy link
Author

OK,谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants