diff --git a/anodet/feature_extraction.py b/anodet/feature_extraction.py index 4ec999e..8fd30ee 100644 --- a/anodet/feature_extraction.py +++ b/anodet/feature_extraction.py @@ -4,7 +4,7 @@ import torch import torch.nn.functional as F -from torchvision.models import resnet18, ResNet18_Weights, wide_resnet50_2, Wide_ResNet50_2_Weights +from torchvision.models import resnet18, ResNet18_Weights, wide_resnet50_2, Wide_ResNet50_2_Weights,resnet34,ResNet34_Weights from tqdm import tqdm from typing import List, Optional, Callable, cast from torch.utils.data import DataLoader @@ -29,12 +29,14 @@ def __init__(self, backbone_name: str, device: torch.device) -> None: """ super().__init__() - assert backbone_name in ['resnet18', 'wide_resnet50'] + assert backbone_name in ['resnet18', 'wide_resnet50','resnet34'] if backbone_name == 'resnet18': self.backbone = resnet18(weights=ResNet18_Weights.DEFAULT, progress=True) elif backbone_name == 'wide_resnet50': self.backbone = wide_resnet50_2(weights=Wide_ResNet50_2_Weights.DEFAULT, progress=True) + elif backbone_name == 'resnet34': + self.backbone = resnet34(weights=ResNet34_Weights.DEFAULT, progress=True) self.backbone.to(device) self.backbone.eval() diff --git a/anodet/padim.py b/anodet/padim.py index 437bab6..eb4a079 100644 --- a/anodet/padim.py +++ b/anodet/padim.py @@ -52,6 +52,8 @@ def __init__(self, backbone: str = 'resnet18', self.channel_indices = get_indices(100, 448, self.device) elif backbone == 'wide_resnet50': self.channel_indices = get_indices(550, 1792, self.device) + elif backbone == 'resnet34': + self.channel_indices = get_indices(100, 448, self.device) self.layer_indices = layer_indices if self.layer_indices is None: diff --git a/anodet/utils.py b/anodet/utils.py index 83a24b8..f3e2803 100644 --- a/anodet/utils.py +++ b/anodet/utils.py @@ -10,15 +10,15 @@ import os -standard_image_transform = T.Compose([T.Resize(224), - T.CenterCrop(224), +standard_image_transform = T.Compose([T.Resize(320), + T.CenterCrop(320), T.ToTensor(), T.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) ]) -standard_mask_transform = T.Compose([T.Resize(224), - T.CenterCrop(224), +standard_mask_transform = T.Compose([T.Resize(320), + T.CenterCrop(320), T.ToTensor() ])