courses/machine_learning/deepdive/08_image/flowersmodeltpu/trainer/preprocess.py
def convert_to_example(csvline, categories):
  """Parse a line of CSV file and convert to TF Record.

  Args:
    csvline: line from input CSV file
    categories: list of labels
  Yields:
    serialized TF example if the label is in categories
  """
  filename, label = csvline.encode('ascii', 'ignore').split(',')
  if label in categories:
    # ignore labels not in categories list
    coder = ImageCoder()
    image_buffer, height, width = _get_image_data(filename, coder)
    del coder
    example = _convert_to_example(filename, image_buffer,
                                  categories.index(label), label, height, width)
    yield example.SerializeToString()
Parse a line of CSV file and convert to TF Record.

  Args:
    csvline: line from input CSV file
    categories: list of labels
  Yields:
    serialized TF example if the label is in categories
  
Parse a line of CSV file and convert to TF Record.
Parse a line of CSV file and convert to TF Record .
def convert_to_example(csvline, categories):
  filename, label = csvline.encode('ascii', 'ignore').split(',')
  if label in categories:
    coder = ImageCoder()
    image_buffer, height, width = _get_image_data(filename, coder)
    del coder
    example = _convert_to_example(filename, image_buffer,
                                  categories.index(label), label, height, width)
    yield example.SerializeToString()
def convert_to_example ( csvline , categories ) : filename , label = csvline . encode ( 'ascii' , 'ignore' ) . split ( ',' ) if label in categories : coder = ImageCoder ( ) image_buffer , height , width = _get_image_data ( filename , coder ) del coder example = _convert_to_example ( filename , image_buffer , categories . index ( label ) , label , height , width ) yield example . SerializeToString ( )
Parse a line of CSV file and convert to TF Record.
Parse a line of CSV file and convert to TF Record .
"""Parse a line of CSV file and convert to TF Record.

  Args:
    csvline: line from input CSV file
    categories: list of labels
  Yields:
    serialized TF example if the label is in categories
  """ # ignore labels not in categories list
serialized TF example if the label is in categories
serialized TF example if the label is in categories
csvline
line from input CSV file
line from input CSV file
categories
list of labels
list of labels