Spaces:
Sleeping
Sleeping
File size: 505 Bytes
f170aa7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import torch
import torchvision
from torch import nn
def create_efficientnet(output_shape: int):
weights = torchvision.models.EfficientNet_V2_L_Weights.IMAGENET1K_V1.DEFAULT
model = torchvision.models.efficientnet_v2_l(weights=weights)
for param in model.parameters():
param.requires_grad = False
model.classifier = nn.Sequential(
nn.Dropout(p=0.10, inplace=True),
nn.Linear(in_features=1280, out_features=output_shape)
)
return model, weights.transforms()
|