-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
36 lines (29 loc) · 816 Bytes
/
Copy pathexample.py
File metadata and controls
36 lines (29 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from ODDataset import ObjectDetectionDataset
from torch.utils.data import DataLoader
from torchvision import transforms
default_transform = transforms.Compose([
transforms.ToTensor(),
])
def collate_fn(batch):
return tuple(zip(*batch))
# Expected structure:
# mydataset/
# ├── dimensions/
# │ ├── image_001.jpg
# │ └── image_002.jpg
# └── labels.json
dataset = ObjectDetectionDataset(
image_folder="mydataset/dimensions",
labels_json_path="mydataset/labels.json",
transform=default_transform,
)
loader = DataLoader(
dataset,
batch_size=4,
shuffle=True,
collate_fn=collate_fn,
)
for images, targets in loader:
print(f"Images batch shape: {images[0].shape}")
print(f"Targets: {targets, }")
break # just the first batch for testing