TypeError in Custom Dataset

I have the below Dataset and I am getting the following error while trying to access the data with dataloader,
TypeError: can’t convert np.ndarray of type numpy.object. The only supported types are: double, float, float16, int64, int32, and uint8._
Below is the code for custom dataset and dataloader

class TestDataset(Dataset):

    def __init__(self, gt_file, root_dir, transform=None):
        super(TestDataset, self).__init__()
        self.ground_truth = pd.read_csv(gt_file, sep=";", header = None)
        self.root_dir = root_dir
        self.transform = transform
        self.C = 3
        self.W = 1360
        self.H = 800

    def __len__(self):
        return len(self.ground_truth)

    def __getitem__(self, idx):
        img_name = os.path.join(self.root_dir,
                                self.ground_truth.iloc[idx, 0])
        image = Image.open(img_name)
        image = np.asarray(image).astype(np.float16)
        image = image.reshape(self.C*self.W*self.H)
        image = torch.from_numpy(image)
        roi_points = self.ground_truth.iloc[idx, 1:-1].values.astype(np.float16)
        class_id = self.ground_truth.iloc[idx, -1]
        #sample = {'image': image, 'roi_points': roi_points, 'classId': [class_id]}

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

        return image, torch.from_numpy(roi_points), torch.Tensor(np.float16(class_id))

# Dataloader call
data_transform = transforms.Compose([
test_data = TestDataset(gt_file='...',
                                           root_dir='...', transform = data_transform)
dataloader = torch.utils.data.DataLoader(test_data,
                                             batch_size=4, shuffle=True,

What’s the type of roi_points and class_id?

I got it working…
Multiple things:

  1. I was using Jupyter Lab and somehow it was not showing me correct error. I had to change my image to RGB to get it working. Since I am new to pytorch I am still searching why this was required.
  2. Next I got _RuntimeError: cat_out is not implemented for type torch.HalfTensor which got fixed by changing float16 to just float

roi_points is ndarray of float and class_id is float…I have to create sequence for class_id and then return to get it working