def data_to_tfrecord(images, labels, filename):
 print ('Converting data into %s ...' % filename)
 cwd = os.getcwd()
 writer = tf.python_io.TFRecordWriter(filename)
 for (index, img) in enumerate(images):
  img_raw = img.tobytes()
  label = int(labels[index])
  example = tf.train.Example(features=tf.train.Features(feature={'label': tf.train.Feature(int64_list=tf.train.Int64List(value=[label])), 'img_raw': tf.train.Feature(bytes_list=tf.train.BytesList(value=[img_raw]))}))
  writer.write(example.SerializeToString())
 writer.close()

def data_to_tfrecord ( images , labels , filename ) : print ( 'Converting data into %s ...' % filename ) cwd = os . getcwd ( ) writer = tf . python_io . TFRecordWriter ( filename ) for ( index , img ) in enumerate ( images ) : img_raw = img . tobytes ( ) label = int ( labels [ index ] ) example = tf . train . Example ( features = tf . train . Features ( feature = { 'label' : tf . train . Feature ( int64_list = tf . train . Int64List ( value = [ label ] ) ) , 'img_raw' : tf . train . Feature ( bytes_list = tf . train . BytesList ( value = [ img_raw ] ) ) } ) ) writer . write ( example . SerializeToString ( ) ) writer . close ( )
save data into tfrecord .