How to get sample_submission.csv when using hf datasets lib?

#9
by maraoz - opened

First time datasets lib user here , so excuse me if it's a newbie question.
I'm loading the dataset as described here: https://huggingface.co/datasets/competitions/aiornot

ds = load_dataset('competitions/aiornot', use_auth_token=access_token)
ds

outputs:

DatasetDict({
    train: Dataset({
        features: ['id', 'image', 'label'],
        num_rows: 18618
    })
    test: Dataset({
        features: ['id', 'image', 'label'],
        num_rows: 43442
    })
})

I can see the training and test data, but I'm not sure how to find the sample_submission.csvfile. Any help? Thanks in advance!

Competitions org

you cannot get it when using datasets lib. sample submission with all the raw data is stored in .extras folder

gotcha, thanks! maybe something like this could be added to the datasets lib:

ds = load_dataset('competitions/aiornot', extras=True)
ds.extras

or more generally:

ds = load_dataset('competitions/aiornot', download_metadata=True)

@maraoz you'd do it like this using the huggingface_hub package (comes installed with datasets, but if you don't have datasets, then just pip install huggingface_hub).

Make sure you're logged in with either huggingface_hub.notebook_login (if in notebook) or huggingface-cli login (if in terminal).

from huggingface_hub import hf_hub_download

file_path = hf_hub_download('competitions/aiornot', '.extras/sample_submission.csv', repo_type='dataset')

If you wanted to read this file into pandas, you'd treat file_path like any other path...

import pandas as pd

df = pd.read_csv(file_path)

Full screenshot of simple colab I just did for reference (its the same code as above)

Screen Shot 2023-02-02 at 12.56.48 PM.png

Sign up or log in to comment