Datasets:
Update README.md
Browse files
README.md
CHANGED
@@ -75,30 +75,29 @@ img2dataset을 통해 다운로드에 성공한 [Bingsu/laion2B-multi-korean-sub
|
|
75 |
|
76 |
```python
|
77 |
import io
|
|
|
78 |
from PIL import Image
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
yield data
|
94 |
```
|
95 |
|
96 |
```python
|
97 |
-
>>>
|
98 |
-
|
99 |
-
|
100 |
-
'
|
101 |
-
'width': 455,
|
102 |
'height': 256}
|
103 |
```
|
104 |
|
|
|
75 |
|
76 |
```python
|
77 |
import io
|
78 |
+
import webdataset as wds
|
79 |
from PIL import Image
|
80 |
+
|
81 |
+
def preprocess(data):
|
82 |
+
webp, jsn = data
|
83 |
+
img = Image.open(io.BytesIO(webp))
|
84 |
+
out = {
|
85 |
+
"image": img,
|
86 |
+
"text": jsn["caption"],
|
87 |
+
"width": jsn["width"],
|
88 |
+
"height": jsn["height"]
|
89 |
+
}
|
90 |
+
return out
|
91 |
+
|
92 |
+
url = "https://huggingface.co/datasets/Bingsu/laion2b_multi_korean_subset_with_image/resolve/main/data/{00000..02122}.tar"
|
93 |
+
dataset = wds.WebDataset(url).shuffle(1000).decode("pil").to_tuple("webp", "json").map(preprocess)
|
|
|
94 |
```
|
95 |
|
96 |
```python
|
97 |
+
>>> next(iter(dataset))
|
98 |
+
{'image': <PIL.WebPImagePlugin.WebPImageFile image mode=RGB size=427x256>,
|
99 |
+
'text': '[따블리에]유아동 미술가운, 미술 전신복',
|
100 |
+
'width': 427,
|
|
|
101 |
'height': 256}
|
102 |
```
|
103 |
|