(pathuni)
return generator_utils.to_example(final).SerializeToString()
Bulk of dataset processing. Converts str path to serialized tf.Example.
Bulk of dataset processing. Converts str path to serialized tf.Example.
Bulk of dataset processing . Converts str path to serialized tf . Example .
def _create_example(pathuni):
  """Bulk of dataset processing. Converts str path to serialized tf.Example."""
  path, uni, binary_fp = pathuni
  final = {}

  # zoom out
  path = svg_utils.zoom_out(path)
  # make clockwise
  path = svg_utils.canonicalize(path)

  # render path for training
  final['rendered'] = svg_utils.per_step_render(path, absolute=True)

  # make path relative
  path = svg_utils.make_relative(path)
  # convert to vector
  vector = svg_utils.path_to_vector(path, categorical=True)
  # make simple vector
  vector = np.array(vector)
  vector = np.concatenate(
      [np.take(vector, [0, 4, 5, 9], axis=-1), vector[..., -6:]], axis=-1)

  # count some stats
  final['seq_len'] = np.shape(vector)[0]
  final['class'] = int(svg_utils.map_uni_to_alphanum(uni))
  final['binary_fp'] = str(binary_fp)

  # append eos
  vector = svg_utils.append_eos(vector.tolist(), True, 10)

  # pad path to 51 (with eos)
  final['sequence'] = np.concatenate(
      (vector, np.zeros(((50 - final['seq_len']), 10))), 0)

  # make pure list:
  final['rendered'] = np.reshape(final['rendered'][..., 0],
                                 [64*64]).astype(np.float32).tolist()
  final['sequence'] = np.reshape(final['sequence'],
                                 [51*10]).astype(np.float32).tolist()
  final['class'] = np.reshape(final['class'],
                              [1]).astype(np.int64).tolist()
  final['seq_len'] = np.reshape(final['seq_len'],
                                [1]).astype(np.int64).tolist()

  return generator_utils.to_example(final).SerializeToString()
def _create_example ( pathuni ) : path , uni , binary_fp = pathuni final = { } # zoom out path = svg_utils . zoom_out ( path ) # make clockwise path = svg_utils . canonicalize ( path ) # render path for training final [ 'rendered' ] = svg_utils . per_step_render ( path , absolute = True ) # make path relative path = svg_utils . make_relative ( path ) # convert to vector vector = svg_utils . path_to_vector ( path , categorical = True ) # make simple vector vector = np . array ( vector ) vector = np . concatenate ( [ np . take ( vector , [ 0 , 4 , 5 , 9 ] , axis = - 1 ) , vector [ ... , - 6 : ] ] , axis = - 1 ) # count some stats final [ 'seq_len' ] = np . shape ( vector ) [ 0 ] final [ 'class' ] = int ( svg_utils . map_uni_to_alphanum ( uni ) ) final [ 'binary_fp' ] = str ( binary_fp ) # append eos vector = svg_utils . append_eos ( vector . tolist ( ) , True , 10 ) # pad path to 51 (with eos) final [ 'sequence' ] = np . concatenate ( ( vector , np . zeros ( ( ( 50 - final [ 'seq_len' ] ) , 10 ) ) ) , 0 ) # make pure list: final [ 'rendered' ] = np . reshape ( final [ 'rendered' ] [ ... , 0 ] , [ 64 * 64 ] ) . astype ( np . float32 ) . tolist ( ) final [ 'sequence' ] = np . reshape ( final [ 'sequence' ] , [ 51 * 10 ] ) . astype ( np . float32 ) . tolist ( ) final [ 'class' ] = np . reshape ( final [ 'class' ] , [ 1 ] ) . astype ( np . int64 ) . tolist ( ) final [ 'seq_len' ] = np . reshape ( final [ 'seq_len' ] , [ 1 ] ) . astype ( np . int64 ) . tolist ( ) return generator_utils . to_example ( final ) . SerializeToString ( )