PyTorchClassification/data_loader.py [368:393]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        else:
            self.tax_levels = ['id', 'genus', 'family', 'order', 'class', 'phylum', 'kingdom']
                               #8142, 4412,    1120,     273,     57,      25,       6

        self.taxonomy, self.classes_taxonomic, self.classnames = self.load_taxonomy(
                                             ann_data, self.tax_levels, self.classes)
        # Set targets 
        if label_smoothing > 0:
            # Build a list of the taxonomic assignment of each class
            # This is a list of list
            # tax_assignments[0] describes the assignment of each class at self.tax_levels[0]
            # tax_assignments[1] at the level of self.tax_levels[1], and so on
            tax_assignments = list(zip(*[[cc[tax_level] for tax_level in self.tax_levels] 
                                                        for cc in ann_data['categories']]))
            # Permute the class order to be 0, ..., num_classes-1 by assuming that 
            # tax_assignments[0] contains the class_ids as integer
            # First, compute how to permute the classes
            cat_permutation = np.argsort(tax_assignments[0])
            # Then apply the permutation to all lists
            # We cannot permute everything at once using numpy arrays as there are different dtype
            for tax_level in range(len(tax_assignments)):
                tax_assignments[tax_level] = np.array(tax_assignments[tax_level])[cat_permutation]
                # Also cut off the genus of the family name in 2017 format
            if dataFormat2017 and isinstance(tax_assignments[1][0], str):
                tax_assignments[1] = [ss.split(' ')[0] for ss in tax_assignments[1]]
                tax_assignments[1] = np.array(tax_assignments[1])
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



PyTorchClassification/data_loader_cv.py [328:353]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        else:
            self.tax_levels = ['id', 'genus', 'family', 'order', 'class', 'phylum', 'kingdom']
                               #8142, 4412,    1120,     273,     57,      25,       6

        self.taxonomy, self.classes_taxonomic, self.classnames = self.load_taxonomy(
                                             ann_data, self.tax_levels, self.classes)
        # Set targets 
        if label_smoothing > 0:
            # Build a list of the taxonomic assignment of each class
            # This is a list of list
            # tax_assignments[0] describes the assignment of each class at self.tax_levels[0]
            # tax_assignments[1] at the level of self.tax_levels[1], and so on
            tax_assignments = list(zip(*[[cc[tax_level] for tax_level in self.tax_levels] 
                                                        for cc in ann_data['categories']]))
            # Permute the class order to be 0, ..., num_classes-1 by assuming that 
            # tax_assignments[0] contains the class_ids as integer
            # First, compute how to permute the classes
            cat_permutation = np.argsort(tax_assignments[0])
            # Then apply the permutation to all lists
            # We cannot permute everything at once using numpy arrays as there are different dtype
            for tax_level in range(len(tax_assignments)):
                tax_assignments[tax_level] = np.array(tax_assignments[tax_level])[cat_permutation]
                # Also cut off the genus of the family name
            if dataFormat2017 and isinstance(tax_assignments[1][0], str):
                tax_assignments[1] = [ss.split(' ')[0] for ss in tax_assignments[1]]
                tax_assignments[1] = np.array(tax_assignments[1])
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



