(voc_root, year, split, output_dir, shuffling=False)
Runs the conversion operation.

    Args:
      year: VOC year, 2007/2012/0712
      voc_root: VOC root dir.
      output_dir: Output directory.
Runs the conversion operation.
Runs the conversion operation .
def run(voc_root, year, split, output_dir, shuffling=False):
    """Runs the conversion operation.

    Args:
      year: VOC year, 2007/2012/0712
      voc_root: VOC root dir.
      output_dir: Output directory.
    """
    if not tf.gfile.Exists(output_dir):
        tf.gfile.MakeDirs(output_dir)

    # Dataset filenames, and shuffling.
    split_file_path = os.path.join(voc_root,
                                 'VOC%s'%year,
                                 'ImageSets',
                                 'Main',
                                 '%s.txt'%split)
    with open(split_file_path) as f:
        filenames = f.readlines()

    if shuffling:
        random.seed(RANDOM_SEED)
        random.shuffle(filenames)

    # Process dataset files.
    i = 0
    fidx = 0
    dataset_dir = os.path.join(voc_root, 'VOC%s'%year)
    while i < len(filenames):
        # Open new TFRecord file.
        tf_filename = _get_output_filename(output_dir, split, fidx)
        with tf.python_io.TFRecordWriter(tf_filename) as tfrecord_writer:
            j = 0
            while i < len(filenames) and j < SAMPLES_PER_FILES:
                sys.stdout.write('\r>> Converting image %d/%d' % (i+1, len(filenames)))
                sys.stdout.flush()

                filename = filenames[i].strip()
                _add_to_tfrecord(dataset_dir, filename, tfrecord_writer)
                i += 1
                j += 1
            fidx += 1

    print('\nFinished converting the Pascal VOC dataset!')
def run ( voc_root , year , split , output_dir , shuffling = False ) : if not tf . gfile . Exists ( output_dir ) : tf . gfile . MakeDirs ( output_dir ) # Dataset filenames, and shuffling. split_file_path = os . path . join ( voc_root , 'VOC%s' % year , 'ImageSets' , 'Main' , '%s.txt' % split ) with open ( split_file_path ) as f : filenames = f . readlines ( ) if shuffling : random . seed ( RANDOM_SEED ) random . shuffle ( filenames ) # Process dataset files. i = 0 fidx = 0 dataset_dir = os . path . join ( voc_root , 'VOC%s' % year ) while i < len ( filenames ) : # Open new TFRecord file. tf_filename = _get_output_filename ( output_dir , split , fidx ) with tf . python_io . TFRecordWriter ( tf_filename ) as tfrecord_writer : j = 0 while i < len ( filenames ) and j < SAMPLES_PER_FILES : sys . stdout . write ( '\r>> Converting image %d/%d' % ( i + 1 , len ( filenames ) ) ) sys . stdout . flush ( ) filename = filenames [ i ] . strip ( ) _add_to_tfrecord ( dataset_dir , filename , tfrecord_writer ) i += 1 j += 1 fidx += 1 print ( '\nFinished converting the Pascal VOC dataset!' )