|
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 |
|
|
|
|
|
|
|
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", token="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") |
|
|
|
if __name__ == "__main__": |
|
main() |