Install Kandinsky 2.x Web UI and generate images

What is Kandinsky?

Kandinsky is a Russian-made image generation AI model that is considered an advanced AI system that generates art based on user input. 2.1 and 2.2 versions of Kandinsky are both publicly available, especially Kandinsky 2.2, which is said to generate realistic images, high resolution (1024×1024) ControlNet support, and the ability to generate more detailed and extensive scenes.

Kandinsky has the following features

  1. Multilingual support: Kandinsky is multilingual and can generate images with prompts in many languages, including Japanese.
  2. Text-conditional diffusion model: Kandinsky 2.2 is a text-conditional diffusion model based on unCLIP and latent diffusion. It consists of a transformer-based image prior model, an unet diffusion model, and a decoder.
  3. Technology integration of Dall-E 2 and Latent Diffusion: Kandinsky 2 is considered a model that combines the best parts of Dall-E 2 and Latent Diffusion and uses these technologies to generate images.
  4. Development by Sberbank and SberAI: Kandinsky 2.1 was launched by Sberbank and developed in cooperation with SberAI, AIRIA, and Sberdevices.

These features give Kandinsky the ability to generate high quality images based on user text input. In addition, Kandinsky is an open-source AI model and is available in many different languages, making it suitable for a wide range of users.

Install it on your own computer using the following GitHub page as a reference. You can do this in your local environment

https://github.com/seruva19/kubin

The python version is 3.10.11 and CUDA 11.8 is installed on Windows. Because I checked the script on GitHub and the version of CUDA installed in the virtual environment was 11.8.

Whether or not to match the version of CUDA in the Python virtual environment with the host system depends on the requirements of the project and the other tools and libraries used. However, there are some general guidelines

  1. Compatibility:
    • Certain libraries and frameworks (e.g. TensorFlow and PyTorch) are compatible with certain CUDA versions. It is important to use the recommended CUDA version to meet the requirements of these libraries.
  2. Stability:
    • Matching CUDA versions ensures compatibility and stability between the virtual environment and the host system. This is especially important when performing GPU-based calculations.
  3. Error Troubleshooting:
    • Using the same CUDA version in the virtual environment and on the host system simplifies error troubleshooting. Using different versions can make it more difficult to resolve errors due to inconsistencies between versions.
  4. PERFORMANCE:
    • In general, the latest CUDA versions offer the latest features and optimizations, which may improve performance. However, the latest version is not always the best. It is important to consider project requirements and compatibility.
  5. Upgrades and Downgrades:
    • It is possible to upgrade or downgrade CUDA versions, but this can be time-consuming, labor-intensive, and may cause unforeseen problems.

When setting up a virtual environment, it is important to consider the dependencies and requirements of your project and choose the most compatible CUDA version possible. Also, by matching the CUDA version in the virtual environment and the host system, many potential problems can be avoided.

Create a clone in the appropriate folder at the command prompt.

git clone https://github.com/seruva19/kubin.git

Navigate to the created directory.

cd kubin

At this location, run the batch file. The contents of the batch file are as follows

This group of commands is used to set up a Python virtual environment and install dependencies within that environment. The commands are described as follows

  1. python -m venv venv:
    • This command creates a virtual environment named venv. The virtual environment is used to isolate project dependencies and prevent interference with the Python environment on other systems.
  2. call venv\Scripts\activate.bat:
    • This command activates the venv virtual environment we just created. This ensures that the next command to be executed will be executed within this virtual environment (in the Windows environment). Python and pip commands will be applied to this virtual environment while it is active.
  3. pip install -r requirements.txt --no-cache-dir --ignore-installed --force-reinstall:
    • This command installs the dependencies listed in the requirements.txt file. In addition, several flags are specified: -f
      • --no-cache-dir: This flag tells pip to disable caching and fetch dependencies from the network each time they are downloaded.
      • --ignore-installed: This flag tells pip to ignore packages already installed and reinstall all packages listed in the requirements.
      • --force-reinstall: This flag instructs to force reinstallation of all packages listed in the requirement. This, in combination with the --ignore-installed flag, helps keep dependencies clean.

By executing these commands in sequence, you can set up a new virtual environment and install the project’s dependencies within that environment. This isolates the project environment from the Python environment on other systems and avoids dependency conflicts.

install.bat

Similarly, run the following batch file

install-torch.bat

This batch file contains the following

This group of commands activates the virtual environment, uninstalls the current installation of PyTorch, and installs a new version of PyTorch from a specific index URL. The commands are described below

  1. call venv\Scripts\activate.bat:
    • This command activates the previously created virtual environment named venv. This ensures that the next command to be executed will be executed within this virtual environment (in the Windows environment).
  2. pip uninstall -y torch:
    • This command uninstalls PyTorch from the virtual environment.The -y flag tells it to run without asking the user for confirmation during the uninstallation process.
  3. pip install torch --index-url https://download.pytorch.org/whl/cu118 --force-reinstall --no-deps:
    • This command installs PyTorch from a specific index URL. Each flag in the command has the following meaning: .
      • --index-url https://download.pytorch.org/whl/cu118: This flag tells pip to search for and download the PyTorch wheel file from the specified URL. This URL contains the PyTorch build for CUDA 11.8.
      • --force-reinstall: This flag tells PyTorch to force reinstallation, if it is already installed.
      • --no-deps: This flag tells PyTorch to install only PyTorch without installing any dependencies. This is useful if other dependencies are already installed or otherwise managed.

By running these commands, you can install a specific version of PyTorch within your virtual environment and make sure that version is compatible with CUDA 11.8. This is a useful set of commands to help you install PyTorch targeting a specific CUDA version.

Finally, run one more batch file

start.bat

This batch file runs a specific Python script after activating the virtual environment.

  1. call venv\Scripts\activate.bat:
    • This command activates the previously created virtual environment named venv. This ensures that the next command to be executed will be executed within this virtual environment (in the Windows environment).
  2. python src\kubin.py:
    • This command executes the Python script named kubin.py in the src directory. This script is executed using the Python interpreter in the virtual environment. This script performs some task and can use the libraries and dependencies installed in the virtual environment.

Once the process is successfully completed, you can access it in your browser.

http://127.0.0.1:7860

When generating images for the first time, wait a while as the model is downloaded.

Please share if you like it!
TOC