How to convert my object detection dataset to Tensorflow COCO format? (i.e. run this Retinanet implementation at my own dataset)

I’m running this Tensorflow implementation of Retinanet ( and it worked for me without problems. However, my goal is to adapt it to my own Object Detection dataset. i.e. put my own object detection dataset to it.

The problem is that the author gets COCO dataset via tfds.load()
I explored these TFRecords files and I noticed that their image annotations are in a different way (different from default COCO annotations) as shown in image below:

Annotation comparison

Is there a way to generate TFRecords files in this specific format of annotations for my own dataset (not get a ready-to-use dataset from tfds)?

Thanks a lot!

colab notebook with the error: