Created
October 9, 2023 06:15
-
-
Save alfredplpl/c13296fb2ceaf84a31a15f9599b90fd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datasets import load_dataset | |
import requests | |
from PIL import Image | |
from tqdm import tqdm | |
dataset = load_dataset("laion/dalle-3-dataset",split="train") | |
for i,row in enumerate(tqdm(dataset)): | |
with open(f"dalle3/{i:06}.txt","w") as f: | |
f.write(row["caption"]) | |
img_url = row["link"] | |
raw_image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB') | |
raw_image.save(f"dalle3/{i:06}.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to save the images with more compression, change the code: