Datasets:

Modalities:
Image
Text
Formats:
webdataset
Libraries:
Datasets
WebDataset
License:

Converting Arrow to WebDataset TAR Format for Offline Use

#5
by katie312 - opened

Hi,

I've downloaded an Arrow-formatted dataset offline using the hugggingface's datasets library by:

import json
from datasets import load_dataset

dataset = load_dataset("pixparse/cc3m-wds")
dataset.save_to_disk("./cc3m_1") 

now I need to convert it to WebDataset's TAR format for offline data ingestion.
Is there a straightforward method to achieve this conversion without an internet connection? Can I simply convert it by

tar -cvf 

btw, when I tried:

import webdataset as wds
from huggingface_hub import get_token
from torch.utils.data import DataLoader

hf_token = get_token()
url = "https://huggingface.co/datasets/timm/imagenet-12k-wds/resolve/main/imagenet12k-train-{{0000..1023}}.tar"
url = f"pipe:curl -s -L {url} -H 'Authorization:Bearer {hf_token}'"
dataset = wds.WebDataset(url).decode()
dataset.save_to_disk("./cc3m_webdataset") 

error occured:

AttributeError: 'WebDataset' object has no attribute 'save_to_disk'

Thanks a lot!

Pixel Parsing org
edited 7 days ago

@katie312 you don't want to download in arrow format, the conversion would be possible but it'd be a bunch of custom work and verification. It's natively webdataset so it's best to download the original tar files.

Use the CLI w/ hf-transfer to download the raw dataset without using the datasets library:

pip install huggingface_hub hf-transfer
HF_TRANSFER=1 huggingface-cli download --repo-type dataset --local-dir /destination/folder pixparse/cc3m-wds

Thanks a lot! I completely forgot to use Hugging Face-CLI download. Thanks for the reminding!

katie312 changed discussion status to closed

Sign up or log in to comment