Small bugfix. During training images get resized to 250x Y or X x 250 first...

Small bugfix. During training images get resized to 250x Y or X x 250 first before center cropping. Otherwise you get a zoom in effect and only work on a small part of the actual image
parent e7da2ad1
......@@ -8,12 +8,14 @@ def get_data_loaders(dataset_path, validation_split, batch_size, num_workers, ce
# define transformation used in training an validation
transform = transforms.Compose([
transforms.Resize(center_crop_size),
transforms.CenterCrop(center_crop_size),
# center crop and resize to 250x250
transforms.RandomCrop(random_crop_size),
# random crop to 224x224
transforms.RandomHorizontalFlip(),
transforms.ToTensor()])
transforms.ToTensor()
])
dataset = torchvision.datasets.ImageFolder(root=dataset_path, transform=transform)
# load image data
......@@ -43,24 +45,7 @@ class ImageFolderWithPaths(torchvision.datasets.ImageFolder):
def get_path_data_loader(dataset_path, batch_size=1, num_workers=4):
dataset = ImageFolderWithPaths(root=dataset_path, transform=transforms.ToTensor())
return torch.utils.data.DataLoader(dataset=dataset, batch_size=batch_size, num_workers=num_workers, shuffle=True)
"""
from pathlib import Path
import time
tl, vl = get_data_loaders(Path("../Datasets/Landmarks"), 0.2, 8, 4, 900,720)
print(len(tl.dataset.dataset.classes))
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
t_sum = 0
last_time = time.time()
for i, batch in enumerate(tl, 0):
t = time.time()
t_diff = t - last_time
t_sum += t_diff
last_time = t
print(f"{t_diff}_{i}")
inputs, labels = batch[0].to(device), batch[1].to(device)
print(t_sum)
"""
"""
from pathlib import Path
loader = get_path_data_loader(Path("../../Datasets/Landmarks"))
......
......@@ -9,7 +9,6 @@ import numpy as np
import uuid
import time
import json
import pickle
import fire
CENTER_CROP_SIZE_FINETUNING = 250
RANDOM_CROP_SITE_FINETUNING = 224
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment