An implementation of Tfrecord in muti-oriented detection task when data augmentation is needed. The bounding box annotation here is x1,y1,x2,y2,x3,y3,x4,y4 which is often used in text detection.
- Python2.7
- TensorFlow1.0
One image corresponds to a txt file. The annotations format in txt file is as follows:
x1,y1,x2,y2,x3,y3,x4,y4,label_name
x1,y1,x2,y2,x3,y3,x4,y4,label_name
You should prepare both train and val datasets. The file struture should be like this:
-$ROOT_PATH
-Dataset_train
-JPEGImages
-your images
-Annotations
-your txt_file
-Dataset_val
-JPEGImages
-your images
-Annotations
-your txt_file
-
First, you should set the right path in
config.pyand the label names inlabel_dict.py. -
Create
.tfrecordfiles.
python txt_to_tfrecord.py --type train
python txt_to_tfrecord.py --type val
- When training, use the function
next_batchinread_tfrecord.py.