tfviewer.py
def preload_images(max_images):
  """ 
  Load images to be displayed in the browser gallery.

  Args:
    max_images (int): Maximum number of images to load.
  Returns:
    count (int): Number of images loaded.
  """
  count = 0
  overlay = overlay_factory.get_overlay(args.overlay, args)

  try:
    tf_record_iterator = tf.python_io.tf_record_iterator
  except:
    tf_record_iterator = tf.compat.v1.python_io.tf_record_iterator
  


  for tfrecord_path in args.tfrecords:
    print("Filename: ", tfrecord_path)
    for i, record in enumerate(tf_record_iterator(tfrecord_path)):
      if args.verbose: print("######################### Record", i, "#########################")
      example = tf.train.Example()
      example.ParseFromString(record)
      feat = example.features.feature

      if len(images) < max_images:
        filename = feat[args.filename_key].bytes_list.value[0].decode("utf-8")
        img =  feat[args.image_key].bytes_list.value[0]
        
        img_with_overlay = overlay.apply_overlay(img, feat)

        filenames.append(filename)
        images.append(img_with_overlay)
        captions.append( tfrecord_path + ":" + filename )
      else:
        return count
      count += 1
  return count
 
  Load images to be displayed in the browser gallery.

  Args:
    max_images (int): Maximum number of images to load.
  Returns:
    count (int): Number of images loaded.
  
Load images to be displayed in the browser gallery.
Load images to be displayed in the browser gallery .
def preload_images(max_images):
  count = 0
  overlay = overlay_factory.get_overlay(args.overlay, args)
  try:
    tf_record_iterator = tf.python_io.tf_record_iterator
  except:
    tf_record_iterator = tf.compat.v1.python_io.tf_record_iterator
  for tfrecord_path in args.tfrecords:
    print("Filename: ", tfrecord_path)
    for i, record in enumerate(tf_record_iterator(tfrecord_path)):
      if args.verbose: print("######################### Record", i, "#########################")
      example = tf.train.Example()
      example.ParseFromString(record)
      feat = example.features.feature
      if len(images) < max_images:
        filename = feat[args.filename_key].bytes_list.value[0].decode("utf-8")
        img =  feat[args.image_key].bytes_list.value[0]
        img_with_overlay = overlay.apply_overlay(img, feat)
        filenames.append(filename)
        images.append(img_with_overlay)
        captions.append( tfrecord_path + ":" + filename )
      else:
        return count
      count += 1
  return count
def preload_images ( max_images ) : count = 0 overlay = overlay_factory . get_overlay ( args . overlay , args ) try : tf_record_iterator = tf . python_io . tf_record_iterator except : tf_record_iterator = tf . compat . v1 . python_io . tf_record_iterator for tfrecord_path in args . tfrecords : print ( "Filename: " , tfrecord_path ) for i , record in enumerate ( tf_record_iterator ( tfrecord_path ) ) : if args . verbose : print ( "######################### Record" , i , "#########################" ) example = tf . train . Example ( ) example . ParseFromString ( record ) feat = example . features . feature if len ( images ) < max_images : filename = feat [ args . filename_key ] . bytes_list . value [ 0 ] . decode ( "utf-8" ) img = feat [ args . image_key ] . bytes_list . value [ 0 ] img_with_overlay = overlay . apply_overlay ( img , feat ) filenames . append ( filename ) images . append ( img_with_overlay ) captions . append ( tfrecord_path + ":" + filename ) else : return count count += 1 return count
Load images to be displayed in the browser gallery.
Load images to be displayed in the browser gallery .
""" 
  Load images to be displayed in the browser gallery.

  Args:
    max_images (int): Maximum number of images to load.
  Returns:
    count (int): Number of images loaded.
  """
count (int): Number of images loaded.
count ( int ) : Number of images loaded .
max_images
Maximum number of images to load.
Maximum number of images to load .