(dataset_dir)
Runs the download and conversion operation.

  Args:
    dataset_dir: The dataset directory where the dataset is stored.
Runs the download and conversion operation.
Runs the download and conversion operation .
def run(dataset_dir):
  """Runs the download and conversion operation.

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

  training_filename = _get_output_filename(dataset_dir, 'train')
  testing_filename = _get_output_filename(dataset_dir, 'test')

  if tf.gfile.Exists(training_filename) and tf.gfile.Exists(testing_filename):
    print('Dataset files already exist. Exiting without re-creating them.')
    return

  dataset_utils.download_and_uncompress_tarball(_DATA_URL, dataset_dir)

  # First, process the training data:
  with tf.python_io.TFRecordWriter(training_filename) as tfrecord_writer:
    offset = 0
    for i in range(_NUM_TRAIN_FILES):
      filename = os.path.join(dataset_dir,
                              'cifar-10-batches-py',
                              'data_batch_%d' % (i + 1))  # 1-indexed.
      offset = _add_to_tfrecord(filename, tfrecord_writer, offset)

  # Next, process the testing data:
  with tf.python_io.TFRecordWriter(testing_filename) as tfrecord_writer:
    filename = os.path.join(dataset_dir,
                            'cifar-10-batches-py',
                            'test_batch')
    _add_to_tfrecord(filename, tfrecord_writer)

  # Finally, write the labels file:
  labels_to_class_names = dict(zip(range(len(_CLASS_NAMES)), _CLASS_NAMES))
  dataset_utils.write_label_file(labels_to_class_names, dataset_dir)

  _clean_up_temporary_files(dataset_dir)
  print('\nFinished converting the Cifar10 dataset!')
def run ( dataset_dir ) : if not tf . gfile . Exists ( dataset_dir ) : tf . gfile . MakeDirs ( dataset_dir ) training_filename = _get_output_filename ( dataset_dir , 'train' ) testing_filename = _get_output_filename ( dataset_dir , 'test' ) if tf . gfile . Exists ( training_filename ) and tf . gfile . Exists ( testing_filename ) : print ( 'Dataset files already exist. Exiting without re-creating them.' ) return dataset_utils . download_and_uncompress_tarball ( _DATA_URL , dataset_dir ) # First, process the training data: with tf . python_io . TFRecordWriter ( training_filename ) as tfrecord_writer : offset = 0 for i in range ( _NUM_TRAIN_FILES ) : filename = os . path . join ( dataset_dir , 'cifar-10-batches-py' , 'data_batch_%d' % ( i + 1 ) ) # 1-indexed. offset = _add_to_tfrecord ( filename , tfrecord_writer , offset ) # Next, process the testing data: with tf . python_io . TFRecordWriter ( testing_filename ) as tfrecord_writer : filename = os . path . join ( dataset_dir , 'cifar-10-batches-py' , 'test_batch' ) _add_to_tfrecord ( filename , tfrecord_writer ) # Finally, write the labels file: labels_to_class_names = dict ( zip ( range ( len ( _CLASS_NAMES ) ) , _CLASS_NAMES ) ) dataset_utils . write_label_file ( labels_to_class_names , dataset_dir ) _clean_up_temporary_files ( dataset_dir ) print ( '\nFinished converting the Cifar10 dataset!' )