TypeError: Input type float32 is not supported from transform.toPilImage

Hey guy! i have a problem when i trying to transform image and i’m stucking here.

First parse image:

parse = Image.open(parse_obj)
parse = np.array(parse)
parse_channel = 20
parse_emb = []

for i in range(parse_channel):
    parse_emb.append((parse == i).astype(np.float32).tolist())

input_image = np.array(parse_emb).astype(np.float32)

Second transform image

transform['1'] = transforms.Compose([
        transforms.ToPILImage(),
        transforms.RandomAffine(degrees=10, translate=(
            0.1, 0.1), scale=(0.8, 1.2), shear=20),
        transforms.ToTensor()])
])

transform['2'] = transforms.Compose([
        transforms.ToTensor()])
])

manualSeed = random.randint(1, 10000)
random.seed(manualSeed)
torch.manual_seed(manualSeed)

num_channel_image = input_image.shape[0]
tform_input_image_np = np.zeros(
shape=input_image.shape, dtype=input_image.dtype)
  
for i in range(num_channel_image):
    if i != 1 and i != 2 and i != 4 and i != 5 and i != 13:
        # if i != 0 and i != 1 and i != 2 and i != 4 and i != 13:
        tform_input_image_np[i] = transforms['1'](input_image[i])  //Error from here
    else:
        tform_input_image_np[i] = transforms['2'](input_image[i])

TypeError: Input type float32 is not supported

But if i try to convert numpy array to uint8, it’ll show another errror:

ValueError: could not broadcast input array from shape (3,1101,750) into shape (1101,750,3)

How i can fix this :frowning: ?