MCPcopy Create free account
hub / github.com/geekcomputers/Python / __init__

Method __init__

ML/src/python/neuralforge/data/datasets.py:135–158  ·  view source on GitHub ↗
(self, root='./data/imagenet', split='train', transform=None, download=False)

Source from the content-addressed store, hash-verified

133
134class ImageNetDataset:
135 def __init__(self, root='./data/imagenet', split='train', transform=None, download=False):
136 if transform is None:
137 if split == 'train':
138 transform = transforms.Compose([
139 transforms.RandomResizedCrop(224),
140 transforms.RandomHorizontalFlip(),
141 transforms.ColorJitter(0.4, 0.4, 0.4),
142 transforms.ToTensor(),
143 transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
144 ])
145 else:
146 transform = transforms.Compose([
147 transforms.Resize(256),
148 transforms.CenterCrop(224),
149 transforms.ToTensor(),
150 transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
151 ])
152
153 try:
154 self.dataset = datasets.ImageFolder(os.path.join(root, split), transform=transform)
155 except:
156 print(f"ImageNet not found at {root}. Please download manually from https://image-net.org/")
157 print("Expected structure: {root}/train/ and {root}/val/")
158 raise
159
160 def __len__(self):
161 return len(self.dataset)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected