Model reference · open weights
CoTyle is an open-weight image model from Kwai-Kolors. CoTyle (BF16) weighs 56.6 GB; the smallest configuration that runs it is H100 80 GB.
Summary of the Kwai-Kolors/CoTyle model card, 2026-10-01
What it is
| Released by | Kwai-Kolors |
|---|---|
| Released | 2025-10-15 |
| Parameters | 20.4B |
| VRAM | 56.6 GB for the weights |
What it runs on
| Card | One image | Memory |
|---|---|---|
| RTX 3060 12 GB … L40S 48 GB | does not fit | |
| A100 80 GB | fits | 78.2 GB |
| H100 80 GB | fits | 78.1 GB |
| RTX PRO 6000 Blackwell 96 GB | fits | 93.8 GB |
| DGX Spark (GB10) 128 GB unified | fits | 107 GB |
| H200 141 GB | fits | 138 GB |
| B200 180 GB | fits | 176 GB |
From the model card
This repository offers the official code of the paper "A Style is Worth One Code: Unlocking Code-to-Style Image Generation with Discrete Style Space". We provide both an Open-Source Version (based on Qwen-Image) and a Commercial Version (based on Kolors). If you are a professional developer and interested in further developing the CoTyle Open-Source Version, please follow the tutorial below. The Commercial Version is coming soon.
class="center">
Innovative visual stylization is a cornerstone of artistic creation, yet generating novel and consistent visual styles remains a significant challenge. Existing generative approaches typically rely on lengthy textual prompts, reference images, or parameter-efficient fine-tuning to guide style-aware image synthesis, but often struggle with style consistency, limited novelty, and complex style representations. In this paper, we affirm that a style is worth one numerical code by introducing the novel task, code-to-style image generation, which produces images with novel, consistent visual styles conditioned solely on a numerical style code. To date, this field has only been primarily explored by the industry (e.g., Midjourney), with no open-source research from the academic community. To fill this gap, we propose CoTyle, the first open-source method for this task. Specifically, we first train a discrete style codebook from a collection of images to extract style embeddings. These embeddings are used to condition a text-to-image diffusion model (T2I-DM) for style-consistent generation. Subsequently, we train an autoregressive transformer on the quantized style codes to model their distribution, allowing the synthesis of novel style codes. During inference, a numerical code maps to a unique style sequence, which guides the diffusion process to produce images in the corresponding style. Unlike existing methods, our approach offers unparalleled simplicity and diversity, unlocking a vast space of reproducible styles from minimal input. Extensive experiments validate that CoTyle effectively turns a numerical code into a style controller, demonstrating a style is worth one code.
Run the following command to install the requirements.
git clone https://github.com/Kwai-Kolors/CoTyle
cd CoTyle
conda create -n cotyle python=3.10
conda activate cotyle
pip install torch==2.6.0 torchvision==0.21.0
pip install -e git+https://github.com/Lakonik/piFlow.git@b1ef16e5e305251bccdfeac2a0e3d0ef339b974a#egg=lakonlab --no-build-isolation
pip install -r requirements.txt
# After running, some dependency errors may appear (don’t meet lakonlab’s requirements).
# This is normal and can be ignored.
Please download the checkpoints and put them to the ./pretrained_models directory.
You can download them from Hugging Face.
git lfs install
git clone https://huggingface.co/Kwai-Kolors/CoTyle
mv CoTyle pretrained_models
For a quick walkthrough of the inference pipeline, we recommend generating a single image (see Single-Sample Generation). To intuitively experience the powerful capabilities of CoTyle, we recommend generating a batch of images (see Batch-Sample Generation), which by default produces 42 images (7 style codes × 6 prompts).
Run the following command to generate a batch of images. By default, 7 rows and 6 columns of images will be generated, where all images in each row are produced using the same style code, and all images in each column are generated using the same prompt.
You can adjust the --style_code and the content in ./test_prompts.txt to obtain the desired outputs.
This process may take considerable time.
Therefore, we provide an accelerated version based on piFlow, which requires only 4 denoising steps; however, this approach produces lower image quality.
Enable --accelerate to activate piFlow.
python inference_batch.py --model_path ./pretrained_models \
--style_code 1234567 5201314 13415926 886 20010627 996007 2333 \
--prompt_file_path ./test_prompts.txt \
--output_path outputs \
--seed 1024 \
--accelerate
If time permits, we strongly recommend executing the command below.
python inference_batch.py --model_path ./pretrained_models \
--style_code 1234567 5201314 13415926 886 20010627 996007 2333 \
--prompt_file_path ./test_prompts.txt \
--output_path outputs \
--seed 1024 \
After successful execution, you will obtain the following results: class="center">
Execute the following code for single-sample inference. You can generate desired results by adjusting the --style_code and --prompt.
python inference.py --model_path ./pretrained_models \
--style_code 1234567 \
--prompt "A lovely crystal snake spirit, slender and nimble, wears an exquisite crystal crown atop its head. Its scales are translucent, shimmering like crystal, its eyes are bright and round, and its expression is lively. Its body coils naturally, its tail gracefully curved, its overall posture harmonious and beautifulQuoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.
Running it yourself
Rent a machine by the hour. Runs as it is with diffusers, on the machine, in Python.
# on your rented machine: pip install diffusers transformers accelerate
import torch
from diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained("Kwai-Kolors/CoTyle", torch_dtype=torch.bfloat16).to("cuda")
image = pipe(prompt="a red bicycle on a cobbled street").images[0]
image.save("/workspace/out.png")