Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compressed binary file size #6

Open
koda-11 opened this issue Jul 27, 2022 · 7 comments
Open

Compressed binary file size #6

koda-11 opened this issue Jul 27, 2022 · 7 comments

Comments

@koda-11
Copy link

koda-11 commented Jul 27, 2022

Hi,
I tried to compress one image file by your pre-trained model.
But the binary file size is same (2.9M) on different lambda model (entroformer_lambda0.1.pth, entroformer_lambda0.01.pth)
I expected to get different binary file size.
It should be the binary file size which is from "entroformer_lambda0.01.pth" model smaller than "entroformer_lambda0.1.pth"
Am i miss something..?

thank you

@mx54039q
Copy link
Collaborator

mx54039q commented Jul 27, 2022 via email

@mlkk518
Copy link

mlkk518 commented Nov 10, 2023

你好,我也遇到同样的问题,原始图像593K, 压缩获得的 .bin 文件大小竟然为1.13M, 麻烦请教下,这个是什么原因呢?

@MY3360
Copy link

MY3360 commented Nov 23, 2023

你好,我也遇到同样的问题,原始图像593K, 压缩获得的 .bin 文件大小竟然为1.13M, 麻烦请教下,这个是什么原因呢?

我也发生类似情况。但是我认为可能是使用的图片本身就已经被压缩过。您可以查看一下您的图片分辨率和位深大小,计算一下是否与您图片的存储大小对的上。一般存储大小都远小于理论计算得到的大小,说明已经是被压缩过的。而程序里读入图像的数据大小仍旧为分辨率乘以位深。

@mlkk518
Copy link

mlkk518 commented Nov 23, 2023 via email

@mx54039q
Copy link
Collaborator

不好意思, 这个问题因为错误信息不足, 当时没有及时回答, 后来因为工作太忙忘记了.

  1. 关于压缩得到的.bin文件比原始图像文件大. 如MY3360所说, 可能是你的原始图像已经是压缩格式了 (比如.jpg), 并且压缩率很高; 我们的算法仍会将这个图像按原图进行压缩, 然后用相应的压缩率的模型来压缩; 所以确认一下你的原始图像文件是否为PNG这样的无损格式.
  2. 关于不同压缩模型的输出都是同一个size. 我在测试时没有遇到过这样的情况, 我猜测可能的原因 a) 代码环境不一致问题, 导致模型对不同图片都是同样的输出 (之前有其他人出现过torch版本不一致导致的问题). b) 熵编码问题导致了数值的溢出, 熵编码的代码我是沿用了别人的代码, 在我本地跑是没有问题的, 你可以check一下这个部分.

Sorry, I didn't answer this question in time and forgot it because I was too busy at work.

Regarding the problem that the output of different compression models are all of the same size, I have not encountered such a situation before. One possible reason is the inconsistent environment (e.g. torch version, someone has mentioned this before), which causes the model to output the same size for different images. b) The entropy encoding module caused the overflow of values. I followed 'torchac' for the entropy encoding code. You may check this part.

Sorry again.

@MY3360
Copy link

MY3360 commented Nov 26, 2023

程序里计算bpp 应该是读取.bin文件的大小,然后除总像素数。 与图像压缩应该没关系吧。十分感谢您的来信,期待交流。


---- 回复的原邮件 ----
发件人 <a class="mail-from" style="color: #1c83eb; text-decoration: none" @." >@.>
日期 2023年11月23日 19:38
收件人 <a class="mail-to" style="color: #1c83eb; text-decoration: none" @." >@.>
抄送至 <a class="mail-cc" style="color: #1c83eb; text-decoration: none" @." >@.>、<a class="mail-cc" style="color: #1c83eb; text-decoration: none" @." >@.>
主题 Re: [damo-cv/entroformer] Compressed binary file size (Issue #6)

你好,我也遇到同样的问题,原始图像593K, 压缩获得的 .bin 文件大小竟然为1.13M, 麻烦请教下,这个是什么原因呢?

我也发生类似情况。但是我认为可能是使用的图片本身就已经被压缩过。您可以查看一下您的图片分辨率和位深大小,计算一下是否与您图片的存储大小对的上。一般存储大小都远小于理论计算得到的大小,说明已经是被压缩过的。而程序里读入图像的数据大小仍旧为分辨率乘以位深。


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: </issues/6/1824275556@github.com>

<script type="application/ld+json">[ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "#6 (comment)", "url": "#6 (comment)", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.": "Organization", "name": "GitHub", "url": "https://github.com" } } ]</script>

感谢作者的回复。我目前的环境是python3.9.16,torch1.10.1。在调试熵编码部分时,发现在计算pmf_y_logit时,distribution_mixture.py中的class DiscretizedMixDistribution下out_A输出tensor全为-inf。我将原代码out_A = torch.log(torch.clamp(cdf_delta, min=1e-12))修改为out_A = torch.log(torch.clamp(cdf_delta.float(), min=1e-12))后,输出码流文件大小似乎变正常了。具体是否正确还需要确认。

@mlkk518
Copy link

mlkk518 commented Nov 29, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants