Download upload.py from pratikstar/doesitchug: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/datasets/pratikstar/doesitchug/resolve/main/upload.py
- Command line
-
hf download hf://datasets/pratikstar/doesitchug/upload.py
-
curl -L -o upload.py https://huggingface.co/datasets/pratikstar/doesitchug/resolve/main/upload.py
1.07 kB
| from huggingface_hub import login | |
| import pandas as pd | |
| from datasets import Dataset, Audio, Sequence, Value | |
| import ast | |
| # login() # This will ask for your token, which you can get from https://huggingface.co/settings/tokens | |
| repo_id = "pratikstar/doesitchug" # Replace 'your-username' with your Hugging Face username | |
| # Load the CSV file | |
| file_path = "./updated_timbre_dataset.csv" | |
| df = pd.read_csv(file_path) | |
| df['Label-Annotations'] = df['Label-Annotations'].apply(lambda x: ast.literal_eval(x) if isinstance(x, str) else x) | |
| print(len(df)) | |
| print(df["Clip-A"][0]) | |
| # print(df["Clip A"]) | |
| # Convert the pandas DataFrame to a Hugging Face Dataset | |
| hf_dataset = Dataset.from_pandas(df) | |
| # Specify that 'clip_a' and 'clip_b' columns are audio columns | |
| hf_dataset = hf_dataset.cast_column("Clip-A", Audio(sampling_rate=44100)) | |
| hf_dataset = hf_dataset.cast_column("Clip-B", Audio(sampling_rate=44100)) | |
| hf_dataset = hf_dataset.cast_column("Label-Annotations", Sequence(Value(dtype='string'))) | |
| print(hf_dataset[0]) | |
| # Push the dataset to the Hub | |
| hf_dataset.push_to_hub(repo_id) | |