Description
System Info
transformers == 4.46.1
Who can help?
No response
Information
- The official example scripts
- My own modified scripts
Tasks
- An officially supported task in the
examples
folder (such as GLUE/SQuAD, ...) - My own task or dataset (give details below)
Reproduction
I pretrained custom EnCodec model of my own and trying to convert it to huggingface model format
I used a different codebook size in my custom EnCodec model such as 4096 or 8192 (the default is 1024)
Here is the problem :
The user can change the codebook size in EncodecConfig by passing the argument.
When the num_quantizer is calculated however, the codebook size is fixed to default value 1024.
transformers/src/transformers/models/encodec/configuration_encodec.py
Lines 187 to 189 in bc598c0
Here, 10 multiplied with self.frame_rate, which stands for the number of bit consumed by the codebook size, is fixed.
Expected behavior
num_quantizer should accept variable codebook size since we can already change the codebook size in argument.
Here is the modified code based on official implementation.
@property
def num_quantizers(self) -> int:
return int(max(1, math.floor(self.target_bandwidths[-1] * 1000 / self.frame_rate * math.log2(self.codebook_size))))
Activity