V1kstrand/FoodClassifier101
0
1import torch2import torchvision3 4from torch import nn5 6def create_effnetb2_model(num_classes:int=3,7 seed:int=42):8 """ Create a effnetb2 feature extractor and transforms """9 weights = torchvision.models.EfficientNet_B2_Weights.DEFAULT10 transforms = weights.transforms()11 model = torchvision.models.efficientnet_b2(weights=weights)12 13 for param in model.parameters():14 param.requires_grad=False15 16 torch.manual_seed(seed)17 model.classifier = nn.Sequential(18 nn.Dropout(p=0.3, inplace=True),19 nn.Linear(in_features=1408, out_features=num_classes, bias=True))20 21 return model, transforms22 