我想提取ResNet101中的特性,但是导入torchvision.models.feature_extraction时遇到了问题。
这是我的代码:
from torchvision import models
from torchvision.models.feature_extractor import create_feature_extractor
res101 = models.resnet101(pretrained=True)
extractor = create_feature_extractor(
res101,
return_nodes=[
"conv1",
"maxpool",
"layer1",
"layer2",
"layer3",
"layer4",
]
)
features = extractor(inputs) 这是一个错误
from torchvision.models.feature_extractor import create_feature_extractor
Traceback (most recent call last):
Input In [11] in <cell line: 1>
from torchvision.models.feature_extractor import create_feature_extractor
ModuleNotFoundError: No module named 'torchvision.models.feature_extractor'发布于 2022-05-28 17:32:55
你可能会尝试使用这样的东西:
from torchvision.models.feature_extraction import create_feature_extractor见extraction vs extractor
发布于 2022-06-06 02:52:02
同样的问题。我使用PyTorch安装了conda,它在木星笔记本中工作得很好。但它在终点站不起作用。
原来pip列出的torchvision版本是0.82。
通过使用torchvision更新pip来解决问题。
也许有些软件包为我安装了旧版本。希望我的经历对你有帮助。
https://stackoverflow.com/questions/72417747
复制相似问题