<jupyter_start><jupyter_text>Create the transformed datasetApply the transforms in order to get grayscale images of the same shape. Verify that your transform works by printing out the shape of the resulting data (printing out a few examples should show you a consistent tensor size).<jupyter_code>root = '/home/redne/mnt/project_zero/project_zero/ds1/parsed/'
voc_classes = ['fork', 'spoon', 'knife', 'coffeeCup', 'clearCup']

imgpath, annopath = data_processor.make_datapath_list(root)
train_img_list, train_anno_list, val_img_list, val_anno_list = imgpath[30:], annopath[30:], imgpath[:30], annopath[:30]

print(train_img_list[0])
transform_anno = data_processor.Anno_json(voc_classes)

ind = 1
image_file_path = val_img_list[ind]
img = cv2.imread(image_file_path)  
height, width, channels = img.shape 


transform_anno(val_anno_list[ind], width, height)
image_file_path = train_img_list[0]
img = cv2.imread(image_file_path)
height, width, channels = img.shape


transform_anno = data_processor.Anno_json(voc_classes)
anno_list = transform_anno(train_anno_list[0], width, height)

plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.show()
color_mean = (104, 117, 123)  
input_size = 300  
transform = data_processor.VOC_DataTransform(input_size, color_mean)

phase = "train"
img_transformed, boxes, labels = transform(
    img, phase, anno_list[:, :4], anno_list[:, 4])
plt.imshow(cv2.cvtColor(img_transformed, cv2.COLOR_BGR2RGB))
plt.show()

phase = "val"
img_transformed, boxes, labels = transform(
    img, phase, anno_list[:, :4], anno_list[:, 4])
plt.imshow(cv2.cvtColor(img_transformed, cv2.COLOR_BGR2RGB))
plt.show()<jupyter_output>Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).<jupyter_text>--- Data Loader<jupyter_code>color_mean = (104, 117, 123) 
input_size = 300

train_dataset = data_processor.VOCDataset(train_img_list, train_anno_list, phase="train", transform=data_processor.VOC_DataTransform(
    input_size, color_mean), transform_anno=data_processor.Anno_json(voc_classes))

val_dataset = data_processor.VOCDataset(val_img_list, val_anno_list, phase="val", transform=data_processor.VOC_DataTransform(
    input_size, color_mean), transform_anno=data_processor.Anno_json(voc_classes))

val_dataset.__getitem__(1)
batch_size = 4

train_dataloader = data.DataLoader(
    train_dataset, batch_size=batch_size, shuffle=True, collate_fn=data_processor.od_collate_fn)

val_dataloader = data.DataLoader(
    val_dataset, batch_size=batch_size, shuffle=False, collate_fn=data_processor.od_collate_fn)

dataloaders_dict = {"train": train_dataloader, "val": val_dataloader}

batch_iterator = iter(dataloaders_dict["val"])
images, targets = next(batch_iterator) 
print(images.size())  # torch.Size([4, 3, 300, 300])
print(len(targets))
print(targets[1].size()) 

print(train_dataset.__len__())
print(val_dataset.__len__())<jupyter_output>torch.Size([4, 3, 300, 300])
4
torch.Size([7, 5])
30
30
{'fraction_non_alphanumeric': 0.12057931963624116, 'fraction_numerical': 0.028292354328056584, 'mean_word_length': 7.342696629213483, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '308115', 'license': 'MIT', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1073, 'n_words': 215, 'path': 'Detection/pytorch/notebooks/01_DataLoader.ipynb', 'repo_name': 'naivelogic/ZeroWaste3D', 'size': '2969'}