# Input type is not supported on loop

**URL:** <https://discuss.pytorch.org/t/input-type-is-not-supported-on-loop/103626>\
**Category:** vision\
**Created:** [November 21, 2020, 5:33pm UTC](https://discuss.pytorch.org/t/input-type-is-not-supported-on-loop/103626 "2020-11-21T17:33:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![akcaymert](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/a/7c8e57/32.png) [@akcaymert](https://discuss.pytorch.org/u/akcaymert)\
**Post date:** [November 21, 2020, 5:33pm UTC](https://discuss.pytorch.org/t/input-type-is-not-supported-on-loop/103626/1 "2020-11-21T17:33:41Z")

</div>

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 ?

```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

```

```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)

```

```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()

```

```auto
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-58-685c10c0cfca> in <module>()
      4 #train
      5 for epochs in range(EPOCHS):
----> 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:
--> 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

```

---

<div class="post-metadata">

**Author:** ![akcaymert](https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/a/7c8e57/32.png) [@akcaymert](https://discuss.pytorch.org/u/akcaymert)\
**Post date:** [November 22, 2020, 9:23pm UTC](https://discuss.pytorch.org/t/input-type-is-not-supported-on-loop/103626/2 "2020-11-22T21:23:25Z")

</div>

i can fix by changing np.array not properly work np.asarray
