GithubHelp home page GithubHelp logo

No compression happened about l3c-pytorch HOT 35 CLOSED

fab-jul avatar fab-jul commented on August 25, 2024
No compression happened

from l3c-pytorch.

Comments (35)

fab-jul avatar fab-jul commented on August 25, 2024

What kind of images did you compress? The models are trained on natural images. And when you say 600-800KB, you mean the .l3c files generated with --write_to_file or the bpsp outputted by test.py?

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

Or are you using l3c.py?

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

After I update my gcc, I can run the codes now.
But I also find that when I run l3c.py on a .jpg file of the size 100kB, the out.l3c becomes to 850kB and the out.png becomes to 1.6M :P (the bpsp of output is great:2.68, but the file is so big...)
Then I tried larger pictures but it allocated more than 10G memory of GPU and it was been killed.
uh...I don't know if it is normal...

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

@BUAAHugeGun This is because it's a JPG, a lossy format :) So if you feed a .jpg to L3C you are asking it to compress the artefacts from JPG losslessly. The number you should care about is how L3C compares to PNG, which is also lossless.

Regarding the GPU: this is the problem of using CNNs. I think this could be optimized but I did not spend the time. If you have more RAM, you can also try the CPU version of torchac.

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

@fab-jul thanks a lot for your response. 👍
I made the mistake because I thought it could conpress any picture sRGB images.
thx

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

uh...I'm coming back here for your help.
Today I tried .png & .NEF files.
But I found that the output image(out.png) was full of blur and noise. :(
I used:
python l3c.py 'logs dir' 0524_0001 enc 'input dir' out.l3c
and
python l3c.py 'logs dir' 0524_0001 dec out.l3c out.png

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

the output will always be equal to the input. what kind of images are in input dir?

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

First I tried .jpg as I said. They were the same, Though the size of output is much larger than input.
Then I tried a .png image from Internet, a .png image from kodak test dataset, two .NEF images from the test dataset mentioned in your paper and got outputs of them which were full of noise and blur.
I'm sorry if this will trouble you. : (

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

Can you post one such .png that produces noise here?

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

kodim01

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

I just downloaded this image and ran it through L3C:

python l3c.py $RELEASED_CKPTS 0524_0001 enc ~/62377157-db349180-b574-11e9-851d-b79e5efc8067.png out.l3c
python l3c.py $RELEASED_CKPTS 0524_0001 dec out.l3c ~/decoded_github.png

And I get the same image back, as expected, i.e. decoded_github.png is exactly the same image I put in.

In theory, the code will always produce the same image. I'm really confused by what you get. Can you post the blurred result as well?

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

out

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

This is very unexpected. It looks very much like you are getting a sampled version of the image. Some questions:

  1. Are you putting in exactly the image you posted above? I.e. what happens when you download that image and feed it?
  2. Are you using the command you posted above? I.e. no --sample or anything?
  3. Are you on the latest git commit?

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

I'm sure about the 3 questions. And I tried some times again.
It is strange that I succeeded once using the image above.
And then it failed again.
I noticed that the size of out.l3c is constant, so I guess there is something wrong when using decoder?

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

...I downloaded the code again.
And then I installed torchac(GPU).
Now when I use a .jpg image, I also get a blurred image...

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

Maybe something with torchac is wrong. Can you try to run

python test.py /path/to/logdir 0524_0001 /some/imgdir --write_to_files=files_out_dir

because that runs multiscale_tester.py's _write_to_file which has an assert to check decoding works.

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

Alternatively, can you send out.l3c?

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

I sent a email to you. : )

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

Thanks! I’ll have a look. If you can, running the above command (the one with --write_to_files) would also be really helpful.

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

test

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

So, I just tried, and I get the same blurry output as you. I then went and compared the binary file you gave me to the one I get when I encode. They only match in the part that encodes the smallest bottleneck (which is encoded with a uniform prior). So, for some reason, your network must produce different probability distributions when encoding.

