Datasets:

ArXiv:
cloneofsimo commited on
Commit
eae87d2
1 Parent(s): 57ac608

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -14
README.md CHANGED
@@ -3,7 +3,7 @@ size_categories:
3
  - 1M<n<10M
4
  viewer: false
5
  ---
6
- # Imagenet.int8: Entire Imagenet dataset in 5GB.
7
 
8
  <p align="center">
9
  <img src="contents/vae.png" alt="small" width="800">
@@ -36,31 +36,36 @@ So clearly, it doesn't make sense to download entire Imagenet and process with V
36
  (BTW If you think you'll need higher precision, you can always further fine-tune your model on higher precision. But I doubt that.)
37
 
38
 
39
- # How to use?
40
 
41
- First download this.
42
 
43
  ```bash
44
- do huggingface-cli download --repo-type dataset cloneofsimo/imagenet.int8 --local-dir ./vae_mds
 
 
 
 
45
  ```
46
 
 
 
47
  Then, you need to install [streaming dataset](https://github.com/mosaicml/streaming) to use this. The dataset is MDS format.
48
 
49
  ```bash
50
  pip install mosaicml-streaming
51
  ```
52
 
53
- Then, you can use this dataset like this:
54
 
55
- ```python
56
 
 
57
  from streaming.base.format.mds.encodings import Encoding, _encodings
58
  import numpy as np
59
  from typing import Any
60
  import torch
61
  from streaming import StreamingDataset
62
- from diffusers.models import AutoencoderKL
63
- from diffusers.image_processor import VaeImageProcessor
64
 
65
  class uint8(Encoding):
66
  def encode(self, obj: Any) -> bytes:
@@ -72,7 +77,6 @@ class uint8(Encoding):
72
 
73
  _encodings["uint8"] = uint8
74
 
75
-
76
  remote_train_dir = "./vae_mds" # this is the path you installed this dataset.
77
  local_train_dir = "./local_train_dir"
78
 
@@ -93,15 +97,18 @@ train_dataloader = torch.utils.data.DataLoader(
93
  )
94
  ```
95
 
96
- Thats the dataloader! Now, below is the example usage. Notice how you have to reshape as data is flattened.
97
 
98
- ```
99
- ###### Example Usage. Let's see if we can get the 5th image. BTW shuffle plz
 
 
 
 
100
 
101
  model = "stabilityai/your-stable-diffusion-model"
102
  vae = AutoencoderKL.from_pretrained("stabilityai/sdxl-vae").to("cuda:0")
103
 
104
-
105
  batch = next(iter(train_dataloader))
106
 
107
  i = 5
@@ -120,7 +127,9 @@ img.save("5th_image.png")
120
 
121
  Enjoy!
122
 
123
- # Citation
 
 
124
 
125
  ```bibtex
126
  @misc{imagenet_int8,
 
3
  - 1M<n<10M
4
  viewer: false
5
  ---
6
+ # Imagenet.int8: Entire Imagenet dataset in 5GB
7
 
8
  <p align="center">
9
  <img src="contents/vae.png" alt="small" width="800">
 
36
  (BTW If you think you'll need higher precision, you can always further fine-tune your model on higher precision. But I doubt that.)
37
 
38
 
39
+ # How do I use this?
40
 
41
+ First download this. You can use `huggingface-cli` for that.
42
 
43
  ```bash
44
+ # Pro tip : use `hf_transfer` to get faster download speed.
45
+ pip install hf_transfer
46
+ export HF_HUB_ENABLE_HF_TRANSFER=True
47
+ # actual download script.
48
+ huggingface-cli download --repo-type dataset cloneofsimo/imagenet.int8 --local-dir ./vae_mds
49
  ```
50
 
51
+
52
+
53
  Then, you need to install [streaming dataset](https://github.com/mosaicml/streaming) to use this. The dataset is MDS format.
54
 
55
  ```bash
56
  pip install mosaicml-streaming
57
  ```
58
 
59
+ Then, you can very simply use the dataset like this:
60
 
61
+ (for more info on using Mosaic's StreamingDataset and MDS format, [reference here](https://docs.mosaicml.com/projects/streaming/en/stable/index.html))
62
 
63
+ ```python
64
  from streaming.base.format.mds.encodings import Encoding, _encodings
65
  import numpy as np
66
  from typing import Any
67
  import torch
68
  from streaming import StreamingDataset
 
 
69
 
70
  class uint8(Encoding):
71
  def encode(self, obj: Any) -> bytes:
 
77
 
78
  _encodings["uint8"] = uint8
79
 
 
80
  remote_train_dir = "./vae_mds" # this is the path you installed this dataset.
81
  local_train_dir = "./local_train_dir"
82
 
 
97
  )
98
  ```
99
 
100
+ By default, batch will have three attributes: `vae_output`, `label`, `label_as_text`.
101
 
102
+ Thats the dataloader! Now, below is the example usage. Notice how you have to reshape the data back to `(B, 4, 32, 32)` as they are decoded flattened.
103
+
104
+ ```python
105
+ ###### Example Usage. Decode back the 5th image. BTW shuffle plz
106
+ from diffusers.models import AutoencoderKL
107
+ from diffusers.image_processor import VaeImageProcessor
108
 
109
  model = "stabilityai/your-stable-diffusion-model"
110
  vae = AutoencoderKL.from_pretrained("stabilityai/sdxl-vae").to("cuda:0")
111
 
 
112
  batch = next(iter(train_dataloader))
113
 
114
  i = 5
 
127
 
128
  Enjoy!
129
 
130
+ # Citations
131
+
132
+ If you find this material helpful, consider citation!
133
 
134
  ```bibtex
135
  @misc{imagenet_int8,