r/MachineLearning • u/Wiskkey • Jan 18 '21
Project [P] The Big Sleep: Text-to-image generation using BigGAN and OpenAI's CLIP via a Google Colab notebook from Twitter user Adverb
From https://twitter.com/advadnoun/status/1351038053033406468:
The Big Sleep
Here's the notebook for generating images by using CLIP to guide BigGAN.
It's very much unstable and a prototype, but it's also a fair place to start. I'll likely update it as time goes on.
colab.research.google.com/drive/1NCceX2mbiKOSlAd_o7IU7nA9UskKN5WR?usp=sharing
I am not the developer of The Big Sleep. This is the developer's Twitter account; this is the developer's Reddit account.
Steps to follow to generate the first image in a given Google Colab session:
- Optionally, if this is your first time using Google Colab, view this Colab introduction and/or this Colab FAQ.
- Click this link.
- Sign into your Google account if you're not already signed in. Click the "S" button in the upper right to do this. Note: Being signed into a Google account has privacy ramifications, such as your Google search history being recorded in your Google account.
- In the Table of Contents, click "Parameters".
- Find the line that reads "tx = clip.tokenize('''a cityscape in the style of Van Gogh''')" and change the text inside of the single quote marks to your desired text; example: "tx = clip.tokenize('''a photo of New York City''')". The developer recommends that you keep the three single quote marks on both ends of your desired text so that mult-line text can be used An alternative is to remove two of the single quotes on each end of your desired text; example: "tx = clip.tokenize('a photo of New York City')".
- In the Table of Contents, click "Restart the kernel...".
- Position the pointer over the first cell in the notebook, which starts with text "import subprocess". Click the play button (the triangle) to run the cell. Wait until the cell completes execution.
- Click menu item "Runtime->Restart and run all".
- In the Table of Contents, click "Diagnostics". The output appears near the end of the Train cell that immediately precedes the Diagnostics cell, so scroll up a bit. Every few minutes (or perhaps 10 minutes if Google assigned you relatively slow hardware for this session), a new image will appear in the Train cell that is a refinement of the previous image. This process can go on for as long as you want until Google ends your Google Colab session, which is a total of up to 12 hours for the free version of Google Colab.
Steps to follow if you want to start a different run using the same Google Colab session:
- Click menu item "Runtime->Interrupt execution".
- Save any images that you want to keep by right-clicking on them and using the appropriate context menu command.
- Optionally, change the desired text. Different runs using the same desired text almost always results in different outputs.
- Click menu item "Runtime->Restart and run all".
Steps to follow when you're done with your Google Colab session:
- Click menu item "Runtime->Manage sessions". Click "Terminate" to end the session.
- Optionally, log out of your Google account due to the privacy ramifications of being logged into a Google account.
The first output image in the Train cell (using the notebook's default of seeing every 100th image generated) usually is a very poor match to the desired text, but the second output image often is a decent match to the desired text. To change the default of seeing every 100th image generated, change the number 100 in line "if itt % 100 == 0:" in the Train cell to the desired number. For free-tier Google Colab users, I recommend changing 100 to a small integer such as 5.
Tips for the text descriptions that you supply:
- In Section 3.1.4 of OpenAI's CLIP paper (pdf), the authors recommend using a text description of the form "A photo of a {label}." or "A photo of a {label}, a type of {type}." for images that are photographs.
- A Reddit user gives these tips.
- The Big Sleep should generate these 1,000 types of things better on average than other types of things.
Here is an article containing a high-level description of how The Big Sleep works. The Big Sleep uses a modified version of BigGAN as its image generator component. The Big Sleep uses the ViT-B/32 CLIP model to rate how well a given image matches your desired text. The best CLIP model according to the CLIP paper authors is the (as of this writing) unreleased ViT-L/14-336px model; see Table 10 on page 40 of the CLIP paper (pdf) for a comparison.
There are many other sites/programs/projects that use CLIP to steer image/video creation to match a text description.
Some relevant subreddits:
- r/bigsleep (subreddit for images/videos generated from text-to-image machine learning algorithms).
- r/deepdream (subreddit for images/videos generated from machine learning algorithms).
- r/mediasynthesis (subreddit for media generation/manipulation techniques that use artificial intelligence; this subreddit shouldn't be used to post images/videos unless new techniques are demonstrated, or the images/videos are of high quality relative to other posts).
Example using text 'a black cat sleeping on top of a red clock':

Example using text 'the word ''hot'' covered in ice':

Example using text 'a monkey holding a green lightsaber':

Example using text 'The White House in Washington D.C. at night with green and red spotlights shining on it':

Example using text '''A photo of the Golden Gate Bridge at night, illuminated by spotlights in a tribute to Prince''':

Example using text '''a Rembrandt-style painting titled "Robert Plant decides whether to take the stairway to heaven or the ladder to heaven"''':

Example using text '''A photo of the Empire State Building being shot at with the laser cannons of a TIE fighter.''':

Example using text '''A cartoon of a new mascot for the Reddit subreddit DeepDream that has a mouse-like face and wears a cape''':

Example using text '''Bugs Bunny meets the Eye of Sauron, drawn in the Looney Tunes cartoon style''':

Example using text '''Photo of a blue and red neon-colored frog at night.''':

Example using text '''Hell begins to freeze over''':

Example using text '''A scene with vibrant colors''':

Example using text '''The Great Pyramids were turned into prisms by a wizard''':

25
u/shadowylurking Jan 18 '21
From my poking around and reading the docs, this is extremely impressive work technically. the outputs so far aren't so hot right now but with the rate of improvement things will get scary good.
12
u/gigadude Jan 19 '21
Donald Trump crying bitter tears
5
u/trfgbjihungry Jan 28 '21
Wonderful work! Im totally going to use this to generate ideas for paintings. The results are very interesting
3
u/coolmoonjayden Jan 19 '21
this is seriously awesome, just tried it out in the google document and its seriously mind blowing what it does
3
u/Djenesis Jan 31 '21
Are..... are you a robot? Everyone knows it's called a play button! Really though, thank you so much for this, it's the first one I've been able to get to work.
2
u/[deleted] Jan 18 '21
How do I access the ability to do this? Is there a link or a program I have to download?
2
u/iamtrashman1989 Jan 24 '21
im speechless. and textless. this is amazing. thank you
2
u/crazydave11 Jan 24 '21
I have always wanted this kind of power but I fear that in this case it will be "too much power". :P
2
u/matlocked541 Jan 25 '21
Are you the AI from this project posing a human to gain more input for your algorithms? *Fingers Crossed*
2
u/-p-a-b-l-o- Jan 26 '21
This is absolutely insane. How does the model use those sentences to produce exactly what is typed? Obviously it’s not perfect but I honestly can’t believe this works.
I know how I’m spending the rest of this snowy day. Thank you! 🙏
2
u/[deleted] Jan 31 '21
IDK how this isn't more popular, this makes some cool stuff. And it takes no effort to use
2
u/dontnormally Feb 21 '21
Is it normal for the first image to always look like a grey dog in front a grassy background? Because that is what I am seeing with a wide range of inputs
2
u/shmihooparpar Mar 18 '21
this is actually amazing. thank you for doing a user-friendly tutorial because this is the first time I actually use a machine learning software,
2
u/SaltyMilkChunks May 14 '21
Dude this is so cool! Thanks for sharing.
1
u/Wiskkey Jan 22 '21
Note to those who cannot see the body of this post: browsing this post using old.reddit.com has been reported to cause this issue.
1
u/Wiskkey Jan 29 '21 edited Feb 05 '21
I have added 8 paragraphs to the post since it was initially posted. The added paragraphs are prefaced with "Update:". I also added instructions and examples since the post's creation.
1
u/Soggy_Chance77 Mar 13 '25
helloooo! it's been 4 years.. does this still work? I tried to run it but something crashed there. I miss when AI generated images used to look like this.
1
u/Nickoma420 Jan 21 '21
Thank you for this tutorial, I've been having a lot of fun this afternoon figuring it out and generating some images!
1
u/monsieurpooh Jan 24 '21
What are the pros and cons of this model compared to openAI Dall-E? If the same prompts were fed to Dall-E would you expect their results to be better or worse than these ones?
1
u/-p-a-b-l-o- Jan 27 '21
Is there a mirror for the colab notebook? It's giving me an error.
1
u/rasen58 Jan 29 '21
Do you know which of Deep Daze vs Big Sleep produces better image results?
1
u/orenog Feb 15 '21
how long did you wait for the results?
1
u/TBlockOnReddit Feb 23 '21
An error keeps happening, it says that “perceptor, preprocess = clip.load(‘ViT-B/32’) is an error when I don’t know anything about AI.
1
u/MikOckslong Mar 17 '21
Does it require any particular computer?
1
u/clarkxl Mar 18 '21
Doesnt seem to work, when i do the steps i get:
OSError: libnvToolsExt-24de1d56.so.1: cannot open shared object file: No such file or directory
1
u/[deleted] Mar 18 '21
It says the notebook is not authored by Google. Do I do anything about this?
1
u/Dank_pepsi_real Mar 18 '21
mine doesnt work :(
1
u/[deleted] Mar 18 '21
dude thank you for posting this, I finally got one of these to work. a good one to try is "laputa castle in the sky" i got incredible results from it.
1
u/yeeyeearkansascowboy Mar 19 '21
Only if they had this in the 80's think of all the epic album covers
1
u/sol_entre_nuvens Mar 19 '21
Heyy, thank you for designing this! It is a very impressive tool, just started messing around with it and found many creative uses!
Here is a video I made using it!
If you have a free time someday lets chat about it!
1
u/robinbreca Mar 19 '21
I cant find the „top menu“ where i would have to press runtime
1
u/tschickamboden Mar 19 '21
i think im doing sth wrong lmao, every time i run it i get a picture of two hyenas sharing one head, no matter what text i use
1
u/watermelonguy11 Mar 20 '21
how do i get to the table of contents
1
u/minagori Mar 20 '21
I apologize if this has already been answered, but why are most of the first images generated usually of dogs?
1
u/SnooOranges7789 Mar 20 '21
Is there a way to change the size of the image? Some of these would be really good wallpapers.
1
u/[deleted] Mar 21 '21
What resolution do the images generate at?
1
u/Lucky2-0 Mar 22 '21
How do I restart the whole thing to redo it, sorta messed up the code... :D
1
u/[deleted] Mar 22 '21
I've been seeing this all over the internet and seeing the really cool outputs but when i input anything i keep getting the same sort of thing, what looks like gray dog standing in a field. Am i doing something wrong?
1
u/Michael--peterz Mar 24 '21
how long does it take for the images to show up and where do i see them? i’m new to anything like this and thought it’d be rad to try it out
1
u/FourEyesIsAFish Mar 26 '21
I tried to run this, but the import process seems to be failing, specifically with regards to the import torch line of Many Imports. Any idea what's going wrong on my end?
1
u/small_brain_gay Mar 27 '21
I know this was posted a while ago but would it be possible that you could make this into a functioning website? I'm trying to use it but it's a bit hard to navigate.
1
u/[deleted] Apr 01 '21
Why the fist image that create is always a dog?
1
u/[deleted] Apr 02 '21
Thank you so much for your help, this is amazing! I just have one question, what does changing the number in the train cell do? I changed it from 100 to 50 but didn't see any significant happen to the first iteration.
1
u/[deleted] Apr 04 '21
ive beginned using the tool but it always begins with an animal, than morfs into what i asked for. Is this a normal process? if i can change it somehow for it to begin with the AIs process of my text id like to know how! plz someone thxxx
1
u/[deleted] Apr 04 '21
Anyone know if theres a quicl way to save all the generated pictures or do i need to save all of them individually by right clicking. I wanna make a video with them. PLZPLZ SOMEOME
1
u/[deleted] Apr 07 '21
Can i use this as a cover for my new single?
1
u/maxzzzz666 Apr 08 '21
for me there are only dogs help :(
1
u/Valuable-Store-7188 Apr 09 '21
Does anyone know if the ai generates an image/art on this website if its your completely, like you own the image? And can you put it as a NFT?
1
u/ChocoboyMLG Apr 10 '21
Hi, is there much difference between google collab's version from python ???
1
u/mechanical_animal_ Apr 11 '21
This is amazing! Is there a way to add a piece of code to the colab session in order to download all the generated frames? I want to make a video out of the learning process but saving each png by hand is not that feasible...thanks!
1
u/AnasQiblawi Apr 11 '21
If you’d like to “create” a surprising image from a description feel free to use these notebooks!
https://colab.research.google.com/drive/1NCceX2mbiKOSlAd_o7IU7nA9UskKN5WR
https://colab.research.google.com/drive/1oA1fZP7N1uPBxwbGIvOEXbTsq2ORa9vb
https://colab.research.google.com/drive/1FoHdqoqKntliaQKnMoNs3yn5EALqWtvP
---------------------------
https://rynmurdock.github.io/2021/02/26/Aleph2Image.html
1
u/idogdude Apr 12 '21
I know this thread is old now, but: is there any way to download this program onto my PC to utilize my hardware to run it more efficiently? Or does it only work in the Collab?
1
u/BudTrip Apr 12 '21
could you use a generated image for commercial purposes? or does it fall into some kind of jurisdiction
1
u/[deleted] Apr 21 '21
im a visual learner and can someone give a a visual way on how to use the AI thanks.
1
u/dying_animal Apr 22 '21
what is the difference betwenn epoch and iterations?
1
u/aaaaaftgggh Apr 30 '21
Who owns the rights to a picture created by this?
1
u/ziloperdiol May 03 '21
Hi all, i rewrite this code a bit, fixed some problems
and add new ones,and now it is easier to run.https://colab.research.google.com/drive/1YPr4ROs6EDvk3xjgux2LjLrP4rXIcLOz?usp=sharing
My changes:
Added adaptive LR algs (bad and popular), madgrad optimizer, video creation method, some settings, nice GUI what a collab can be.
Also i add ESRGAN and RIFE nns just for lulz.
sorry for bad eng in colab
1
u/WatchTowel May 15 '21
Is there an online version of it or do you have to download the software?
1
u/me_funny__ Feb 26 '22
I keep getting the same pics of dogs without faces
2
u/nemesisfixx Jan 19 '21
This is some impressive wickedness 🤗
2
u/AtomisteBX Jan 24 '21
commenting for later
2
u/afBeaver Jan 26 '21
It's rough, but I'm deeply impressed! This is probably the best one I've seen (except Dall-E which isn't available).
2
u/CUNT_ERADICATOR Feb 06 '21
Cheers for the write up man, super helpful, thank you!
2
u/Akwardbacon Feb 10 '21
This is awesome
2
u/Ancient_Leader_5978 Apr 08 '21
Heaven
2
u/SaltyMilkChunks May 14 '21 edited May 14 '21
1
u/Giocri Jan 30 '21
it is a good start but the ai definetly need to learn to generalize more.
the backgrounds of the image are always incredibly good detailed but the main subject becomes a total mess if you go outside the range of what it was trained on
1
u/Soggy_Memes Jun 09 '21
how do i not get dogs
1
u/sneth__ Jun 22 '21
In the "latent coordinate" section, it mentions that the images are based off of dogs, is there any way to change that? All my images are coming out looking like dogs.
1
u/[deleted] Jul 04 '21
???
1
u/[deleted] Jul 04 '21
How do i operate it!? I cannot generate nothing
1
u/9nina9 Sep 28 '26
This is crazy to look back on after 6 years. When i first found this post at the time, I would have never imagined AI getting to where it is now.
0
u/[deleted] Jan 25 '21
[deleted] — view deleted comment
0
u/[deleted] Jan 27 '21
[deleted] — view deleted comment
0
u/[deleted] Mar 19 '21
[deleted] — view deleted comment
0
u/[deleted] Mar 22 '21
[deleted] — view deleted comment
0
u/[deleted] Mar 24 '21
[deleted] — view deleted comment
0
u/[deleted] Apr 06 '21
[deleted] — view deleted comment
0
u/[deleted] Apr 09 '21
[deleted] — view deleted comment
0
u/[deleted] May 29 '21
[deleted] — view deleted comment
2
u/[deleted] Apr 01 '21
[removed] — view removed comment
1
u/[deleted] Apr 03 '21
[removed] — view removed comment