CompressAI icon indicating copy to clipboard operation
CompressAI copied to clipboard

Does CompressAI support direct compression of [y] instead of [y-mean]?

Open zhengxinChenee opened this issue 9 months ago • 3 comments

As stated, how can we use CompressAI to compress [y] instead of [y-mean]. Furthermore, how can we understand the advantages of compressing [y-mean]? Thank you very much for your answer!!!

zhengxinChenee avatar Nov 22 '23 08:11 zhengxinChenee

round(y-means) == round(y) if means = 0. (Or means == None works too.)

For example, just set means=None when using the desired entropy model:

        y_hat, y_likelihoods = self.gaussian_conditional(y, scales_hat, means=None)

In terms of advantages, that depends on the situation. If the source y has its most-likely-value occurring exactly at the mean, then [y - mean] will probably produce less reconstruction error since we can then reconstruct the most-likely-value with exact precision. On the other hand, if the actual values occur at locations other than the mean, then both methods will produce similar results. So... it depends.

See here for an example: https://github.com/InterDigitalInc/CompressAI/discussions/227#discussioncomment-5654273


Somewhat related concept: the deadzone quantizer used by JPEG allows near-zero DCT-transformed-and-rescaled coefficients to be rounded to zero, which helps reduce the rate since the most-likely-symbols are near zero, and reconstructing them as zero is worth the R-D tradeoff.

deadzone (Deadzone quantizer on the left. Lloyd-Max quantizer on the right.)

YodaEmbedding avatar Nov 22 '23 12:11 YodaEmbedding

Great answer! Thanks a lot! In general, compressing [y-mean] achieves better R-D tradeoff. However, in some cases, we have to compress [y] whose mean is not none. For example, in Checkerboard Context Model, we should compress [y] for one-pass encoding, and compressing [y-mean] leads to two-pass encoding. Can you make some suggestions for AE/AD of [y] using CompressAI?Thank you very much for your answer!!!

zhengxinChenee avatar Nov 22 '23 13:11 zhengxinChenee

As stated, how can we use CompressAI to compress [y] instead of [y-mean]. Furthermore, how can we understand the advantages of compressing [y-mean]? Thank you very much for your answer!!!

Hello, I would like to ask you a question about the installation of compressai “Successfully installed compressai-1.2.4.dev0” . I successfully installed cmpressai, but I got the following error when importing:

import compressai Traceback (most recent call last): File "", line 1, in File "F:\compressai\compressai_init_.py", line 30, in from compressai import ( File "F:\compressai\compressai\latent_codecs_init_.py", line 38, in from .rasterscan import RasterScanLatentCodec File "F:\compressai\compressai\latent_codecs\rasterscan.py", line 38, in from compressai.ans import BufferedRansEncoder, RansDecoder ImportError: DLL load failed while importing ans: 找不到指定的程序。

WenBingo avatar Feb 27 '24 03:02 WenBingo