blenderproc.python.utility.LabelIdMapping module
Provides a class to handle the mapping between different semantic segmentations.
- class blenderproc.python.utility.LabelIdMapping.LabelIdMapping[source]
Bases:
object
Handles category id mapping for semantic segmentation maps.
- add(label, id_value)[source]
Inserts the given label-id pair into the mapping.
- Parameters:
label (
str
) – The label of the pair.id_value (
int
) – The id of the pair
- static from_csv(path, label_col_name='name', id_col_name='id')[source]
Builds a label-id mapping based on the given csv file.
- Parameters:
path – The path to a csv file.
label_col_name – The name of the column which should be used as label.
id_col_name – The name of the column which should be used as id.
- Return type:
- Returns:
The built label mapping object.
- static from_dict(label_to_id)[source]
Builds a label-id mapping based on the given dict.
- Parameters:
label_to_id (
dict
) – A dict where keys are labels and values are ids.- Return type:
- Returns:
The built label mapping object.
- has_id(id_value)[source]
Checks if the mapping contains the given id.
- Parameters:
id_value (
int
) – The id to look for.- Return type:
bool
- Returns:
True, if the id is already in use.
- has_label(label)[source]
Checks if the mapping contains the given label.
- Parameters:
label (
str
) – The label to look for.- Return type:
bool
- Returns:
True, if the label is already in use.