import numpy as np import pandas as pd def colour_code_segmentation(image, label_values): label_values = [label_values[key] for key in label_values] colour_codes = np.array(label_values) x = colour_codes[image.astype(int)] return x def get_label_info(csv_path): ann = pd.read_csv(csv_path) label = {} for iter, row in ann.iterrows(): label_name = row['name'] r = row['r'] g = row['g'] b = row['b'] label[label_name] = [int(r), int(g), int(b)] return label