Exemplo n.º 1
0
    def getitem_additional(self, index):
        ID = self.additional_df.ID.values[index]
        ppths = '/common/danylokolinko/publichpa'

        X = load_RGBY_image(ppths,
                            'train',
                            ID,
                            channels=self.channels,
                            b8=self.b8)

        y = list(map(int, self.additional_df.Label.values[index].split('|')))
        y = one_hot_embedding(y, self.NUM_CL)

        ss_mask = None
        if self.segmentation:
            ppth = ppths + '_mask_semantic'
            ss_mask = self.load_mask_pred(ppth, ID, 'cell')
            ss_mask1 = self.load_mask_pred(ppth, ID, 'nuc')
            ss_mask1 = (cv2.resize(ss_mask1, ss_mask.shape[:-1]))
            ss_mask = np.concatenate((ss_mask, ss_mask1), axis=-1)
        if self.load_masks:
            cell_mask = self.load_mask(ppths + '_mask', ID, 'cell')

        if self.cell_input:
            X = np.concatenate((X, np.expand_dims(cell_mask, axis=0)), axis=0)

        out1 = self.transform_func(X, y, ID, cell_mask, ss_mask)

        return out1
Exemplo n.º 2
0
    def __getitem__(self, index):
        ss_mask = None
        if self.additional_data_path and index >= len(self.list_IDs):
            return self.getitem_additional(index - len(self.list_IDs))

        ID = self.list_IDs[index]
        # return np.nan, np.nan, ID, (np.nan), np.nan
        X = load_RGBY_image(self.path,
                            'train',
                            ID,
                            channels=self.channels,
                            b8=self.b8)

        y = list(map(int, self.labels[index].split('|')))
        y = one_hot_embedding(y, self.NUM_CL)
        if self.segmentation:
            ss_mask = self.load_mask_pred(self.hpasegm_path, ID, 'cell')
            ss_mask1 = self.load_mask_pred(self.hpasegm_path, ID, 'nuc')
            ss_mask1 = (cv2.resize(ss_mask1, ss_mask.shape[:-1]))
            ss_mask = np.concatenate((ss_mask, ss_mask1), axis=-1)
        if self.load_masks:
            cell_mask = self.load_mask(self.load_masks_path, ID, 'cell')

        if self.cell_input:
            X = np.concatenate((X, np.expand_dims(cell_mask, axis=0)), axis=0)

        out1 = self.transform_func(X, y, ID, cell_mask, ss_mask)

        return out1
Exemplo n.º 3
0
    def __getitem__(self, index):
        image, tags = super().__getitem__(index)

        if self.transform is not None:
            image = self.transform(image)

        label = one_hot_embedding([self.class_dic[tag] for tag in tags],
                                  self.classes)
        return image, label
Exemplo n.º 4
0
    def __getitem__(self, index):
        image, tags, mask = super().__getitem__(index)

        if self.transform is not None:
            input_dic = {'image': image, 'mask': mask}
            output_dic = self.transform(input_dic)

            image = output_dic['image']
            mask = output_dic['mask']

        label = one_hot_embedding([self.class_dic[tag] for tag in tags],
                                  self.classes)
        return image, label, mask
Exemplo n.º 5
0
    def __getitem__(self, index):
        image, image_id, tags, mask = super().__getitem__(index)

        label = one_hot_embedding([self.class_dic[tag] for tag in tags],
                                  self.classes)
        return image, image_id, label, mask