Dataset.from_pandas with a DataFrame of PIL.Images
COLLABORATOR
A duplicate of https://github.com/huggingface/datasets/issues/4796.

We could get this for free by implementing the `Image` feature as an extension type, as shown in [this](https://colab.research.google.com/drive/1Uzm_tXVpGTwbzleDConWcNjacwO1yxE4?usp=sharing) Colab (example with UUIDs).

2023-10-12T17:36:26Z
https://github.com/huggingface/datasets/issues/6288#issuecomment-1760062591
https://api.github.com/repos/huggingface/datasets/issues/6288
IC_kwDODunzps5o6Gx_
https://api.github.com/repos/huggingface/datasets/issues/comments/1760062591/reactions
2023-10-12T17:36:26Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1760062591
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
CONTRIBUTOR
+1 to this
Calling this line with a df that contains a PIL image (as they are returned from load_dataset)
`ds = Dataset.from_pandas(df)`
Results in this error:
`ArrowInvalid: ('Could not convert <PIL.PngImagePlugin.PngImageFile image mode=RGB size=1024x1024 at 0x2B41F2D70> with type PngImageFile: did not recognize Python value type when inferring an Arrow data type', 'Conversion failed for column image with type object')`
2023-10-20T18:23:05Z
https://github.com/huggingface/datasets/issues/6288#issuecomment-1773198378
https://api.github.com/repos/huggingface/datasets/issues/6288
IC_kwDODunzps5psNwq
https://api.github.com/repos/huggingface/datasets/issues/comments/1773198378/reactions
2023-10-20T18:23:05Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1773198378
https://avatars.githubusercontent.com/u/1981179?v=4
https://api.github.com/users/ZachNagengast/events{/privacy}
https://api.github.com/users/ZachNagengast/followers
https://api.github.com/users/ZachNagengast/following{/other_user}
https://api.github.com/users/ZachNagengast/gists{/gist_id}
https://github.com/ZachNagengast
ZachNagengast
MDQ6VXNlcjE5ODExNzk=
https://api.github.com/users/ZachNagengast/orgs
https://api.github.com/users/ZachNagengast/received_events
https://api.github.com/users/ZachNagengast/repos
https://api.github.com/users/ZachNagengast/starred{/owner}{/repo}
https://api.github.com/users/ZachNagengast/subscriptions
User
https://api.github.com/users/ZachNagengast
public
NONE
I found something that can be used as solution.

I have the same problem when I've try to load the images from a pamdas dataset

If you have all on a pandas dataset try 
Dataset.from_dict( your_df.reset_index(drop=True).to_dict(orient='list'), split=set_your_split)

And this avoid the error
2024-11-29T16:35:29Z
https://github.com/huggingface/datasets/issues/6288#issuecomment-2508125352
https://api.github.com/repos/huggingface/datasets/issues/6288
IC_kwDODunzps6VfvSo
https://api.github.com/repos/huggingface/datasets/issues/comments/2508125352/reactions
2024-11-29T16:35:29Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2508125352
https://avatars.githubusercontent.com/u/56119719?v=4
https://api.github.com/users/juanxo90/events{/privacy}
https://api.github.com/users/juanxo90/followers
https://api.github.com/users/juanxo90/following{/other_user}
https://api.github.com/users/juanxo90/gists{/gist_id}
https://github.com/juanxo90
juanxo90
MDQ6VXNlcjU2MTE5NzE5
https://api.github.com/users/juanxo90/orgs
https://api.github.com/users/juanxo90/received_events
https://api.github.com/users/juanxo90/repos
https://api.github.com/users/juanxo90/starred{/owner}{/repo}
https://api.github.com/users/juanxo90/subscriptions
User
https://api.github.com/users/juanxo90
public
Currently type inference doesn't know what to do with a Pandas Series of PIL.Image objects, though it would be nice to get a Dataset with the Image type this way