i just want to get the encode of images use pretrained resnet50, Here is my code
from torchvision.models.resnet import resnet50 import torch.nn as nn import torch as t from utils import preprocess def resnet(): net = resnet50(pretrained=True) # delete fc layer del net.fc for param in net.parameters(): param.requires_grad = False # print(net) return net model = resnet() img = preprocess(img_name) # img(tensor) -> [1, 3, 299, 299] encode_img = model(img)
when i run above code, it give me an error like this.
Exception has occurred: AttributeError
‘ResNet’ object has no attribute ‘fc’
how could i solve this problem, if anyone can tell me. I will be very grateful