Create scafolding for inception A test

This commit is contained in:
2024-06-02 19:31:35 +02:00
parent a4a2801ee4
commit 3fee9fde6f
2 changed files with 217 additions and 3 deletions

View File

@@ -47,14 +47,14 @@ def print_model_parameters(model: torch.nn.Module):
print(name, param.numel())
def predict(model, image_path, preprocess=None):
def predict(model, image_path, resize=299, crop=299, preprocess=None):
input_image = Image.open(image_path)
if preprocess is None:
preprocess = transforms.Compose(
[
transforms.Resize(299),
transforms.CenterCrop(299),
transforms.Resize(resize),
transforms.CenterCrop(crop),
transforms.ToTensor(),
transforms.Normalize(
mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]