Spaces:
Sleeping
Sleeping
File size: 571 Bytes
cfdcae4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import torch
import torch.nn as nn
import torch.optim as optim
import torchvision.transforms as transforms
from torchvision import models
from PIL import Image
import os
import random
class ResNet50(nn.Module):
def __init__(self):
super(ResNet50, self).__init__()
self.resnet = models.resnet50(pretrained=True)
for param in self.resnet.parameters():
param.requires_grad = False
self.resnet.fc = nn.Sequential(
nn.Linear(2048, 2)
)
def forward(self, x):
x = self.resnet(x)
return x |