(dataset_dir, output_dir, name='voc_train', shuffling=False)
Runs the conversion operation.

    Args:
      dataset_dir: The dataset directory where the dataset is stored.
      output_dir: Output directory.
Runs the conversion operation.
Runs the conversion operation .
def run(dataset_dir, output_dir, name='voc_train', shuffling=False):
    """Runs the conversion operation.

    Args:
      dataset_dir: The dataset directory where the dataset is stored.
      output_dir: Output directory.
    """
    if not tf.gfile.Exists(dataset_dir):
        tf.gfile.MakeDirs(dataset_dir)

    # Dataset filenames, and shuffling.
    path = os.path.join(dataset_dir, DIRECTORY_ANNOTATIONS)
    filenames = sorted(os.listdir(path))
    if shuffling:
        random.seed(RANDOM_SEED)
        random.shuffle(filenames)

    # Process dataset files.
    i = 0
    fidx = 0
    while i < len(filenames):
        # Open new TFRecord file.
        tf_filename = _get_output_filename(output_dir, name, 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]
                img_name = filename[:-4]
                _add_to_tfrecord(dataset_dir, img_name, tfrecord_writer)
                i += 1
                j += 1
            fidx += 1

    print('\nFinished converting the Pascal VOC dataset!')
def run ( dataset_dir , output_dir , name = 'voc_train' , shuffling = False ) : if not tf . gfile . Exists ( dataset_dir ) : tf . gfile . MakeDirs ( dataset_dir ) # Dataset filenames, and shuffling. path = os . path . join ( dataset_dir , DIRECTORY_ANNOTATIONS ) filenames = sorted ( os . listdir ( path ) ) if shuffling : random . seed ( RANDOM_SEED ) random . shuffle ( filenames ) # Process dataset files. i = 0 fidx = 0 while i < len ( filenames ) : # Open new TFRecord file. tf_filename = _get_output_filename ( output_dir , name , 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 ] img_name = filename [ : - 4 ] _add_to_tfrecord ( dataset_dir , img_name , tfrecord_writer ) i += 1 j += 1 fidx += 1 print ( '\nFinished converting the Pascal VOC dataset!' )