<jupyter_start><jupyter_text>BEFORE RUNNING: Go to File > Save a copy in Drive to save a copy in your drive---  Run this first<jupyter_code>!pip install big-sleep --upgrade
!nvidia-smi<jupyter_output>Requirement already satisfied: big-sleep in /usr/local/lib/python3.7/dist-packages (0.8.5)
Requirement already satisfied: torch>=1.7.1 in /usr/local/lib/python3.7/dist-packages (from big-sleep) (1.10.0+cu111)
Requirement already satisfied: regex in /usr/local/lib/python3.7/dist-packages (from big-sleep) (2019.12.20)
Requirement already satisfied: tqdm in /usr/local/lib/python3.7/dist-packages (from big-sleep) (4.62.3)
Requirement already satisfied: pytorch-pretrained-biggan in /usr/local/lib/python3.7/dist-packages (from big-sleep) (0.1.1)
Requirement already satisfied: torchvision>=0.8.2 in /usr/local/lib/python3.7/dist-packages (from big-sleep) (0.11.1+cu111)
Requirement already satisfied: einops>=0.3 in /usr/local/lib/python3.7/dist-packages (from big-sleep) (0.3.2)
Requirement already satisfied: fire in /usr/local/lib/python3.7/dist-packages (from big-sleep) (0.4.0)
Requirement already satisfied: ftfy in /usr/local/lib/python3.7/dist-packages (from big-sleep) (6.0.3)
Requirement al[...]<jupyter_text>Generate imagesEnter your prompt in the "Text" field to the right of the code box below.You can supply it with multiple phrases at once using backslashes to seperate them to attempt to further specify what the image should be, e.g:```an armchair in the form of pikachu\an armchair imitating pikachu\abstract```The model will train for 20 epochs. Running the entire course is not recommended because it'll take a very very long time and Colab will probably time you out. On average there's a coherent and decent output before the end of the first epoch but you can go for longer if you want.To stop a run, you might need to click the "stop" button 3 times which will have Colab prompt you to reset the runtime.---Parameters:TEXT - This is the prompt you want the AI to use to generate your image. It's ideal to use something descriptive but not a requirement.SAVE_EVERY - Default: 100 - How often the output image will be saved and displayed.SAVE_PROGRESS - Default: False - Saves the output so that it can be resumedLEARNING_RATE - Default: 8e-2 - Affects how much compensation there is for approximated errors. Values too low can result in the output not resembling the prompt at all (especially for more obscure prompts) or stagnating and barely changing, values too high can result in the output being too wild or can result in a feedback loop where the image completely breaks down.It's often easier for the AI to figure out more obscure or weird prompts with a higher learning rate (often, at low learning rates the AI will commonly output images of animals for more obscure prompts.) but raising the learning rate often leads to less stability.This value takes a lot of work to fine-tune. I usually set it to something higher. 2e-1 (0.2) can result in some great output but it's common to see the images break down with such a high value. 8e-2 (0.08) is probably a decent balance. Play around for yourself. Different prompts work better with different learning rates.<jupyter_code>from tqdm import trange
import string
from IPython.display import Image, display

from big_sleep import Imagine

TEXT = "ocean deep\\abstract\\in the style of monet" #@param {type:"string"}

#Default: 100
SAVE_EVERY = 10 #@param {type:"number"} 

#Default: False
SAVE_PROGRESS = True #@param {type:"boolean"}

#Default: False
#EXPERIMENTAL_RESAMPLE = False #@param {type:"boolean"}

#Default: 8e-2
LEARNING_RATE =  3e-2#@param {type:"number"}

#Default: 1050
ITERATIONS = 100 #@param {type:"number"} 

model = Imagine(
    text = TEXT,
    save_every = SAVE_EVERY,
    lr = LEARNING_RATE,
    iterations = ITERATIONS,
    save_progress = SAVE_PROGRESS,
    #experimental_resample = EXPERIMENTAL_RESAMPLE
)

for epoch in trange(20, desc = 'epochs'):
    for i in trange(1000, desc = 'iteration'):
        model.train_step(epoch, i)

        if i == 0 or i % model.save_every != 0:
            continue

        filename = TEXT.translate(str.maketrans('', '', string.punctuation)).replace(' ', '_')
        image = Image(f'./{filename}.png')
        display(image)<jupyter_output>epochs:   0%|          | 0/20 [00:00<?, ?it/s]
iteration:   0%|          | 0/1000 [00:00<?, ?it/s][A
iteration:   0%|          | 1/1000 [00:06<1:47:36,  6.46s/it][A
iteration:   0%|          | 2/1000 [00:12<1:47:17,  6.45s/it][A
iteration:   0%|          | 3/1000 [00:19<1:47:12,  6.45s/it][A
iteration:   0%|          | 4/1000 [00:25<1:47:13,  6.46s/it][A
iteration:   0%|          | 5/1000 [00:32<1:47:05,  6.46s/it][A
iteration:   1%|          | 6/1000 [00:38<1:46:58,  6.46s/it][A
iteration:   1%|          | 7/1000 [00:45<1:46:49,  6.45s/it][A
iteration:   1%|          | 8/1000 [00:51<1:46:46,  6.46s/it][A
iteration:   1%|          | 9/1000 [00:58<1:46:35,  6.45s/it][A
iteration:   1%|          | 10/1000 [01:07<2:00:31,  7.30s/it][A
{'fraction_non_alphanumeric': 0.11477362986497221, 'fraction_numerical': 0.06096108022239873, 'mean_word_length': 3.7429378531073447, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '272647', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1849, 'n_tokens_neox': 1655, 'n_words': 587, 'path': 'Copy_of_Big_Sleep_Tweaked.ipynb', 'repo_name': 'dfrankle2/voterinfoproject', 'size': '5036'}