Input type is not supported on loop

username: akcaymert
cooked: <p>i working on segmentation models but facing ‘Input type float32(or uint8 int32) is not supported’ on for loop. both image type and label type are list,  How to fix this problem ?</p>
<pre><code class="lang-auto">class datasetLoader_from(Dataset):
  def __init__(self,color,transform=None):
    self.label = []
    self.image = []
    i = 0
    for folder in os.listdir('/content/drive/MyDrive/face_image/real'):
      img = cv2.imread(os.path.join('/content/drive/MyDrive/face_image/real',folder),cv2.COLOR_BGR2RGB)
      img = np.asarray(img,dtype = np.float32)
      self.label.append(rgb_to_onehot(img,color))
      i+=1
      if i ==250:
        break
    k = 0
    for folder in os.listdir('/content/drive/MyDrive/face_image/real_photos'):
      img = cv2.imread(os.path.join('/content/drive/MyDrive/face_image/real_photos',folder),cv2.COLOR_BGR2RGB)
      img = np.asarray(img,dtype=np.float32)
      self.image.append(img)
      k+=1
      if k ==250:
        break
    self.transform = transform
    print(type(label))
    print(type(image))
  def __len__(self):
    try: #for type error
      if (len(self.image)==len(self.label)):
        return len(self.image)
    except:
      print('__len__ exception occured')
  def __getitem__(self,x):

    sub_image = self.image[x]
    sub_label = self.label[x]


    if self.transform:
      sub_image = self.transform(sub_image)
      sub_label = self.transform(sub_label)
    return sub_image,sub_label

</code></pre>
<pre><code class="lang-auto">transform_dict = transforms.Compose(
        [transforms.ToPILImage(),
         transforms.RandomResizedCrop(224),
         transforms.RandomHorizontalFlip(),
         transforms.ToTensor(),
         transforms.Normalize(mean=[0.485, 0.456, 0.406],
                              std=[0.229, 0.224, 0.225]),
         ])
Train_Dataset = datasetLoader_from_csv(color,transform=transform_dict)
Train_Dataset = DataLoader(Train_Dataset, batch_size=4,shuffle=False, num_workers=0)
</code></pre>
<pre><code class="lang-auto">for epochs in range(EPOCHS):
  for i,(images,labels) in enumerate(Train_Dataset):
    print(f"Epoch: {epochs/EPOCHS}")
    images = images.to(device)
    labels = labels.to(device)
    optim.zero_grad()
</code></pre>
<pre><code class="lang-auto">---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-58-685c10c0cfca&gt; in &lt;module&gt;()
      4 #train
      5 for epochs in range(EPOCHS):
----&gt; 6   for i,(images,labels) in enumerate(Train_Dataset):
      7     print(f"Epoch: {epochs/EPOCHS}")
      8     images = images.to(device)

7 frames
/usr/local/lib/python3.6/dist-packages/torchvision/transforms/functional.py in to_pil_image(pic, mode)
    241 
    242     if mode is None:
--&gt; 243         raise TypeError('Input type {} is not supported'.format(npimg.dtype))
    244 
    245     return Image.fromarray(npimg, mode=mode)

TypeError: Input type float32 is not supported
</code></pre>

username: akcaymert
cooked: <p>i can fix by changing np.array not properly  work np.asarray</p>