Spaces:
Sleeping
Sleeping
| import torch | |
| from torchvision import models | |
| from torch import nn | |
| def create_effnetb2(num_classes:int = 101, seed:int = 42): | |
| torch.manual_seed(seed) | |
| weights = models.EfficientNet_B2_Weights.DEFAULT | |
| model = models.efficientnet_b2(weights=weights) | |
| transform = weights.transforms() | |
| for param in model.parameters(): | |
| param.requires_grad = False | |
| model.classifier = nn.Sequential( | |
| nn.Dropout(p=0.3, inplace=True), | |
| nn.Linear(in_features=1408, out_features=num_classes) | |
| ) | |
| return model, transform | |