|
import datasets |
|
|
|
train0, validation0, test0 = datasets.load_dataset("superb", "ks", split=["train","validation","test"]) |
|
|
|
labels = train0.features["label"].names |
|
label2id = {x: labels.index(x) for x in labels} |
|
id2label = {str(id): label for label, id in label2id.items()} |
|
|
|
down_id = label2id['down'] |
|
on_id = label2id['on'] |
|
|
|
|
|
train1 = train0.filter(lambda example: example['label'] == down_id or example['label'] == on_id) |
|
|
|
|
|
validation1 = validation0.filter(lambda example: example['label'] == down_id or example['label'] == on_id) |
|
|
|
test1 = test0.filter(lambda example: example['label'] == down_id or example['label'] == on_id) |
|
|
|
train1.to_csv('/home/mr249/ac_h/do1/tmp/train1.csv') |
|
validation1.to_csv('/home/mr249/ac_h/do1/tmp/validation1.csv') |
|
test1.to_csv('/home/mr249/ac_h/do1/tmp/test1.csv') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
train2 = datasets.Dataset.from_csv('/home/mr249/ac_h/do1/train.csv','train') |
|
validation2 = datasets.Dataset.from_csv('/home/mr249/ac_h/do1/validation.csv','validation') |
|
test2 = datasets.Dataset.from_csv('/home/mr249/ac_h/do1/test.csv','test') |
|
|
|
|
|
|
|
|
|
|
|
|
|
new_features = train2.features.copy() |
|
new_features["label"] = datasets.ClassLabel(names=['down', 'on'],id=None) |
|
train2 = train2.cast(new_features) |
|
validation2 = validation2.cast(new_features) |
|
test2 = test2.cast(new_features) |
|
|
|
|
|
down_on = datasets.DatasetDict({ |
|
"train": train2, |
|
"validation": validation2, |
|
"test": test2, |
|
}) |
|
|
|
|
|
down_on.save_to_disk('/home/mr249/ac_h/down_on') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from huggingface_hub import login |
|
login() |
|
|
|
down_on.push_to_hub("MatsRooth/down_on",private=False,embed_external_files=True) |
|
|
|
|
|
train3 = load_dataset("MatsRooth/down_on", split="train") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|