greatly enrich one’s mind! This simple command line tool, input text can generate strange images

Time:2021-4-20

[introduction]: a simple command line tool for generating images from text.

greatly enrich one's mind! This simple command line tool, input text can generate strange images

brief introduction

Deep daze is a command line tool that uses openai clip and siren to generate images from text. It can generate corresponding images by using simple language to describe image content.

![shattered plates on the grass
(broken dishes on the grass) ](https://gitee.com/kaixiaoyan/…

greatly enrich one's mind! This simple command line tool, input text can generate strange images

greatly enrich one's mind! This simple command line tool, input text can generate strange images

Project address:

https://github.com/lucidrains…

Download and install

Deep daze is a python command-line tool, so you need to install Python in the environment you use, and then execute the following command to install it:

$ pip install deep-daze

greatly enrich one's mind! This simple command line tool, input text can generate strange images

Easy to use

The use of deep daze is also very simple. Just remember an image command, such as:

$ imagine "a house in the forest"  

In windows, you need to use the administrator to open the CMD window.

greatly enrich one's mind! This simple command line tool, input text can generate strange images

If the memory is large enough, you can add the — Deep option to get higher quality pictures

$ imagine "shattered plates on the ground" --deeper  

Deep daze has the following options:

--img=IMAGE_PATH  
    Default: none.  
    To optimize the path of PNG / JPG image or PIL image.  
--encoding=ENCODING  
    Default: none.  
    User created custom clip encoding. If used, replaces any text or image used.  
--create_story=CREATE_STORY  
    Default value: false.  
    If you enable this feature, you can use text longer than 77 characters to create picture stories.  
--story_start_words=STORY_START_WORDS  
    Default value: 5.  
    Only in create_ Used when story is true.  
--story_words_per_epoch=STORY_WORDS_PER_EPOCH  
    Default value: 5.  
    Only in create_ Used when story is true.  
--story_separator:  
    Default: None  
    Only in create_ Used when story is true.定义一个类似.的分隔符。  
--lower_bound_cutout=LOWER_BOUND_CUTOUT  
    Default: 0.1  
    The sampling lower limit of the size of random incision of each batch of siren images. Should be less than 0 . 8。  
--upper_bound_cutout=UPPER_BOUND_CUTOUT  
    Default: 1.0  
    The sampling upper limit of the size of random incision of each batch of siren images. It should be kept at 1.0.  
--saturate_bound=SATURATE_BOUND  
    Default: false  
    If true, lower is set during training_ BOUND_ The cutoff increased linearly to 0.75.  
--learning_rate=LEARNING_RATE  
    Default value: 1e-05  
    Learning rate of neural network.  
--num_layers=NUM_LAYERS  
    Default value: 16  
    The number of hidden layers of siren neural network.  
--batch_size=BATCH_SIZE  
    Default value: 4  
    The number of images passed to Siren before the loss is calculated. Reducing this value may reduce memory and accuracy.  
--gradient_accumulate_every=GRADIENT_ACCUMULATE_EVERY  
    Default value: 4  
    The weighted loss of n samples is calculated. Increasing this value helps to improve accuracy with a smaller batch size.  
--epochs=EPOCHS  
    Default value: 20  
    The number of times to run.  
-- iterations = iteration  
    Default value: 1050  
    The number of times the sum and backpropagation losses are calculated in a given period.  
--save_every=SAVE_EVERY  
    Default value: 100  
    Each iteration of the generated image is a multiple of this number.  
--image_width = IMAGE_WIDTH  
    Default value: 512  
    The required image resolution.  
--deeper=DEEPER  
    Default: false  
    The siren neural network with 32 hidden layers is used.  
--overwrite=OVERWRITE  
    Default: false  
    Whether to overlay the existing generated image with the same name.  
--save_progress=SAVE_PROGRESS  
    Default: false  
    Whether to save the image generated before siren training.  
--seed=SEED  
    Type: optional  
    Default: None  
    The seed to be used is for deterministic operation.  
--open_folder=OPEN_FOLDER  
    Default value: true  
    Whether to open the folder for the generated images.  
--save_date_time=SAVE_DATE_TIME  
    Default: false  
    Save the file with a timestamp. For example, '% Y% m% d -% H% m% s-my'_ phrase_ here`  
--start_image_path= TART_IMAGE_PATH  
    Default: None  
    First train students on the original image, then turn to text input  
--start_image_train_iters=START_IMAGE_TRAIN_ITERS  
    Default value: 50  
    The number of initial training on the initial image  
--theta_initial=THETA_INITIAL  
    Default value: 30.0  
    Parameters describing the frequency of color space. Only for the first layer of the network.  
--theta_hidden = THETA_INITIAL  
    Default value: 30.0  
    Parameters describing the frequency of color space. Only for the hidden layer of the network.  
--save_gif = SAVE_GIF  
    Default: false  
    Whether to save GIF animation for the build process. Only in save_ Valid when progress is set to true.

more

  • Training synthesis based on one picture
$ imagine 'a clear night sky filled with stars' --start_image_path ./cloudy-night-sky.jpg  

Original image:

greatly enrich one's mind! This simple command line tool, input text can generate strange images

Composite image:

greatly enrich one's mind! This simple command line tool, input text can generate strange images

  • Calling with Python
from deep_daze import Imagine  
  
imagine = Imagine(  
    text = 'cosmic love and attention',  
    num_layers = 24,  
)  
imagine()  
  • Save every four iterations. Save the image in this format: insert\_ text\_ here.00001.png,insert\_ text\_ here.00002.png,…
imagine = Imagine(  
    text=text,  
    save_every=4,  
    save_progress=True  
)  
  • Create a file with a timestamp and serial number
imagine = Imagine(  
    text=text,  
    save_every=4,  
    save_progress=True,  
    save_date_time=True,  
)  

Open source outpostShare popular, interesting and practical open source projects everyday. Participate in the maintenance of 100000 + star’s open source technology resource library, including python, Java, C / C + +, go, JS, CSS Node.js , PHP,. Net, etc.