Hi,
I have the following directory
data/
├── images/         # dir for jpg files
├── aeroplane.txt   # aeroplane object class labels
├── bicycle.txt     # bicycle object class labels
├── bird.txt        # bird object class labels
├── boat.txt        # boat object class labels
├── bottle.txt      # bottle object class labels
├── bus.txt         # bus object class labels
├── car.txt         # car object class labels
├── cat.txt         # cat object class labels
├── chair.txt       # chair object class labels
├── cow.txt         # cow object class labels
├── diningtable.txt # dining table object class labels
├── dog.txt         # dog object class labels
├── horse.txt       # horse object class labels
├── motorbike.txt   # motorbike object class labels
├── person.txt      # person object class labels
├── pottedplant.txt # potted plant object class labels
├── sheep.txt       # sheep object class labels
├── sofa.txt        # sofa object class labels
├── train.txt       # train object class labels
├── tvmonitor.txt   # TV monitor object class labels
I have 17000 pictures that I want to classify the objects it has according to the directory above whether a sofa train or sheep, ect… is present.
I have set up the code below but I am having difficulty setting up a training folder that would randomly take 25% of the data set present for example.
import torch
import torchvision.transforms as transforms
import torchvision.models as models
import torch.nn as nn
import torch.optim as optim
import numpy as np
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
pip install torchvision
from torchvision import models
dir(models)
resnet = models.resnet101(pretrained=True)
from torchvision import transforms
Image transformations
image_transforms = {
# Train uses data augmentation
‘train’:
transforms.Compose([
transforms.RandomResizedCrop(size=256, scale=(0.8, 1.0)),
transforms.RandomRotation(degrees=15),
transforms.ColorJitter(),
transforms.RandomHorizontalFlip(),
transforms.CenterCrop(size=224),  # Image net standards
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406],
[0.229, 0.224, 0.225])  # Imagenet standards
]),
# Validation does not use augmentation
‘valid’:
transforms.Compose([
transforms.Resize(size=256),
transforms.CenterCrop(size=224),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
]),
}
import torchvision.datasets as datasets
train_set = datasets.ImageFolder(“root/label/train”, transform = image_transforms[‘train’])
val_set = datasets.ImageFolder(“root/label/valid”, transform = image_transforms[‘valid’])
FileNotFoundError                         Traceback (most recent call last)
 in ()
----> 1 train_set = datasets.ImageFolder(“root/label/train”, transform = image_transforms[‘train’])
2 val_set = datasets.ImageFolder(“root/label/valid”, transform = image_transforms[‘valid’])
2 frames
/usr/local/lib/python3.6/dist-packages/torchvision/datasets/folder.py in _find_classes(self, dir)
120         if sys.version_info >= (3, 5):
121             # Faster and available in Python 3.5 and above
–> 122             classes = [d.name for d in os.scandir(dir) if d.is_dir()]
123         else:
124             classes = [d for d in os.listdir(dir) if os.path.isdir(os.path.join(dir, d))]
FileNotFoundError: [Errno 2] No such file or directory: ‘root/label/train’