| import torch | |
| import torchvision.models as models | |
| backbone = models.resnet18(pretrained=True) | |
| backbone.fc = torch.nn.Identity() # strip final FC → 512-d output | |
| backbone.eval() | |
| dummy = torch.randn(1, 3, 224, 224) | |
| with torch.no_grad(): | |
| emb = backbone(dummy) | |
| print(f"Embedding shape : {emb.shape}") # expect torch.Size([1, 512]) |