torchvision官网的分类模型 <no title> — Torchvision 0.20 documentation
训练和预测时,改成自己的分类数
# model = models.resnet50(weights=models.ResNet50_Weights.IMAGENET1K_V2) #加载模型。会自动下载模型 # model = models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1) # model = models.regnet_y_400mf(weights=models.RegNet_Y_400MF_Weights.IMAGENET1K_V2) # model = models.efficientnet_v2_s(weights = models.EfficientNet_V2_S_Weights.IMAGENET1K_V1) # model = models.shufflenet_v2_x2_0(weights = models.ShuffleNet_V2_X2_0_Weights.IMAGENET1K_V1) # model = models.convnext_tiny(weights=models.ConvNeXt_Tiny_Weights.IMAGENET1K_V1) # model = models.densenet121(weights=models.DenseNet121_Weights.IMAGENET1K_V1) # model = models.googlenet(weights=models.GoogLeNet_Weights.IMAGENET1K_V1) # model = models.maxvit_t(weights=models.MaxVit_T_Weights.IMAGENET1K_V1) # model = models.swin_v2_t(weights=models.Swin_V2_T_Weights.IMAGENET1K_V1) # model = models.mnasnet0_5(weights=models.MNASNet0_5_Weights.IMAGENET1K_V1) # model = models.mobilenet_v3_small(weights=models.MobileNet_V3_Small_Weights.IMAGENET1K_V1) # model = models.resnext50_32x4d(weights=models.ResNeXt50_32X4D_Weights.IMAGENET1K_V2) model = models.wide_resnet50_2(weights=models.Wide_ResNet50_2_Weights.IMAGENET1K_V2) # 为了适应自己的数据集,将最后一层修改下 model.fc = nn.Linear(model.fc.in_features, classes) # 用于googlenet # model.classifier[1] = nn.Linear(model.classifier[1].in_features, classes) # 用于efficientnet # model.classifier[2] = nn.Linear(model.classifier[2].in_features, classes) # 用于convnext # model.classifier=nn.Linear(model.classifier.in_features,classes) #用于densenet121 # model.classifier[5] = nn.Linear(model.classifier[5].in_features, classes) # maxvit_t # model.head = nn.Linear(model.head.in_features,classes) #swin_v2_t # model.classifier[1] = nn.Linear(model.classifier[1].in_features, classes) #mnasnet0_5 # model.classifier[3] = nn.Linear(model.classifier[3].in_features, classes) #mobilenet_v3_small
各个系列中,预测速度最快的是Resnet18
标签:IMAGENET1K,models,模型,分类,汇总,Weights,weights,model,classifier From: https://www.cnblogs.com/xixixing/p/18516315