Kandinsky-2
Kandinsky-2 copied to clipboard
Add setup script and txt2img generation script for ease of use
For windows users and nvidia GPU: You need to have Python (3.10) installed as well as git.
Scripts: https://gist.github.com/DanPli/98c05281a749254e5b572238825d3617 and https://gist.github.com/DanPli/0bfcaed38ed678adf3cd3f6aa0420f46
Edit: Here is a simple inpainting script: https://gist.github.com/DanPli/bce1fac71c2bdef0252d70b682808faa see comment https://github.com/ai-forever/Kandinsky-2/issues/33#issuecomment-1499201569
I created the setup batch file to setup kandinsky-2 for myself, but perhaps someone finds it useful. Installs Kandinsky with torch 2.0 and cudnn118 as well as the other dependencies. Create a folder, place the files inside and run the setup_kandinsky.bat to do the installation.
The gen.py is based on https://gist.github.com/Blucknote/31f792621f4e4cdf0a7d2505ddd6b0a2 mostly changing the image saving method and naming to avoid windows OS invalid file naming issues, resulting in errors. Thank you, user Blucknote.
and after all the dependencies are installed you can use the gen.py to generate images. FYI, on the first run, the model will be downloaded from the huggingface hub.
To use the txt2img generator file, open a powershell/cmd shell window in the folder, activate the venv with " .\venv\Scripts\activate "
With the venv active:
Example usage: python.exe gen.py --prompt 1girl --negative_prompt "ugly, bad anatomy" --steps 50
Put prompts and negatives in quotes if there is more than one word (spaces, special characters etc.) Other commands you can pass to the gen.py: [--prompt PROMPT] [--negative_prompt NEGATIVE_PROMPT] [--steps STEPS] [--batch BATCH] [--scale SCALE] [--height HEIGHT] [--width WIDTH] [--sampler SAMPLER] [--prior_scale PRIOR_SCALE] [--prior_steps PRIOR_STEPS]
Generated images will be placed in a subfolder "generated_images" with date and numbering naming convention and in png format by default.
Yay I'm usefull :D
I guess i don't had errors with filenames because of WSL
Thanks I also made a tutorial video
27.) Python Script - Jupyter Based - PC - Free
Midjourney Level NEW Open Source Kandinsky 2.1 Beats Stable Diffusion - Installation And Usage Guide
For windows users and nvidia GPU: You need to have Python (3.10) installed as well as git.
Scripts: https://gist.github.com/DanPli/98c05281a749254e5b572238825d3617 and https://gist.github.com/DanPli/0bfcaed38ed678adf3cd3f6aa0420f46
I created the setup batch file to setup kandinsky-2 for myself, but perhaps someone finds it useful. Installs Kandinsky with torch 2.0 and cudnn118 as well as the other dependencies. Create a folder, place the files inside and run the setup_kandinsky.bat to do the installation.
The gen.py is based on https://gist.github.com/Blucknote/31f792621f4e4cdf0a7d2505ddd6b0a2 mostly changing the image saving method and naming to avoid windows OS invalid file naming issues, resulting in errors. Thank you, user Blucknote.
and after all the dependencies are installed you can use the gen.py to generate images. FYI, on the first run, the model will be downloaded from the huggingface hub.
To use the txt2img generator file, open a powershell/cmd shell window in the folder, activate the venv with " .\venv\Scripts\activate.bat "
With the venv active:
Example usage: python.exe gen.py --prompt 1girl --negative_prompt "ugly, bad anatomy" --steps 50
Put prompts and negatives in quotes if there is more than one word (spaces, special characters etc.) Other commands you can pass to the gen.py: [--prompt PROMPT] [--negative_prompt NEGATIVE_PROMPT] [--steps STEPS] [--batch BATCH] [--scale SCALE] [--height HEIGHT] [--width WIDTH] [--sampler SAMPLER] [--prior_scale PRIOR_SCALE] [--prior_steps PRIOR_STEPS]
Generated images will be placed in a subfolder "generated_images" with date and numbering naming convention and in png format by default.
tried your bat file and it fixed my issues thank you!
Added a simple inpainting script: https://gist.github.com/DanPli/bce1fac71c2bdef0252d70b682808faa
Usage: Make sure the venv is active, then call the inpaint.py as in this example:
python inpaint.py --img "my cool images folder\image_1.png" --prompt "a butterfly flying" --sampler ddim_sampler --scale 4 --steps 50
The image will then be inpainted with the prompt provided. The default inpainting mask size is 768x768 (as this is the default txt2img size) - if your image has different dimensions, you should make sure the mask fits in your image by using the --h (height) and --w (width) commands. The resulting image will have the dimensions as specified using --h and --w, and I got tensor errors when I used non conforming dimensions. If you receive errors, try to aim for a standard resolution, i.e. 512x768 instead of 511x821.
You can pass these commands:
inpaint.py [-h] --img "path\image.jpg" [--prompt PROMPT] [--negative_prompt NEGATIVE_PROMPT] [--steps STEPS] [--batch BATCH] [--scale SCALE] [--h H] [--w W] [--sampler SAMPLER] [--prior-scale PRIOR_SCALE] [--prior-steps PRIOR_STEPS]
I set the default cfg scale to 4 because this appeared to be the sweet spot before the entire image was overpainted. YMMV. I would prefer DDIM over the PLMS sampler for inpainting, the default is PLMS however.