Пример #1
0
 def __init__(self, data_path, pickle_path, budget, augment=False):
     self.path = data_path
     self.augment = augment
     if config.stain_normalized:
         self.n = stainNorm_Reinhard.Normalizer()
         i1 = cv2.imread('./data/source.png')
         i1 = cv2.cvtColor(i1, cv2.COLOR_BGR2RGB)
         self.n.fit(i1)
     label = []
     img_path = []
     with open(pickle_path, 'rb') as f:
         data_budget = pickle.load(f)
     for i, class_name in enumerate(data_budget[budget]['patches'].keys()):
         img_path = img_path + [
             os.path.join(class_name, x)
             for x in data_budget[budget]['patches'][class_name]
         ]
         num_imgs = len(data_budget[budget]['patches'][class_name])
         label = label + [i] * num_imgs
         print(f'number of images in class {class_name} are {num_imgs}')
     self.imgs = img_path
     self.labels = label
Пример #2
0
    def __init__(self, data_path, pickle_path, budget, augment=False):
        self.path = data_path
        self.augment = augment
        if config.stain_normalized:
            self.n = stainNorm_Reinhard.Normalizer()
            i1 = cv2.imread('./data/source.png')
            i1 = cv2.cvtColor(i1, cv2.COLOR_BGR2RGB)
            self.n.fit(i1)
        normal_label = []
        tumour_label = []
        normal_path = []
        tumour_path = []

        with open(pickle_path, 'rb') as f:
            data_budget = pickle.load(f)
        for image_name in data_budget[budget]['patches']['Normal']:
            normal_path.append(os.path.join('Normal', image_name))
            normal_label.append(0)
        for image_name in data_budget[budget]['patches']['Tumour']:
            tumour_path.append(os.path.join('Tumour', image_name))
            tumour_label.append(1)
        self.imgs = np.append(normal_path, tumour_path)
        self.labels = np.append(normal_label, tumour_label)