Let’s say you have a dataset on the hub, containing some images:
from datasets import load_dataset
dataset = load_dataset("hf-internal-testing/example-documents")
How can I add a new image to it?
I tried:
from PIL import Image
image = Image.open("/content/cord_example.png").convert("RGB")
new_image = {'image': image}
dataset['test'] = dataset['test'].add_item(new_image)
but this fails with:
ArrowInvalid: Could not convert <PIL.Image.Image image mode=RGB size=576x864 at 0x7F7CCC4589D0> with type Image: did not recognize Python value type when inferring an Arrow data type