Giter Site home page Giter Site logo

Issue with generate_map.py: "TypeError: Input 'split_dim' of 'Split' Op has type float32 that does not match expected type of int32" about image-compression-cnn HOT 5 CLOSED

iamaaditya avatar iamaaditya commented on August 27, 2024
Issue with generate_map.py: "TypeError: Input 'split_dim' of 'Split' Op has type float32 that does not match expected type of int32"

from image-compression-cnn.

Comments (5)

iamaaditya avatar iamaaditya commented on August 27, 2024

@subzerofun Thanks for pointing that out.

  1. It seems Tensorflow updated the split function from tf.split(axis, num_or_size_splits, value) to tf.split(value, num_or_size_splits, axis)

  2. Same change in tf.concat tf.concat(axis, values) to tf.concat(values,axis)

  3. tf.batch_matmul is now tf.matmul

These changes are in-order to make it work similar to Numpy.

I have pushed the changes. do a pull and it should work fine.

Also, for some reason the models load much slowly in newer version of TF but I have no idea what could be the issue.

from image-compression-cnn.

subzerofun avatar subzerofun commented on August 27, 2024

Thanks for the reply! I have just used the official upgrade script from the Tensorflow site, processed all your .py files (no errors after converting) and now everything is running fine!

I just tested a few images and the results are amazing. From what i have read the best JPEG compression algorithm out there is Mozillas mozjpeg – comparison:
Comparison of JPEG Lossless Compression Tools

I will try to process the images from the blog article above and the compare the results. The only problem is that the images are quite big (3000-4000px) and i don't have enough GPU memory at the moment (50+ Chrome tabs...). So the generate_map.py script just crashes with an ResourceExhaustedError error. Is there any way to reduce the memory usage?

And your algorithm can even reduce a moz-jpeg! Just a short result:
800 x 1000px ... moz-jpeg (quality 80/100) ... 172kb
... and after cnn compression: 62kb (!!!)

Of course you can see more artifacts (best visible in smooth regions) compared to the original file. And for some reason the cnn-image is sharper than the original.

Still – overall the ability to reduce the filesize of images, generated with the best jpeg algorithm out there, is amazing!

This is really a great solution for web images! The only downside is the computation time/effort.

from image-compression-cnn.

iamaaditya avatar iamaaditya commented on August 27, 2024

Thanks for the research. I am glad to hear that it is doing great on moz-jpeg.

  1. Regardless of the size of the original image, the map being generated used the downsized image of 224x224. See this https://github.com/iamaaditya/image-compression-cnn/blob/master/util.py#L24
    (This is because the TF model to generate the heatmaps are trained for specific input dimensions).

  2. If you give me what exact error you are getting I might be able to help.

  3. I just did for an image with 5391x4048 pixels and it performed without problem.

  4. Computation time is an issue, and we do understand that this makes it not feasible for quick deployment. However, encoding is a one time cost and decoding is as cheap/fast as JPEG. Also, since generating map is GPU based, it can take many images at a time (around 50 for my GPU) and generate the map at the same time.

If you looking to deploy this for an efficient system, get in touch with me. I can help you with that.

from image-compression-cnn.

subzerofun avatar subzerofun commented on August 27, 2024

Was trying a 2400 x 3000px image – but only with 1.6 of 6 GB VRAM available. For some reason it worked when i tried running it a second time.

The 3072 x 2304px image from the comparison site also worked now.
mozjpeg result: from 1,2 MB to 363 kb
CNN result: 305 kb
from compressed mozjpeg to CNN: 335 kb

Thanks for the deployment offer but i'm just testing this for fun :-). Maybe i'll use it for my next website, but since i only write small wordpress themes/sites, i will just need to convert ~50-200 images. That's manageable with a .sh script.

from image-compression-cnn.

iamaaditya avatar iamaaditya commented on August 27, 2024

Sure. I am glad it works. All the best with your work.

from image-compression-cnn.

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.