Upload folder using huggingface_hub
Browse files
plpq.py
CHANGED
|
@@ -83,9 +83,9 @@ class PLPQ(PreTrainedModel):
|
|
| 83 |
"""
|
| 84 |
Quantize the input tensor
|
| 85 |
Parameters:
|
| 86 |
-
x (
|
| 87 |
Returns:
|
| 88 |
-
torch.Tensor: The indices tensor
|
| 89 |
"""
|
| 90 |
z = self.encoder(x).permute(0, 2, 3, 1).contiguous()
|
| 91 |
b, h, w, c = z.shape
|
|
@@ -97,10 +97,11 @@ class PLPQ(PreTrainedModel):
|
|
| 97 |
@torch.no_grad()
|
| 98 |
def decode(self, indices: torch.Tensor) -> torch.Tensor:
|
| 99 |
"""
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
| 104 |
"""
|
| 105 |
|
| 106 |
ncodes = indices.shape[-1]
|
|
|
|
| 83 |
"""
|
| 84 |
Quantize the input tensor
|
| 85 |
Parameters:
|
| 86 |
+
x (torch.Tensor): The input tensor of shape (b, c, h, w)
|
| 87 |
Returns:
|
| 88 |
+
torch.Tensor: The indices tensor of shape (b, t, n_quantizers)
|
| 89 |
"""
|
| 90 |
z = self.encoder(x).permute(0, 2, 3, 1).contiguous()
|
| 91 |
b, h, w, c = z.shape
|
|
|
|
| 97 |
@torch.no_grad()
|
| 98 |
def decode(self, indices: torch.Tensor) -> torch.Tensor:
|
| 99 |
"""
|
| 100 |
+
Decode a tensor, inverse of self.quantize
|
| 101 |
+
Parameters:
|
| 102 |
+
indices (torch.Tensor): The input codes of shape (b, t, n_quantizers)
|
| 103 |
+
Returns:
|
| 104 |
+
torch.Tensor: The decoded tensor of shape (b, c, h, w)
|
| 105 |
"""
|
| 106 |
|
| 107 |
ncodes = indices.shape[-1]
|