Giter Site home page Giter Site logo

eleutherai / dalle-mtf Goto Github PK

View Code? Open in Web Editor NEW
435.0 30.0 48.0 279 KB

Open-AI's DALL-E for large scale training in mesh-tensorflow.

Home Page: https://www.eleuther.ai/

License: MIT License

Python 100.00%
artificial-intelligence transformers multimodal text-to-image variational-autoencoder autoregressive

dalle-mtf's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dalle-mtf's Issues

Add resblocks to VAE

You can pretty much copy the following code with appropriate modifications. To be more specific, the following is important ingredients:

  • Each resolution consists of down/up-sampler and blocks(), consisting of a certain number of Res blocks.
  • Each Res block looks as in block() (no modification preferred)
  • For the specifics of up/down-sampler, please refer to the comments.
  • The hidden dimension of each layer depends on the current spatial scale, and the order of blocks() and up/down-sampler() matters.
def block(self, x, dim, name=None):
    with tf.variable_scope(name):
        hidden_dim = dim // 4
        res = x
        x = self.activation(x, name="activ1")   
        x = self.conv2d(x, hidden_dim, (1, 1), (1, 1), padding="SAME", name="conv1",
                        variable_dtype=self.variable_dtype)
        x = self.activation(x, name="activ2")
        x = self.conv2d(x, hidden_dim, (3, 3), (1, 1), padding="SAME", name="conv2",
                        variable_dtype=self.variable_dtype)
        x = self.activation(x, name="activ3")
        x = self.conv2d(x, dim, (1, 1), (1, 1), padding="SAME", name="conv3",
                        variable_dtype=self.variable_dtype)
        x += res     
        return x


def blocks(self, x, dim, num_blocks, name=None):
    with tf.variable_scope(name):
        for idx in range(num_blocks):
            x = block(x, dim, name="block"+str(idx))    


def decoder(self, num_res, num_blocks):
    with tf.variable_scope("decoder"):
        dim = tf.shape(x)[1] # dim = c
        # num_res is the number of resolutions. e.g. if 32 -> 64 -> 128 -> 256, then = 4
        for idx in range(num_res):
            x = self.blocks(x, dim//(2 ** idx), num_blocks, name='blocks'+str(idx))
            if idx != num_res - 1: # not the last layer
                x = upsample(x) # nearest neighbor interpolation upsampling by the factor of 2
        x = self.conv2d(x, self.channels_dim, (1, 1), (1, 1), variable_dtype=self.variable_dtype)
        return x


def encoder(self, x, num_res, dim, num_blocks):
    with tf.variable_scope("encoder"):
        # dim is the embedding dimension of the first layer of encoder
        x = self.conv2d(x, dim, (3, 3), (1, 1), padding="SAME", name="conv_in",
                        variable_dtype=self.variable_dtype)        
        dim = tf.shape(x)[1] # dim = c
        for idx in range(num_res):
            x = self.blocks(x, dim * (2 ** idx), num_blocks, name='blocks'+str(idx))
            if idx != num_res - 1: # not the last layer
                x = downsample(x) # average pooling with stride = 2
        return x

Got Error

I got error when run the command:
python3 src/data/create_tfrecords.py

Error:
Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.04M/1.04M [00:00<00:00, 6.36MB/s] Downloading: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 456k/456k [00:00<00:00, 3.31MB/s] Downloading: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1.36M/1.36M [00:00<00:00, 7.19MB/s] 0it [00:00, ?it/s]Traceback (most recent call last): File "src/data/create_tfrecords.py", line 184, in <module> tokenizer=None) File "src/data/create_tfrecords.py", line 158, in create_paired_dataset data = load_jsonl(path) File "src/data/create_tfrecords.py", line 32, in load_jsonl with open(input_path, 'r', encoding='utf-8') as f: FileNotFoundError: [Errno 2] No such file or directory: '/home/data/coco/coco_captions.jsonl' 0it [00:00, ?it/s]

Easy to use dataset for DALL-E

The COCO dataset is a high-quality dataset both in terms of images and text. Each image has multiple captions and it consists of around 100 000 images. I have created a Google Colab which does the following:

  1. Fetches the COCO images and captions
  2. Allows the user to specify image dimensions which the images will be resized to
  3. Stores information in two files for easy access in the following format:

od-captions.txt (<image_path> : <image_caption>)

train2017/000000203564.jpg : A bicycle replica with a clock as the front wheel.
train2017/000000322141.jpg : A room with blue walls and a white sink and door.
train2017/00000016977.jpg : A car that seems to be parked illegally behind a legally parked car
train2017/000000106140.jpg : A large passenger airplane flying through the air.
train2017/000000571635.jpg : A bathroom with a toilet, sink, and shower.

od-captionsonly.txt (<image_caption>)

A bicycle replica with a clock as the front wheel.
A room with blue walls and a white sink and door.
A car that seems to be parked illegally behind a legally parked car
A large passenger airplane flying through the air.
A bathroom with a toilet, sink, and shower.

Here is an example image and caption:
image
The man at bat readies to swing at the pitch while the umpire looks on.

I have written this hoping it will be somewhat compatible with @htoyryla's fork of a similar project. Might be of interest to you. Feel free to use this to generate a dataset for DALL-E!

"No pertained models... yet"

The image generation takes a good amount of time because of the training.

When the pretrained models are released, how big is the size of the pretrained model, and how long will image generation take then? And how much computing power?

And around what time to you plan to release pretrained models?

Best regards

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.