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

运行summary时出现了报错 #53

Open
Vision-LYF opened this issue Apr 7, 2023 · 2 comments
Open

运行summary时出现了报错 #53

Vision-LYF opened this issue Apr 7, 2023 · 2 comments

Comments

@Vision-LYF
Copy link

import torch
from thop import clever_format, profile
from torchsummary import summary

from nets.yolo import YoloBody

if name == "main":
input_shape = [416, 416]
anchors_mask = [[6, 7, 8], [3, 4, 5], [0, 1, 2]]
num_classes = 80
backbone = 'mobilenetv1'

device  = torch.device("cuda" if torch.cuda.is_available() else "cpu")
m       = YoloBody(anchors_mask, num_classes, backbone=backbone).to(device)
summary(m, (3, input_shape[0], input_shape[1]))

# mobilenetv1-yolov4 40,952,893
# mobilenetv2-yolov4 39,062,013
# mobilenetv3-yolov4 39,989,933

# 修改了panet的mobilenetv1-yolov4 12,692,029
# 修改了panet的mobilenetv2-yolov4 10,801,149
# 修改了panet的mobilenetv3-yolov4 11,729,069

dummy_input     = torch.randn(1, 3, input_shape[0], input_shape[1]).to(device)
flops, params   = profile(m.to(device), (dummy_input, ), verbose=False)

flops           = flops * 2
flops, params   = clever_format([flops, params], "%.3f")
print('Total GFLOPS: %s' % (flops))
print('Total params: %s' % (params))

我在运行以上程序时出现了以下错误:Traceback (most recent call last):
File "E:\PycharmProjects\mobilenet-yolov4-pytorch-main\mobilenet-yolov4-pytorch-main\summary.py", line 8, in
from nets.yolo import YoloBody
File "E:\PycharmProjects\mobilenet-yolov4-pytorch-main\mobilenet-yolov4-pytorch-main\nets\yolo.py", line 7, in
from .densenet import _Transition, densenet121, densenet169, densenet201
File "E:\PycharmProjects\mobilenet-yolov4-pytorch-main\mobilenet-yolov4-pytorch-main\nets\densenet.py", line 8, in
from torchvision.models.utils import load_state_dict_from_url
ModuleNotFoundError: No module named 'torchvision.models.utils'

@bubbliiiing
Copy link
Owner

额,你改成torch.hub

@Vision-LYF
Copy link
Author

谢谢导儿

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