(metadata, paths)
Generates DTD examples.
Generates DTD examples.
Generates DTD examples .
def generate_dtd_examples(metadata, paths):
  """Generates DTD examples."""
  data_path = paths['dtd-r1.0.1'] / 'dtd/images'

  image_ids = itertools.count()

  for label, class_name in enumerate(metadata['class_names']):
    for image_path in (data_path / class_name).iterdir():
      yield _image_key(next(image_ids), metadata['total_num_examples']), {
          'image': _load_and_process_image(image_path=image_path),
          'format': 'JPEG',
          'filename': image_path.name,
          'label': label,
          'class_name': class_name,
      }
def generate_dtd_examples ( metadata , paths ) : data_path = paths [ 'dtd-r1.0.1' ] / 'dtd/images' image_ids = itertools . count ( ) for label , class_name in enumerate ( metadata [ 'class_names' ] ) : for image_path in ( data_path / class_name ) . iterdir ( ) : yield _image_key ( next ( image_ids ) , metadata [ 'total_num_examples' ] ) , { 'image' : _load_and_process_image ( image_path = image_path ) , 'format' : 'JPEG' , 'filename' : image_path . name , 'label' : label , 'class_name' : class_name , }