Esempio n. 1
0
    def forward_feature(self, batch, **kwargs):
        data = list_to_variable(batch['image_batch'],
                                volatile=kwargs.get('volatile', False))
        labels = tensor_to_var(torch.Tensor(np.array(batch['label_batch'])))

        features = self.model.features(data)
        return features, labels
    def forward(self, batch, **kwargs):
        """

        :param batch:
        :param kwargs:
        :return:
        """
        #         print(batch['image_batch'][0].min())
        #         print(batch['image_batch'][0].max())

        data = list_to_variable(batch['image_batch'],
                                volatile=kwargs.get('volatile', False))
        lbls = [img / 255.0 for img in batch['image_batch']]
        labels = list_to_variable(lbls, volatile=kwargs.get('volatile', False))

        pred = self.model(data)

        return pred, labels
Esempio n. 3
0
    def forward(self, batch, **kwargs):
        """

        :param batch:
        :param kwargs:
        :return:
        """
        data = list_to_variable(batch['image_batch'],
                                volatile=kwargs.get('volatile', False))
        labels = tensor_to_var(torch.Tensor(np.array(batch['label_batch'])))

        pred = self.model(data)

        return pred, labels
Esempio n. 4
0
    def forward(self, batch, **kwargs):
        """

        :param batch:
        :param kwargs:
        :return:
        """
        data = list_to_variable(batch['image_batch'],
                                volatile=kwargs.get('volatile', False))
        labels_lesion = tensor_to_var(
            torch.Tensor(np.array(batch['label_batch'])))
        labels_row = tensor_to_var(
            torch.Tensor(np.array(batch['center_row_batch'])))
        labels_col = tensor_to_var(
            torch.Tensor(np.array(batch['center_col_batch'])))

        pred = self.model(data)

        return pred[:,
                    0], pred[:,
                             1], pred[:,
                                      2], labels_lesion, labels_row, labels_col
def test_resnet_auto():
    model = get_feature_model('auto',
                              'auto',
                              load_pretrained=False,
                              opti=None,
                              lr=None,
                              mom=None,
                              checkpoint_pretrained=None,
                              learn_pos=False,
                              force_on_cpu=False)
    val_loader = get_valloader_only(False, False, 1, 0, False)
    for batch_idx, batch in enumerate(val_loader):
        if len(batch['image_batch']) > 0:
            # print(len(batch['image_batch']))
            # print(batch['image_batch'][0].size())
            data = list_to_variable(batch['image_batch'])
            labels = tensor_to_var(torch.Tensor(np.array(
                batch['label_batch'])),
                                   async=True)

            pred = model(data)

        break