def __init__(self, input_size, color_mean, color_std): self.data_transform = { "train": Compose([ Scale(scale=[0.5, 1.5]), RandomRotation(angle=[-10, 10]), RandomMirror(), Resize(input_size), Normalize_Tensor(color_mean, color_std), ]), "val": Compose( [Resize(input_size), Normalize_Tensor(color_mean, color_std)]) }
from torch.optim import lr_scheduler from utils import ChestXrayDataset, ToTensor, LeftToRightFlip, RandomCrop, Resize, ColorJitter, RandomRotation from torchvision import transforms, models from torch.utils.data import DataLoader import torch import torch.nn as nn from focal_loss import FocalLoss from model import get_model transform = { 'train': transforms.Compose([ LeftToRightFlip(0.5), RandomRotation(angle=3, p=0.5), Resize(224), ColorJitter(p=0.5, color=0.1, contrast=0.1, brightness=0.1, sharpness=0.1), RandomCrop(scale=210, p=0.5), Resize(224), ToTensor() ]), 'test': transforms.Compose([ToTensor()]) } datasets = {