Example #1
0
from COFGA_dataset import CofgaDataset

# ## Define run
# define name of output files
results_name = "ResNet50_no_aug__map.csv"
results_name_AP_val = "ResNet50_no_aug__AP_val.csv"
results_name_AP_train = "ResNet50_no_aug_AP_train.csv"

# ## Data augmentation
data_transform = None

# ## Loading the data

# loading the custom dataset
dataset = CofgaDataset(
    csv_file='/zhome/b0/8/88043/COFGA_Project/dataset/train_preprocessed.csv',
    root_dir='/zhome/b0/8/88043/COFGA_Project/dataset/root/train/resized/',
    transform=data_transform)

print("Total number of images: ", len(dataset))

COFGA_headers = pd.read_csv(
    '/zhome/b0/8/88043/COFGA_Project/dataset/train_preprocessed.csv')

COFGA_labels = COFGA_headers.columns.tolist()
COFGA_labels.pop(0)

COFGA_labels.insert(0, "epoch")

# ## Constructing trainLoader and validation loader

batch_size = 32
Example #2
0
#performing vertical flip with a gven probability
prob = 0.8
vert_transform = transforms.Compose([
    transforms.RandomVerticalFlip(prob),
    transforms.ToTensor(),
])

# allows to chose randomly from the different transformations
transform_list = transforms.RandomChoice(
    [rotation_transform, hoz_transform, vert_transform])

# ## Loading the data

# loading the custom dataset
dataset = CofgaDataset(csv_file='dataset/train_preprocessed.csv',
                       root_dir='dataset/root/train/resized/',
                       transform=transform_list)

print("Total number of images: ", len(dataset))

COFGA_headers = pd.read_csv('dataset/train_preprocessed.csv')

COFGA_labels = COFGA_headers.columns.tolist()
COFGA_labels.pop(0)

COFGA_labels.insert(0, "epoch")

# ## Constructing trainLoader and validation loader
batch_size = 32

# fraction of dataset to be validation set