I am currently trying to find a way to determine a chess position based on an overhead picture of a chessboard. My model is a retrained resnet50. Here is my code:
classes = ['b','k','n','p','q','r',None,'B','K','N','P','Q','R']
squares = image_processing('/Users/Me/Downloads/s-zoom.file.jpeg')
image_transforms = transforms.Compose([
transforms.Resize((227,227)),
transforms.ToTensor()
])
board = []
for square in squares:
square = Image.fromarray(square)
square = image_transforms(square).float()
square = square.unsqueeze(0)
output = model(square)
_, predicted = torch.max(output.data, 1)
board.append(classes[predicted.item()])
The problem is that this takes a long time to process - over 20 seconds, when ideally it should take under 5. What is a more efficient way of doing this?