Problem during the training with the parameter train_dataset. (Dict/Tensor problem)
Author: dgrnd4
Pull request: no

Hi there, I'm following the [tutorial](https://huggingface.co/blog/fine-tune-vit), trying to fine-tune the net on Stanford Dog Dataset.

I am facing this problem: once that I try to do `trainer.train()`
this error appear:
```/usr/local/lib/python3.7/dist-packages/transformers/optimization.py:310: FutureWarning: This implementation of AdamW is deprecated and will be removed in a future version. Use the PyTorch implementation torch.optim.AdamW instead, or set `no_deprecation_warning=True` to disable this warning
  FutureWarning,
 ---Running training 
  Num examples = 4160
  Num Epochs = 4
  Instantaneous batch size per device = 16
  Total train batch size (w. parallel, distributed & accumulation) = 16
  Gradient Accumulation steps = 1
  Total optimization steps = 1040
ValueError                                Traceback (most recent call last)
[<ipython-input-32-0f10542a3dd8>](https://86s6jsm55e-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20220615-060045-RC00_455067423#) in <module>()
      1 # RESULTS
      2 
----> 3 train_results = trainer.train()
      4 trainer.save_model()
      5 trainer.log_metrics("train", train_results.metrics)
13 frames
[/usr/local/lib/python3.7/dist-packages/transformers/models/vit/feature_extraction_vit.py](https://86s6jsm55e-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20220615-060045-RC00_455067423#) in __call__(self, images, return_tensors, **kwargs)
    125         if not valid_images:
    126             raise ValueError(
--> 127                 "Images must of type `PIL.Image.Image`, `np.ndarray` or `torch.Tensor` (single example), "
    128                 "`List[PIL.Image.Image]`, `List[np.ndarray]` or `List[torch.Tensor]` (batch of examples)."
    129             ) ```

The error is the following:
**```ValueError: Images must of type `PIL.Image.Image`, `np.ndarray` or `torch.Tensor` (single example), `List[PIL.Image.Image]`, `List[np.ndarray]` or `List[torch.Tensor]` (batch of examples).```**

I think that the problem is on the definition of dataset['train'] that isn't an iterable or something like that: do you have any recommendation? I tried literally every kind of change of type but still cannot train it!!!

The dataset that I have are np.array with dim (256,256,3) that I'm processing with:
``` def transform(arr_x=x_te, arr_y=y_te):
  inputs = extractor([x for x in arr_x], return_tensors='pt')
  inputs['labels'] = [y for y in arr_y]
  return inputs # <class 'transformers.feature_extraction_utils.BatchFeature'>
```

After that I create:
```
dd = datasets.DatasetDict({"train": Dataset.from_dict({'pixel_values': arr_transf_te['pixel_values'], 'labels':arr_transf_te['labels'] })})
```

And then I do the transform:
```
dataset = dd.with_transform(transform)
```

Once I try to:
```
trainer = Trainer(
    model=model,
    args=training_args,
    data_collator=collate_fn,
    compute_metrics=compute_metrics,
    train_dataset = dataset['train'] , # type datasets.arrow_dataset.Dataset
    tokenizer = extractor,
)
```

In:
```
train_results = trainer.train()
```
I get the error that I show you above

This is my [project](https://colab.research.google.com/drive/1CueCyVjyh6sRJF2gcs0WdF0u33rtzmLI?usp=sharing): if you can look at it would be AMAZING!

Comments:
@NielsRogge have you seen this error? This comes from the ViT fine-tuning tutorial.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.