resnet100 / inference.py
Warlord-K's picture
Upload folder using huggingface_hub
968b459 verified
raw
history blame
407 Bytes
from resnet import get_model
import torch
from PIL import Image
from torchvision.transforms.functional import pil_to_tensor
model = get_model("r100", dropout=0.0, fp16=True, num_features=512).cuda()
model.load_state_dict(torch.load("model.pt"))
model.eval()
img = pil_to_tensor(Image.open("test.jpg").resize((112,112))).permute(0, 1, 2).to("cuda", torch.float16).unsqueeze(dim = 0)
embeddings = model(img)