set_format("np") no longer works for Image data
NONE
A quick fix for now is doing this:

```python
X_train = np.stack(dataset["train"]["image"])[..., None]
2022-01-09T17:37:14Z
https://github.com/huggingface/datasets/issues/3553#issuecomment-1008342038
https://api.github.com/repos/huggingface/datasets/issues/3553
IC_kwDODunzps48GhQW
https://api.github.com/repos/huggingface/datasets/issues/comments/1008342038/reactions
2022-01-09T17:37:14Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1008342038
https://avatars.githubusercontent.com/u/5862228?v=4
https://api.github.com/users/cgarciae/events{/privacy}
https://api.github.com/users/cgarciae/followers
https://api.github.com/users/cgarciae/following{/other_user}
https://api.github.com/users/cgarciae/gists{/gist_id}
https://github.com/cgarciae
cgarciae
MDQ6VXNlcjU4NjIyMjg=
https://api.github.com/users/cgarciae/orgs
https://api.github.com/users/cgarciae/received_events
https://api.github.com/users/cgarciae/repos
https://api.github.com/users/cgarciae/starred{/owner}{/repo}
https://api.github.com/users/cgarciae/subscriptions
User
https://api.github.com/users/cgarciae
public
NONE
This error also propagates to jax and is even trickier to fix, since `.with_format(type='jax')` will use numpy conversion internally (and fail). For a three line failure:

```python
dataset = datasets.load_dataset("mnist")
dataset.set_format("jax")
X_train = dataset["train"]["image"]
```
2022-01-11T15:59:33Z
https://github.com/huggingface/datasets/issues/3553#issuecomment-1010106376
https://api.github.com/repos/huggingface/datasets/issues/3553
IC_kwDODunzps48NQAI
https://api.github.com/repos/huggingface/datasets/issues/comments/1010106376/reactions
2022-01-11T16:04:10Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1010106376
https://avatars.githubusercontent.com/u/1962818?v=4
https://api.github.com/users/andreaferretti/events{/privacy}
https://api.github.com/users/andreaferretti/followers
https://api.github.com/users/andreaferretti/following{/other_user}
https://api.github.com/users/andreaferretti/gists{/gist_id}
https://github.com/andreaferretti
andreaferretti
MDQ6VXNlcjE5NjI4MTg=
https://api.github.com/users/andreaferretti/orgs
https://api.github.com/users/andreaferretti/received_events
https://api.github.com/users/andreaferretti/repos
https://api.github.com/users/andreaferretti/starred{/owner}{/repo}
https://api.github.com/users/andreaferretti/subscriptions
User
https://api.github.com/users/andreaferretti
public
COLLABORATOR
Hi! We've recently introduced a new Image feature that yields PIL Images (and caches transforms on them) instead of arrays.

However, this feature requires a custom transform to yield np arrays directly:
```python
ddict = datasets.load_dataset("mnist")

def pil_image_to_array(batch):
     return {"image": [np.array(img) for img in batch["image"]]}  # or jnp.array(img) for Jax

ddict.set_transform(pil_image_to_array, columns="image", output_all_columns=True)
```

[Docs](https://huggingface.co/docs/datasets/master/process.html#format-transform) on `set_transform`.

Also, the approach proposed by @cgarciae is not the best because it loads the entire column in memory.

@albertvillanova @lhoestq WDYT? The Audio and the Image feature currently don't support the TF/Jax/PT Formatters, but for the Numpy Formatter maybe it makes more sense to return np arrays (and not a dict in the case of the Audio feature or a PIL Image object in the case of the Image feature).
2022-01-11T18:09:06Z
https://github.com/huggingface/datasets/issues/3553#issuecomment-1010227945
https://api.github.com/repos/huggingface/datasets/issues/3553
IC_kwDODunzps48Ntrp
https://api.github.com/repos/huggingface/datasets/issues/comments/1010227945/reactions
2022-01-11T18:12:28Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1010227945
https://avatars.githubusercontent.com/u/47462742?v=4
https://api.github.com/users/mariosasko/events{/privacy}
https://api.github.com/users/mariosasko/followers
https://api.github.com/users/mariosasko/following{/other_user}
https://api.github.com/users/mariosasko/gists{/gist_id}
https://github.com/mariosasko
mariosasko
MDQ6VXNlcjQ3NDYyNzQy
https://api.github.com/users/mariosasko/orgs
https://api.github.com/users/mariosasko/received_events
https://api.github.com/users/mariosasko/repos
https://api.github.com/users/mariosasko/starred{/owner}{/repo}
https://api.github.com/users/mariosasko/subscriptions
User
https://api.github.com/users/mariosasko
public
MEMBER
Yes I agree it should return arrays and not a PIL image (and possible an array instead of a dict for audio data).
I'm currently finishing some code refactoring of the image and audio and opening a PR today. Maybe we can look into that after the refactoring
2022-01-13T13:39:26Z
https://github.com/huggingface/datasets/issues/3553#issuecomment-1012145521
https://api.github.com/repos/huggingface/datasets/issues/3553
IC_kwDODunzps48VB1x
https://api.github.com/repos/huggingface/datasets/issues/comments/1012145521/reactions
2022-01-13T13:39:26Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1012145521
https://avatars.githubusercontent.com/u/42851186?v=4
https://api.github.com/users/lhoestq/events{/privacy}
https://api.github.com/users/lhoestq/followers
https://api.github.com/users/lhoestq/following{/other_user}
https://api.github.com/users/lhoestq/gists{/gist_id}
https://github.com/lhoestq
lhoestq
MDQ6VXNlcjQyODUxMTg2
https://api.github.com/users/lhoestq/orgs
https://api.github.com/users/lhoestq/received_events
https://api.github.com/users/lhoestq/repos
https://api.github.com/users/lhoestq/starred{/owner}{/repo}
https://api.github.com/users/lhoestq/subscriptions
User
https://api.github.com/users/lhoestq
public
COLLABORATOR
This has been fixed in https://github.com/huggingface/datasets/pull/5072, which is included in the latest release of `datasets`.
2022-10-14T12:03:54Z
https://github.com/huggingface/datasets/issues/3553#issuecomment-1278915364
https://api.github.com/repos/huggingface/datasets/issues/3553
IC_kwDODunzps5MOrMk
https://api.github.com/repos/huggingface/datasets/issues/comments/1278915364/reactions
2022-10-14T12:03:54Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1278915364
https://avatars.githubusercontent.com/u/47462742?v=4
https://api.github.com/users/mariosasko/events{/privacy}
https://api.github.com/users/mariosasko/followers
https://api.github.com/users/mariosasko/following{/other_user}
https://api.github.com/users/mariosasko/gists{/gist_id}
https://github.com/mariosasko
mariosasko
MDQ6VXNlcjQ3NDYyNzQy
https://api.github.com/users/mariosasko/orgs
https://api.github.com/users/mariosasko/received_events
https://api.github.com/users/mariosasko/repos
https://api.github.com/users/mariosasko/starred{/owner}{/repo}
https://api.github.com/users/mariosasko/subscriptions
User
https://api.github.com/users/mariosasko
public
## Describe the bug
`dataset.set_format("np")` no longer works for image data, previously you could load the MNIST like this:

```python
dataset = load_dataset("mnist")
dataset.set_format("np")
X_train = dataset["train"]["image"][..., None] # <== No longer a numpy array
```
but now it doesn't work, `set_format("np")` seems to have no effect and the dataset just returns a list/array of PIL images instead of numpy arrays as requested.
