I use the code below and i dont understand how does "quality" control compress ratio.
from compressai.zoo import bmshj2018_factorized
self.codec = bmshj2018_factorized(quality=4, metric='mse', pretrained=True, progress=True)
@register_model("bmshj2018-factorized")
class FactorizedPrior(CompressionModel):
r"""Factorized Prior model from J. Balle, D. Minnen, S. Singh, S.J. Hwang,
N. Johnston: `"Variational Image Compression with a Scale Hyperprior"
<https://arxiv.org/abs/1802.01436>`_, Int Conf. on Learning Representations
(ICLR), 2018.
.. code-block:: none
┌───┐ y
x ──►─┤g_a├──►─┐
└───┘ │
▼
┌─┴─┐
│ Q │
└─┬─┘
│
y_hat ▼
│
·
EB :
·
│
y_hat ▼
│
┌───┐ │
x_hat ──◄─┤g_s├────┘
└───┘
EB = Entropy bottleneck
Args:
N (int): Number of channels
M (int): Number of channels in the expansion layers (last layer of the
encoder and last layer of the hyperprior decoder)
"""
def __init__(self, N, M, **kwargs):
super().__init__(**kwargs)
self.entropy_bottleneck = EntropyBottleneck(M)
print(N, M)
self.g_a = nn.Sequential(
conv(3, N),
GDN(N),
conv(N, N),
GDN(N),
conv(N, N),
GDN(N),
conv(N, M),
)
self.g_s = nn.Sequential(
deconv(M, N),
GDN(N, inverse=True),
deconv(N, N),
GDN(N, inverse=True),
deconv(N, N),
GDN(N, inverse=True),
deconv(N, 3),
)
self.N = N
self.M = M
Different level of "quality" has the same framework (conv channel, qualitize, entropy bottleneck etc..).
The only thought in my head is that the conv weight is more rough with the smaller "quality", so the input of entropy_bottleneck is seem to be flatter, thus, the result of arithmetic coding has changed.
I use the code below and i dont understand how does "quality" control compress ratio.
Different level of "quality" has the same framework (conv channel, qualitize, entropy bottleneck etc..).
The only thought in my head is that the conv weight is more rough with the smaller "quality", so the input of entropy_bottleneck is seem to be flatter, thus, the result of arithmetic coding has changed.