Datasets:
File size: 940 Bytes
8e3b45d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import datasets
from datasets import Dataset
import sys
import os
from pathlib import Path
from tqdm import tqdm
from PIL import Image
from collections import defaultdict
#for i in *.svg; do rsvg-convert -w 768 -h 768 "${i}" -o "${i%svg}png"; done
def main():
files = list(Path('png768/').rglob("*.png"))
data = defaultdict(list)
print("Loading dataset...")
for file in tqdm(files):
emoji_name = file.stem.replace("_"," ").replace("-"," ").replace("medium", "")
data['text'].append(emoji_name)
image = Image.open(str(file))
data['image'].append(image)
dataset = Dataset.from_dict(data)
print("Dataset loaded.")
print(dataset)
print(dataset[0])
print(dataset[42])
dataset.save_to_disk("microsoft-fluentui-emoji-768")
print("Dataset saved to disk.")
dataset.push_to_hub("Norod78/microsoft-fluentui-emoji-768")
if __name__ == "__main__":
main() |