def formatted_anns(image_id, category, area, bbox):
     annotations = []
     for i in range(0, len(category)):
         new_ann = {
             "image_id": image_id,
             "category_id": category[i],
             "isCrowd": 0,
             "area": area[i],
             "bbox": list(bbox[i]),
         }
         annotations.append(new_ann)

     return annotations

Now you can combine the image and annotation transformations to use on a batch of examples: