title: How to convert string labels to int labels when using `tf.data.Dataset.list_files`
body: <p>I am new to machine learning and have tried many different ways to create an image data pipeline. I went through Udacity and Google Tutorials and they all work great, so long as you get your image data from TF Hub or some other online source. Unfortunately, I haven't found ANY end-to-end examples (that work) of how to do this correctly when you have your own locally stored images. This is as close as I have gotten.</p>
  
  <p>I have my own image data and am trying to get it in the correct Tensor format to fit my model (I'm using a feature extractor from TensorFlow Hub). I froze all the layers, added a binary output layer.</p>
  
  <p>I get the following error when I run a training session with <code>train_batches</code> <code>model.fit</code></p>
  
  <p><code>UnimplementedError:  Cast string to float is not supported</code></p>
  
  <p>I'm pretty sure it has to do with the class labels being strings (pulled from folder name). Is there anyway I can pass a dictionary with values <code>0</code> and <code>1</code> to relabel?</p>
  
  <p>Am I missing something much more crucial than this?</p>
  
  <pre><code>image_path_list = glob('/content/sample_data/tng (1)/*/*.jpg')
  data = tf.data.Dataset.list_files(image_path_list)
  print(image_path_list)
  print()
  print(data)
  
  def load_images(path):
      image = tf.io.read_file(path)
      image = tf.io.decode_jpeg(image, channels=3)
      label = tf.strings.split(path, os.path.sep)[-2]
      return image, label
  data = data.map(load_images)
  
  def preprocess(image, label):
      image = tf.image.resize(image, (IMG_RES, IMG_RES))
      image /= 255.
      return image, label
  
  BATCH_SIZE = 1
  
  train_batches = data.shuffle(len(image_path_list)).map(preprocess).batch(BATCH_SIZE).prefetch(1) 
  </code></pre>