Now, I don't see how --write_to_files worked, because it should raise an assertion. I'm really not sure what's going on here. Are you encoding on GPU? If so, which GPU do you have? If you try with this file here, does it work, i.e., does --write_to_files work and does l3c.py work?

62377157-db349180-b574-11e9-851d-b79e5efc8067

from l3c-pytorch.

ChipsSpectre avatar ChipsSpectre commented on August 25, 2024

Hey
I have the same problem, tested it with the .png files from the CIFAR10 dataset like this car.
automobile4
I used this command to get the l3c:
python test.py ../ 0524_0001 ~/images/bar/ --names "L3C" --recursive=auto --write_to_files ~/images/foo/
and this command to decode it again:

python l3c.py ../ 0524_0001 dec ~/Bilder/foo/automobile4.l3c auto.png

yielding these blurs:

auto

When I use the command for encoding,

python l3c.py ../ 0524_0001 enc ~/images/bar/automobile4.png foo.l3c

I get the different blurs.
auto

The code is executed on NVIDIA RTX 2070, with the anaconda environment installed according to the repository, with torch 1.1.0

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

I‘ll check this out. Since it happens on CIFAR also, it most likely is not a memory issue

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

It is strange that when I first used l3c.py, the output was the same as the input, but when I found this problem, I tried the same input as the first one, the output changed to a blurred image.
And the only commit between the two tries was the modification of torchac...

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

Wait, are you saying that everything worked before that commit? Or are you not 100% sure?

Edit: Are you running both encoding and decoding on the CPU?

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

Uh, I just tried .jpg images on GPU before that commit and they were OK.
Round after the commit, I asked you why the output was larger than input when trying .jpg.
Then I edit the code of torchac as your description and run it on .png images and it didn't work well.
Finally I download code again and found it also didn't work well on .jpg images.

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

So, I finally have some time to dig into this. Good news: I can now finally reproduce it, with the steps provided by @ChipsSpectre.

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

Update: This has to do with CUDA.

If I compile torchac without CUDA support AND run all commands with CUDA_VISIBLE_DEVICES="", no errors appear.

Currently however, there is some weird behavior in torchac.py, where it always thinks CUDA is available. I'll dig more later this week.

from l3c-pytorch.

BUAAHugeGun avatar BUAAHugeGun commented on August 25, 2024

thx a lot. I guess it's hard to find this problem.

from l3c-pytorch.

ChipsSpectre avatar ChipsSpectre commented on August 25, 2024

Thank you for the tip. I will also have a look into the torchac module.
I could reproduce correct encryption and decryption with

CUDA_VISIBLE_DEVICES=""

on my machine, too.

Edit: The Arithmetic coder does not adapt the device before calling the torchac module.
grafik

The data are transferred to the default device (e.g. a GPU) before starting the bitcoding, where the data is only converted to float.
grafik

I assume now that maybe the error can be avoided by transferring the data to cpu if torchac-cpu is available only, similar to the function encode_logistic_mixture in torchac.

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

@ChipsSpectre Yes I realized that too now. Another problem is that if you compile with GPU support once, it stays in your build dir, and then torchac.py will always use the GPU version. I'll fix both things.

What's really weird to me however is that it works when using test.py. Because there is a line in there that does an assert output == input. So, when using the decoder in test.py, everything works. Somehow however, when using the decoder through l3c.py, it doesn't work anymore...

If you want to dig into that, it would also be much appreciated :)

from l3c-pytorch.

ChipsSpectre avatar ChipsSpectre commented on August 25, 2024

fixed.
the restorer class was the problem.
i create a pull request.

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

Still working on making the backend selection more seamless, so keeping this open.

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

@BUAAHugeGun Please try again with the latest master commit and let me know how it goes

from l3c-pytorch.

fab-jul avatar fab-jul commented on August 25, 2024

Closing this due to inactivity.

from l3c-pytorch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.