Skip to content

Instantly share code, notes, and snippets.

@metacritical
Forked from FurkanGozukara/kandinsky.txt
Created July 14, 2023 23:18
Show Gist options
  • Save metacritical/c47f0bb0f385e68da62d2d520b1643bb to your computer and use it in GitHub Desktop.
Save metacritical/c47f0bb0f385e68da62d2d520b1643bb to your computer and use it in GitHub Desktop.

Revisions

  1. @FurkanGozukara FurkanGozukara revised this gist Apr 10, 2023. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions kandinsky.txt
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,10 @@
    # repo link : https://github.com/ai-forever/Kandinsky-2
    # used repo commit hash : a4354c04d5fbd48851866ef7d84ec444d3d50102

    # those who getting cuda error
    # pip uninstall torch
    # pip3 install torch==1.13.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117

    import os
    import uuid
    from PIL import Image
  2. @FurkanGozukara FurkanGozukara revised this gist Apr 5, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions kandinsky.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    # tutorial video link : https://youtu.be/dYt9xJ7dnpU
    # colab link : https://colab.research.google.com/drive/1xSbu-b-EwYd6GdaFPRVgvXBX_mciZ41e?usp=sharing
    # repo link : https://github.com/ai-forever/Kandinsky-2
    # used repo commit hash : a4354c04d5fbd48851866ef7d84ec444d3d50102

    import os
    import uuid
  3. @FurkanGozukara FurkanGozukara revised this gist Apr 5, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion kandinsky.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # tutorial video link : https://youtu.be/dYt9xJ7dnpU

    # colab link : https://colab.research.google.com/drive/1xSbu-b-EwYd6GdaFPRVgvXBX_mciZ41e?usp=sharing

    import os
    import uuid
  4. @FurkanGozukara FurkanGozukara revised this gist Apr 5, 2023. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions kandinsky.txt
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    # tutorial video link : https://youtu.be/dYt9xJ7dnpU


    import os
    import uuid
    from PIL import Image
  5. @FurkanGozukara FurkanGozukara revised this gist Apr 5, 2023. 1 changed file with 35 additions and 26 deletions.
    61 changes: 35 additions & 26 deletions kandinsky.txt
    Original file line number Diff line number Diff line change
    @@ -1,33 +1,42 @@
    images = model.generate_text2img(
    "fantastic dreamlike forest",
    num_steps=30,
    batch_size=1,
    guidance_scale=4,
    h=768,
    w=768,
    sampler='p_sampler',
    prior_cf_scale=4,
    prior_steps="5"
    )

    import os
    import uuid
    from PIL import Image

    # path to the folder where the images will be saved
    folder_path = 'C:/Kandinsky-2/imgs'

    # generate a unique identifier
    guid = uuid.uuid4()
    # Set the number of iterations
    num_iterations = 10

    # loop through all images in the list
    for i, image in enumerate(images):
    # create the file name using the GUID, index, and the image file extension
    file_name = f"{guid}_{i}.png"
    for iteration in range(num_iterations):
    print(f"Generating images for iteration {iteration + 1}/{num_iterations}...")

    # display the image
    display(image)
    images = model.generate_text2img(
    "lion, jungle, cartoon, ultra realistic",
    num_steps=40,
    batch_size=1,
    guidance_scale=4,
    h=768,
    w=768,
    sampler='p_sampler',
    prior_cf_scale=4,
    prior_steps="5"
    )

    # path to the folder where the images will be saved
    folder_path = 'C:/Kandinsky-2/imgs'

    # generate a unique identifier
    guid = uuid.uuid4()

    # loop through all images in the list
    for i, image in enumerate(images):
    # create the file name using the GUID, index, and the image file extension
    file_name = f"{guid}_{i}.png"

    # display the image
    display(image)

    # save the image to the folder with the GUID and index name
    file_path = os.path.join(folder_path, file_name)
    image.save(file_path)

    # save the image to the folder with the GUID and index name
    file_path = os.path.join(folder_path, file_name)
    image.save(file_path)
    remaining_iterations = num_iterations - (iteration + 1)
    print(f"Completed iteration {iteration + 1}/{num_iterations}. {remaining_iterations} iteration(s) remaining.")
  6. @FurkanGozukara FurkanGozukara revised this gist Apr 5, 2023. 1 changed file with 24 additions and 7 deletions.
    31 changes: 24 additions & 7 deletions kandinsky.txt
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,33 @@
    display(images[0])
    images = model.generate_text2img(
    "fantastic dreamlike forest",
    num_steps=30,
    batch_size=1,
    guidance_scale=4,
    h=768,
    w=768,
    sampler='p_sampler',
    prior_cf_scale=4,
    prior_steps="5"
    )

    import os
    import uuid
    from PIL import Image

    # path to the folder where the image will be saved
    # path to the folder where the images will be saved
    folder_path = 'C:/Kandinsky-2/imgs'

    # generate a unique identifier
    guid = uuid.uuid4()

    # create the file name using the GUID and the image file extension
    file_name = str(guid) + '.png'

    # save the image to the folder with the GUID name
    images[0].save(os.path.join(folder_path, file_name))
    # loop through all images in the list
    for i, image in enumerate(images):
    # create the file name using the GUID, index, and the image file extension
    file_name = f"{guid}_{i}.png"

    # display the image
    display(image)

    # save the image to the folder with the GUID and index name
    file_path = os.path.join(folder_path, file_name)
    image.save(file_path)
  7. @FurkanGozukara FurkanGozukara created this gist Apr 5, 2023.
    16 changes: 16 additions & 0 deletions kandinsky.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    display(images[0])
    import os
    import uuid
    from PIL import Image

    # path to the folder where the image will be saved
    folder_path = 'C:/Kandinsky-2/imgs'

    # generate a unique identifier
    guid = uuid.uuid4()

    # create the file name using the GUID and the image file extension
    file_name = str(guid) + '.png'

    # save the image to the folder with the GUID name
    images[0].save(os.path.join(folder_path, file_name))