(self)
return splits
Create splits for Fungi and store them in the default path.

    If no split file is provided, and the default location for Fungi Identity
    splits does not contain a split file, splits are randomly created in this
    function using 70%, 15%, and 15% of the data for training, validation and
    testing, respectively, and then stored in that default location.

    Returns:
      The splits for this dataset, represented as a dictionary mapping each of
      'train', 'valid', and 'test' to a list of class names.
Create splits for Fungi and store them in the default path.
Create splits for Fungi and store them in the default path .
def create_splits(self):
    """Create splits for Fungi and store them in the default path.

    If no split file is provided, and the default location for Fungi Identity
    splits does not contain a split file, splits are randomly created in this
    function using 70%, 15%, and 15% of the data for training, validation and
    testing, respectively, and then stored in that default location.

    Returns:
      The splits for this dataset, represented as a dictionary mapping each of
      'train', 'valid', and 'test' to a list of class names.
    """
    # We ignore the original train and validation splits (the test set cannot be
    # used since it is not labeled).
    with tf.io.gfile.GFile(os.path.join(self.data_root, 'train.json')) as f:
      original_train = json.load(f)
    with tf.io.gfile.GFile(os.path.join(self.data_root, 'val.json')) as f:
      original_val = json.load(f)

    # The categories (classes) for train and validation should be the same.
    assert original_train['categories'] == original_val['categories']
    # Sort by category ID for reproducibility.
    categories = sorted(
        original_train['categories'], key=operator.itemgetter('id'))

    # Assert contiguous range [0:category_number]
    assert ([category['id'] for category in categories
            ] == list(range(len(categories))))

    # Some categories share the same name (see
    # https://github.com/visipedia/fgvcx_fungi_comp/issues/1)
    # so we include the category id in the label.
    labels = [
        '{:04d}.{}'.format(category['id'], category['name'])
        for category in categories
    ]

    train_inds, valid_inds, test_inds = gen_rand_split_inds(
        self.NUM_TRAIN_CLASSES, self.NUM_VALID_CLASSES, self.NUM_TEST_CLASSES)
    splits = {
        'train': [labels[i] for i in train_inds],
        'valid': [labels[i] for i in valid_inds],
        'test': [labels[i] for i in test_inds]
    }
    return splits
def create_splits ( self ) : # We ignore the original train and validation splits (the test set cannot be # used since it is not labeled). with tf . io . gfile . GFile ( os . path . join ( self . data_root , 'train.json' ) ) as f : original_train = json . load ( f ) with tf . io . gfile . GFile ( os . path . join ( self . data_root , 'val.json' ) ) as f : original_val = json . load ( f ) # The categories (classes) for train and validation should be the same. assert original_train [ 'categories' ] == original_val [ 'categories' ] # Sort by category ID for reproducibility. categories = sorted ( original_train [ 'categories' ] , key = operator . itemgetter ( 'id' ) ) # Assert contiguous range [0:category_number] assert ( [ category [ 'id' ] for category in categories ] == list ( range ( len ( categories ) ) ) ) # Some categories share the same name (see # https://github.com/visipedia/fgvcx_fungi_comp/issues/1) # so we include the category id in the label. labels = [ '{:04d}.{}' . format ( category [ 'id' ] , category [ 'name' ] ) for category in categories ] train_inds , valid_inds , test_inds = gen_rand_split_inds ( self . NUM_TRAIN_CLASSES , self . NUM_VALID_CLASSES , self . NUM_TEST_CLASSES ) splits = { 'train' : [ labels [ i ] for i in train_inds ] , 'valid' : [ labels [ i ] for i in valid_inds ] , 'test' : [ labels [ i ] for i in test_inds ] } return splits