import torch
import torchvision
from torch.utils.data import Dataset, DataLoader
from torchvision import datasets, transforms

#should output the images in 640 x 640
def load_data(data_folder, batch_size, train):
    transform = {
        'train': transforms.Compose(
            [transforms.Resize([224, 224]),
                #transforms.RandomCrop(224),
                #transforms.RandomHorizontalFlip(),
                transforms.ToTensor(),
                transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                  std=[0.229, 0.224, 0.225])]),
        'test': transforms.Compose(
            [transforms.Resize([224, 224]),
                transforms.ToTensor(),
                transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                  std=[0.229, 0.224, 0.225])])
        }
    data = datasets.ImageFolder(root = data_folder, transform=transform['train' if train else 'test'])
    data_loader = torch.utils.data.DataLoader(data, batch_size=batch_size, shuffle=True, drop_last = True if train else False)
    return data_loader, data
