将huggingface数据库图片转为普通文件保存

将huggingface数据库图片转为普通文件保存


from datasets import load_dataset
dataset = load_dataset("wtcherr/LAION10K", split="train")

for i in range(len(dataset)):
    img = dataset[i]['image']
    img.save(f"{i}.jpg")
    prompt = dataset[i]['prompt']    
    f = open(f"{i}.txt", "w")
    f.write(prompt)
    f.close()

你可能感兴趣的:(数据库)