title: Tensorflow Removing JFIF
body: <p>I am quite new to tensorflow, I would like to clearly know, what does the below command do?</p>
  
  <pre><code>import tensorflow as tf
  from tensorflow import keras
  from tensorflow.keras import layers
  import os
  
  num_skipped = 0
  for folder_name in ("Cat", "Dog"):
      print("folder_name:",folder_name) #folder_name: Cat
      folder_path = os.path.join("Dataset/PetImages", folder_name)
      print("folder_path:",folder_path) #folder_path: Dataset/PetImages/Cat
      for fname in os.listdir(folder_path):
          print("fname:",fname) #fname: 5961.jpg
          fpath = os.path.join(folder_path, fname)
          print("fpath:", fpath) #fpath: Dataset/PetImages/Cat/10591.jpg
          try:
              fobj = open(fpath, "rb")
              is_jfif = tf.compat.as_bytes("JFIF") in fobj.peek(10)
          finally:
              fobj.close()
  
          if not is_jfif:
              num_skipped += 1
              # Delete corrupted image
              os.remove(fpath)
  
  print("Deleted %d images" % num_skipped)
  </code></pre>
  
  <p><strong>Keras Website comment on the above code :</strong></p>
  
  <p><em>When working with lots of real-world image data, corrupted images are a common occurence. Let's filter out badly-encoded images that do not feature the string "JFIF" in their header.</em></p>
  
  <p>I want to specifically know what does the below command do, how does it do ?</p>
  
  <pre><code> is_jfif = tf.compat.as_bytes("JFIF") in fobj.peek(10)
  </code></pre>
  
  <p>I checked the API but wasn't clearly able to understand it. </p>
  
  <p>A better explanation will be of much help. </p>
  
  <p>Thanks</p>