from datasets import load_dataset
your_data = load_dataset('imagefolder', data_dir='annotated_data') # this will use metadata.jsonl in annotated_data to create your_data
print(your_data)
# optional: you can easily plot one instance of your_data in jupyter notebook
import torch
from torchvision.utils import draw_bounding_boxes
from torchvision.transforms.functional import pil_to_tensor, to_pil_image
example = your_data['train'][0]
boxes_xyxy = torch.tensor(example['objects']['bbox'])
labels = [x for x in example['objects']['names']]
to_pil_image(
draw_bounding_boxes(
pil_to_tensor(example['image'].convert('RGB')),
boxes_xyxy,
colors="red",
labels=labels,
)
)