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 -b white -w 512 -h 512 "${i}" -o "${i%svg}jpg"; done def main(): files = list(Path('jpg512/').rglob("*.jpg")) 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-512-whitebg") print("Dataset saved to disk.") dataset.push_to_hub("Norod78/microsoft-fluentui-emoji-512-whitebg") if __name__ == "__main__": main()