Views
No views yet
airplane, automobile, bird, cat, deer, dog, frog, horse, ship, truck1import torch
2from googlenet_model import GoogLeNetCIFAR # Make sure this contains the model implementation
3
4# Load the pretrained model
5model = GoogLeNetCIFAR(num_classes=10)
6model.load_state_dict(torch.load("Inception-v1.pth", map_location=torch.device('cpu')))
7model.eval()
8
9# Example inference
10from torchvision import transforms
11from PIL import Image
12
13transform = transforms.Compose([
14 transforms.Resize((32, 32)),
15 transforms.ToTensor(),
16 transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
17])
18
19image = Image.open("example_image.png")
20input_tensor = transform(image).unsqueeze(0) # Add batch dimension
21
22output, _, _ = model(input_tensor) # Main output and auxiliary classifiers
23predicted_class = output.argmax(1).item()
24print("Predicted Class:", predicted_class)