Update README.md
Browse files
README.md
CHANGED
|
@@ -41,7 +41,7 @@ def image_to_indices(image, vq):
|
|
| 41 |
|
| 42 |
return indices, norm
|
| 43 |
|
| 44 |
-
def
|
| 45 |
b = indices.shape[0]
|
| 46 |
w = int(indices.shape[-1] ** 0.5)
|
| 47 |
v = vq.quantize.embedding(indices)
|
|
@@ -61,7 +61,7 @@ if __name__ == '__main__':
|
|
| 61 |
# Encode image.
|
| 62 |
ids, _ = image_to_indices(image, vq)
|
| 63 |
# Decode by integer ids.
|
| 64 |
-
pixel_values =
|
| 65 |
preview = transforms.functional.to_pil_image(pixel_values.detach().squeeze(0).to('cpu'))
|
| 66 |
```
|
| 67 |
|
|
|
|
| 41 |
|
| 42 |
return indices, norm
|
| 43 |
|
| 44 |
+
def indices_to_tensor(indices, vq, ada: AdaLayerNorm):
|
| 45 |
b = indices.shape[0]
|
| 46 |
w = int(indices.shape[-1] ** 0.5)
|
| 47 |
v = vq.quantize.embedding(indices)
|
|
|
|
| 61 |
# Encode image.
|
| 62 |
ids, _ = image_to_indices(image, vq)
|
| 63 |
# Decode by integer ids.
|
| 64 |
+
pixel_values = indices_to_tensor(ids, vq, ada) / 2.0 + 0.5
|
| 65 |
preview = transforms.functional.to_pil_image(pixel_values.detach().squeeze(0).to('cpu'))
|
| 66 |
```
|
| 67 |
|