Giter VIP home page Giter VIP logo

Attention Mechanism (as implemented in Vision Transformer) for Image compression

The encoder takes the original image (in this case we used 3x224x224 images), divides it into fixed size patches, adds positional information to each patch, applies dropout and then passes the image through a cascade of 6 blocks of a Transformer module followed by layer normalization and the linear mapping. We use a patch size of 16 x 16 and each patch is flattened into a vector of size 1x768 (3x16x16). As a result, each 224x224 image is divided into 196 patches and reshaped into a 196x768 matrix. The embedding size (768) and the number of patches are maintained throughout the encoder module until the final linear layer. This linear layer is the one that does the compression, converting each image’s representation to a 1x1176 vector. Thus, the encoder compresses the image from 3x224x224x8 bits to 1176x64 bits which is 0.5 bits per pixel.

For the decoder, we use one linear layer to expand the compressed representation from a vector of size 1176 to a vector of size 150528 which is then reshaped into a tensor of shape (3x224x224).

neliphaz45's Projects

neliphaz45 doesn’t have any public repositories yet.

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.