instructions
Browse files
README.md
CHANGED
@@ -1,3 +1,61 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
pretty_name: OpenAI guided-diffusion 256px class-conditional unguided samples (20 samples)
|
4 |
+
size_categories:
|
5 |
+
- n<1K
|
6 |
---
|
7 |
+
|
8 |
+
Read from the webdataset (after saving it somewhere on your disk) like this:
|
9 |
+
|
10 |
+
```python
|
11 |
+
from webdataset import WebDataset
|
12 |
+
from typing import TypedDict
|
13 |
+
from PIL import Image
|
14 |
+
from PIL.PngImagePlugin import PngImageFile
|
15 |
+
from io import BytesIO
|
16 |
+
from os import makedirs
|
17 |
+
|
18 |
+
Example = TypedDict('Example', {
|
19 |
+
'__key__': str,
|
20 |
+
'__url__': str,
|
21 |
+
'img.png': bytes,
|
22 |
+
})
|
23 |
+
|
24 |
+
dataset = WebDataset('./wds-dataset-viewer-test/{00000..00001}.tar')
|
25 |
+
|
26 |
+
out_root = 'out'
|
27 |
+
makedirs(out_root, exist_ok=True)
|
28 |
+
|
29 |
+
for ix, item in enumerate(dataset):
|
30 |
+
with BytesIO(item['img.png']) as stream:
|
31 |
+
img: PngImageFile = Image.open(stream)
|
32 |
+
img.load()
|
33 |
+
img.save(f'{out_root}/{ix}.png')
|
34 |
+
```
|
35 |
+
|
36 |
+
Or from the HF dataset like this:
|
37 |
+
|
38 |
+
```python
|
39 |
+
from datasets import load_dataset
|
40 |
+
from datasets.dataset_dict import DatasetDict
|
41 |
+
from datasets.arrow_dataset import Dataset
|
42 |
+
from PIL.PngImagePlugin import PngImageFile
|
43 |
+
from typing import TypedDict, Iterable
|
44 |
+
from os import makedirs
|
45 |
+
|
46 |
+
class Item(TypedDict):
|
47 |
+
index: int
|
48 |
+
tar: str
|
49 |
+
tar_path: str
|
50 |
+
img: PngImageFile
|
51 |
+
|
52 |
+
dataset: DatasetDict = load_dataset('Birchlabs/wds-dataset-viewer-test')
|
53 |
+
train: Dataset = dataset['train']
|
54 |
+
|
55 |
+
out_root = 'out'
|
56 |
+
makedirs(out_root, exist_ok=True)
|
57 |
+
|
58 |
+
it: Iterable[Item] = iter(train)
|
59 |
+
for item in it:
|
60 |
+
item['img'].save(f'{out_root}/{item["index"]}.png')
|
61 |
+
```
|