Giter Site home page Giter Site logo

gregorkobsik / imagetransformer Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 24.22 MB

This notebook shows a basic implementation of a transformer (decoder) architecture for image generation in TensorFlow 2.

License: MIT License

Jupyter Notebook 100.00%
transformers autoregressive-models imagegpt mnist-generation image-generation transformer-decoder generative-methods generative-loss autoregressive-image-generation

imagetransformer's Introduction

ImageTransformer

This notebook shows a basic implementation of a transformer (decoder) architecture for image generation in TensorFlow 2.

It demonstrates how to use a transformer decoder to learn a generative representation of the MNIST dataset and perform an autoregressive image reconstruction.

Mnist dataset examples:

MNIST examples

To reduce the number of color values, we perform a color quantization, e.g. we compute k-means clustering to get 8 color clusters and thus reduce our color palette.

Quantized examples:

MNIST quantized

Afterwards we serialize the images to obtain linear sequences of length 784 per image, which can be fed into the model as used in NLP.

See the notebook to get an in-depth explanation of the model.

Results

We perform image reconstruction, e.g. we take mnist images, remove the bottom half of the image, quantize it and let our model reconstruct the missing part. Afterwards we can revert the quantization and obtain a new generated mnist image. Compare the output and the input to see that the model does not memorize the inputs but creates new images.

Input data:

mnist input

Bottom half removed:

mnist top half

Generated output:

model output

Further reading

Keywords

Autoregressive Image Generation, MNIST, Transformers, Transformer Decoder, ImageGPT, Generative Methods, Generative Loss, Deep Learning, Machine Learning, TensorFlow 2

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.