melanoma_detect / model.py
shukurullo2004's picture
Upload 9 files
b221e1d verified
raw
history blame
No virus
496 Bytes
import torch
import torchvision
from torch import nn
def create_model():
torch.manual_seed(42)
torch.cuda.manual_seed(42)
weights = torchvision.models.ViT_B_16_Weights.DEFAULT
transform = weights.transforms()
model = torchvision.models.vit_b_16(weights=weights)
# 4. Freeze all layers in base model
for param in model.parameters():
param.requires_grad = False
model.heads = nn.Sequential(
nn.Linear(768,1)
)
return model, transform