|
import torch |
|
import torch.nn as nn |
|
import torch.optim as optim |
|
from torchvision import datasets, transforms |
|
from torch.utils.data import DataLoader |
|
import os |
|
import copy |
|
|
|
|
|
transform = transforms.Compose([ |
|
transforms.Resize((250, 250)), |
|
transforms.ToTensor(), |
|
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) |
|
]) |
|
|
|
|
|
data_dir = 'Processed_Data' |
|
|
|
|
|
train_dataset = datasets.ImageFolder(os.path.join(data_dir, 'train'), transform=transform) |
|
valid_dataset = datasets.ImageFolder(os.path.join(data_dir, 'valid'), transform=transform) |
|
test_dataset = datasets.ImageFolder(os.path.join(data_dir, 'test'), transform=transform) |
|
|
|
|
|
batch_size = 32 |
|
|
|
|
|
|
|
print(f"Number of training images: {len(train_dataset)}") |
|
print(f"Number of validation images: {len(valid_dataset)}") |
|
print(f"Number of test images: {len(test_dataset)}") |