Spaces:
Runtime error
Runtime error
Upload ./RepCodec/repcodec/modules/projector.py with huggingface_hub
Browse files
RepCodec/repcodec/modules/projector.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) ByteDance, Inc. and its affiliates.
|
| 2 |
+
# Copyright (c) Chutong Meng
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the CC BY-NC license found in the
|
| 5 |
+
# LICENSE file in the root directory of this source tree.
|
| 6 |
+
# Based on AudioDec (https://github.com/facebookresearch/AudioDec)
|
| 7 |
+
|
| 8 |
+
import torch.nn as nn
|
| 9 |
+
|
| 10 |
+
from repcodec.layers.conv_layer import Conv1d
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class Projector(nn.Module):
|
| 14 |
+
def __init__(
|
| 15 |
+
self,
|
| 16 |
+
input_channels: int,
|
| 17 |
+
code_dim: int,
|
| 18 |
+
kernel_size=3,
|
| 19 |
+
stride=1,
|
| 20 |
+
bias=False
|
| 21 |
+
):
|
| 22 |
+
super().__init__()
|
| 23 |
+
self.project = Conv1d(
|
| 24 |
+
input_channels,
|
| 25 |
+
code_dim,
|
| 26 |
+
kernel_size=kernel_size,
|
| 27 |
+
stride=stride,
|
| 28 |
+
bias=bias
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
def forward(self, x):
|
| 32 |
+
return self.project(x)
|