# Krea 2

Krea 2 (K2) là mô hình text-to-image dựa trên flow-matching, được xây dựng quanh một MMDiT single-stream với grouped-query attention. Bộ mã hóa văn bản Qwen3-VL cung cấp điều kiện: thay vì sử dụng hidden state cuối cùng, các hidden state từ mười hai lớp decoder được lấy theo từng token và được kết hợp bên trong transformer bởi một giai đoạn text-fusion nhỏ. Ảnh được giải mã bằng Qwen-Image VAE.

Hai checkpoint được phát hành, chia sẻ cùng một kiến trúc nhưng với các cài đặt sampler khuyến nghị khác nhau:

- **Cơ bản (midtrain)** — sử dụng bộ lấy mẫu đầy đủ với classifier-free guidance: `num_inference_steps=28`, `guidance_scale=4.5`.
- **TDM (đã chưng cất)** — được chưng cất để lấy mẫu trong vài bước, chạy với `num_inference_steps=8` và tắt hướng dẫn (`guidance_scale=0.0`).

`guidance_scale` tuân theo quy ước của Krea 2: velocity được tính bằng `cond + guidance_scale * (cond - uncond)` và guidance được kích hoạt khi `guidance_scale > 0` (điều này tương đương với công thức CFG thông thường với scale là `1 + guidance_scale`).

## Văn bản sang hình ảnh

```python
import torch
from diffusers import Krea2Pipeline

# Load from a local directory produced by the Krea 2 conversion (no hub repo yet).
pipe = Krea2Pipeline.from_pretrained("krea/Krea-2-Raw", dtype=torch.bfloat16)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

prompt = "a fox in the snow"
image = pipe(
    prompt,
    height=1024,
    width=1024,
    num_inference_steps=28,
    guidance_scale=4.5,
    generator=torch.Generator("cuda").manual_seed(0),
).images[0]
image.save("krea2.png")
```

Ngoài ra, chúng tôi còn cung cấp một ví dụ về việc sử dụng Krea2 Turbo :

```python
import torch
from diffusers import Krea2Pipeline

pipe = Krea2Pipeline.from_pretrained("krea/Krea-2-Turbo", dtype=torch.bfloat16)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

image = pipe(
    "a fox in the snow",
    height=1024,
    width=1024,
    num_inference_steps=8,
    guidance_scale=0.0,
    generator=torch.Generator("cuda").manual_seed(0),
).images[0]
image.save("krea2_turbo.png")
```

## Tải checkpoint dạng tệp đơn

```python
import torch
from diffusers import Krea2Pipeline, Krea2Transformer2DModel

transformer = Krea2Transformer2DModel.from_single_file(
    "https://huggingface.co/krea/Krea-2-Turbo/blob/main/turbo.safetensors", dtype=torch.bfloat16
)
pipe = Krea2Pipeline.from_pretrained("krea/Krea-2-Turbo", transformer=transformer, dtype=torch.bfloat16).to("cuda")
```

## Krea2Pipeline[[diffusers.Krea2Pipeline]]

#### diffusers.Krea2Pipeline[[diffusers.Krea2Pipeline]]

```python
diffusers.Krea2Pipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLQwenImage, text_encoder: Qwen3VLModel, tokenizer: AutoTokenizer, transformer: Krea2Transformer2DModel, text_encoder_select_layers: tuple[int, ...] | list[int] | None = None, is_distilled: bool = False, patch_size: int = 2)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/krea2/pipeline_krea2.py#L134)

**Tham số:**

scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/vi/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : trình lập lịch Euler flow-matching. Lịch sigma của Krea 2 là sự dịch chuyển thời gian mũ nhận thức độ phân giải, do đó cấu hình trình lập lịch được kỳ vọng sẽ đặt `use_dynamic_shifting=True` cùng với các tham số dịch chuyển Krea 2 (`base_shift=0.5`, `max_shift=1.15`, `base_image_seq_len=256`, `max_image_seq_len=6400`).

vae ([AutoencoderKLQwenImage](/docs/diffusers/main/vi/api/models/autoencoderkl_qwenimage#diffusers.AutoencoderKLQwenImage)) : Bộ tự mã hóa biến phân Qwen-Image (f8, 16 kênh tiềm ẩn) được sử dụng để giải mã các giá trị tiềm ẩn thành hình ảnh.

text_encoder ([PreTrainedModel](https://huggingface.co/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel)) : Một mô hình Qwen3-VL (ví dụ `Qwen3VLModel` của `Qwen/Qwen3-VL-4B-Instruct`). Pipeline tiêu thụ một chồng hidden states được lấy từ nhiều lớp decoder khác nhau thay vì hidden state cuối cùng.

tokenizer ([AutoTokenizer](https://huggingface.co/docs/transformers/main/en/model_doc/auto#transformers.AutoTokenizer)) : Bộ phân từ đi kèm với bộ mã hóa văn bản.

transformer ([Krea2Transformer2DModel](/docs/diffusers/main/vi/api/models/krea2_transformer2d#diffusers.Krea2Transformer2DModel)) : MMDiT luồng đơn của Krea 2, dự đoán vận tốc khớp dòng (flow-matching velocity).

text_encoder_select_layers (`tuple[int, ...]`, *tùy chọn*) : Các chỉ số trong tuple `hidden_states` của text encoder (0 là đầu ra embedding) mà trạng thái của chúng được xếp chồng theo từng token làm điều kiện văn bản cho transformer. Phải có `transformer.config.num_text_layers` mục.

is_distilled (`bool`, *tuỳ chọn*, mặc định là `False`) : Xác định xem transformer có phải là checkpoint được chưng cất theo ít bước (TDM/turbo) hay không. Khi `True`, một mức dịch chuyển bước thời gian cố định `mu=1.15` sẽ được sử dụng; ngược lại, `mu` sẽ được tính toán từ độ phân giải của hình ảnh.

patch_size (`int`, *optional*, mặc định là 2) : Độ dài cạnh của các ô vuông mà các biến tiềm ẩn được đóng gói vào trước khi đi vào transformer. Hệ số giảm mẫu từ pixel sang token hiệu dụng là `vae_scale_factor * patch_size`.

Pipeline Krea 2 cho việc tạo ảnh từ văn bản.

#### __call__[[diffusers.Krea2Pipeline.__call__]]

```python
__call__(prompt: str | list[str] | None = None, negative_prompt: str | list[str] | None = None, height: int = 1024, width: int = 1024, num_inference_steps: int = 28, sigmas: list[float] | None = None, guidance_scale: float = 4.5, num_images_per_prompt: int = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_embeds_mask: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds_mask: typing.Optional[torch.Tensor] = None, output_type: str | None = 'pil', return_dict: bool = True, callback_on_step_end: typing.Optional[typing.Callable[[int, int, dict], NoneType]] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], attention_kwargs: dict[str, typing.Any] | None = None, max_sequence_length: int = 512)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/krea2/pipeline_krea2.py#L445)

**Tham số:**

prompt (`str` hoặc `list[str]`, *tùy chọn*) : Prompt hoặc các prompt để hướng dẫn việc tạo ảnh. Nếu không được định nghĩa, cần phải truyền `prompt_embeds`.

negative_prompt (`str` hoặc `list[str]`, *tùy chọn*) : Prompt hoặc các prompt không được dùng để hướng dẫn tạo ảnh. Bỏ qua khi `guidance_scale <= 0`; mặc định là prompt rỗng khi guidance được bật.

height (`int`, mặc định là 1024) : Chiều cao của hình ảnh được tạo ra, tính bằng pixel. Làm tròn lên thành bội số của 16 nếu cần.

width (`int`, mặc định là 1024) : Độ rộng của hình ảnh được tạo ra, tính bằng pixel. Làm tròn lên thành bội số của 16 nếu cần.

num_inference_steps (`int`, mặc định là 28) : Số bước khử nhiễu. Sử dụng 28 cho checkpoint cơ bản (midtrain) và 8 cho checkpoint chưng cất ít bước (TDM).

sigmas (`list[float]`, *optional*) : Các sigma tùy chỉnh cho trình lập lịch. Nếu không được định nghĩa, lưới mặc định `linspace(1.0, 1/num_inference_steps, num_inference_steps)` sẽ được sử dụng (sự dịch chuyển nhận thức độ phân giải được áp dụng bên trong trình lập lịch).

guidance_scale (`float`, mặc định là 4.5) : Thang độ dẫn hướng không điều kiện (classifier-free guidance), tuân theo quy ước của Krea 2: vận tốc được tính bằng `cond + guidance_scale * (cond - uncond)` và dẫn hướng được kích hoạt khi `guidance_scale > 0` (điều này tương đương với công thức CFG thông thường với thang độ `1 + guidance_scale`). Đặt thành `0.0` để tắt (ví dụ: cho checkpoint TDM).

num_images_per_prompt (`int`, mặc định là 1) : Số lượng hình ảnh cần tạo cho mỗi prompt.

generator (`torch.Generator` hoặc `list[torch.Generator]`, *tùy chọn*) : Một hoặc nhiều [torch generator](https://pytorch.org/docs/stable/generated/torch.Generator.html) để đảm bảo quá trình sinh là tất định.

latents (`torch.Tensor`, *tùy chọn*) : Các latents nhiễu đã tạo trước ở dạng đóng gói `(batch_size, image_seq_len, in_channels)`, được lấy mẫu từ phân phối Gaussian, dùng làm đầu vào cho việc tạo ảnh.

prompt_embeds (`torch.Tensor`, *tùy chọn*) : Các vector nhúng văn bản đã tạo trước có hình dạng `(batch_size, text_seq_len, num_text_layers, text_hidden_dim)`. Nếu không được cung cấp, các vector nhúng sẽ được tạo từ `prompt`.

prompt_embeds_mask (`torch.Tensor`, *tùy chọn*) : Mặt nạ Boolean cho `prompt_embeds`; bắt buộc khi `prompt_embeds` được truyền vào.

negative_prompt_embeds (`torch.Tensor`, *tùy chọn*) : Các vector nhúng văn bản âm đã tạo trước; cùng bố cục với `prompt_embeds`.

negative_prompt_embeds_mask (`torch.Tensor`, *tùy chọn*) : Mặt nạ Boolean cho `negative_prompt_embeds`; bắt buộc khi `negative_prompt_embeds` được truyền vào.

output_type (`str`, *tùy chọn*, mặc định là `"pil"`) : Định dạng đầu ra của hình ảnh được tạo ra. Chọn giữa `"pil"`, `"np"`, `"pt"` hoặc `"latent"`.

return_dict (`bool`, *tùy chọn*, mặc định là `True`) : Có nên trả về một [Krea2PipelineOutput](/docs/diffusers/main/vi/api/pipelines/krea2#diffusers.pipelines.krea2.Krea2PipelineOutput) thay vì một tuple thông thường hay không.

callback_on_step_end (`Callable`, *tùy chọn*) : Một hàm được gọi vào cuối mỗi bước khử nhiễu với `callback_on_step_end(self, step, timestep, callback_kwargs)`.

callback_on_step_end_tensor_inputs (`list[str]`, *tùy chọn*, mặc định là `["latents"]`) : Danh sách các đầu vào tensor cho hàm `callback_on_step_end`. Phải là một tập con của `._callback_tensor_inputs`.

attention_kwargs (`dict`, *tùy chọn*) : Một từ điển kwargs mà nếu được chỉ định sẽ được truyền đến `AttentionProcessor` như đã định nghĩa dưới `self.processor` trong [diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py).

max_sequence_length (`int`, mặc định là 512) : Độ dài chuỗi văn bản cố định được transformer tiêu thụ; các prompt sẽ được đệm hoặc cắt ngắn để đạt độ dài này.

**Trả về:** [Krea2PipelineOutput](/docs/diffusers/main/vi/api/pipelines/krea2#diffusers.pipelines.krea2.Krea2PipelineOutput) hoặc `tuple`

[Krea2PipelineOutput](/docs/diffusers/main/vi/api/pipelines/krea2#diffusers.pipelines.krea2.Krea2PipelineOutput) nếu `return_dict` là True, ngược lại là một `tuple`, trong đó phần tử đầu tiên là một danh sách chứa các hình ảnh đã tạo.

Hàm được gọi khi gọi pipeline cho việc sinh.

Ví dụ:
```py
>>> import torch
>>> from diffusers import Krea2Pipeline

>>> # Load from a local directory produced by the Krea 2 conversion (no hub repo yet).
>>> pipe = Krea2Pipeline.from_pretrained("path/to/krea2-diffusers", torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")
>>> prompt = "a fox in the snow"
>>> # Base (midtrain) checkpoint defaults. For the few-step distilled (TDM) checkpoint use
>>> # `num_inference_steps=8, guidance_scale=0.0` instead.
>>> image = pipe(prompt, num_inference_steps=28, guidance_scale=4.5).images[0]
>>> image.save("krea2.png")
```

#### encode_prompt[[diffusers.Krea2Pipeline.encode_prompt]]

```python
encode_prompt(prompt: str | list[str], device: typing.Optional[torch.device] = None, num_images_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_embeds_mask: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 512)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/krea2/pipeline_krea2.py#L263)

**Tham số:**

prompt (`str` hoặc `list[str]`, *tùy chọn*) : prompt cần được mã hóa

device : (`torch.device`): thiết bị torch

num_images_per_prompt (`int`) : số lượng hình ảnh cần được tạo cho mỗi prompt

prompt_embeds (`torch.Tensor`, *tùy chọn*) : Các vector nhúng văn bản đã được tạo trước, có hình dạng `(batch_size, text_seq_len, num_text_layers, text_hidden_dim)`. Có thể được sử dụng để dễ dàng điều chỉnh các đầu vào văn bản, *ví dụ* như trọng số của prompt. Nếu không được cung cấp, các vector nhúng văn bản sẽ được tạo từ đối số đầu vào `prompt`.

prompt_embeds_mask (`torch.Tensor`, *tùy chọn*) : Mặt nạ boolean được tạo trước, đánh dấu các token văn bản hợp lệ, có hình dạng `(batch_size, text_seq_len)`. Bắt buộc khi truyền `prompt_embeds`.

max_sequence_length (`int`, mặc định là 512) : Độ dài chuỗi văn bản cố định được transformer tiêu thụ; các prompt sẽ được đệm hoặc cắt ngắn để đạt độ dài này.

#### get_text_hidden_states[[diffusers.Krea2Pipeline.get_text_hidden_states]]

```python
get_text_hidden_states(prompt: str | list[str], max_sequence_length: int = 512, device: typing.Optional[torch.device] = None)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/krea2/pipeline_krea2.py#L214)

Tokenize `prompt` thành bố cục Krea 2 có độ dài cố định và lấy các trạng thái ẩn của encoder đã chọn.

Trả về một tuple `(hidden_states, attention_mask)` có hình dạng `(batch_size, text_seq_len, num_text_layers, text_hidden_dim)` và `(batch_size, text_seq_len)` (bool).

#### prepare_position_ids[[diffusers.Krea2Pipeline.prepare_position_ids]]

```python
prepare_position_ids(text_seq_len: int, grid_height: int, grid_width: int, device: device)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/krea2/pipeline_krea2.py#L381)

Xây dựng tọa độ rotary `(text_seq_len + grid_height * grid_width, 3)` cho chuỗi kết hợp: các token văn bản nằm tại gốc tọa độ, các token ảnh mang tọa độ lưới tiềm ẩn `(0, h, w)` của chúng.

## Krea2PipelineOutput[[diffusers.pipelines.krea2.Krea2PipelineOutput]]

#### diffusers.pipelines.krea2.Krea2PipelineOutput[[diffusers.pipelines.krea2.Krea2PipelineOutput]]

```python
diffusers.pipelines.krea2.Krea2PipelineOutput(images: list[PIL.Image.Image] | numpy.ndarray)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/krea2/pipeline_output.py#L24)

**Tham số:**

images (`list[PIL.Image.Image]` hoặc `np.ndarray`) : Danh sách các hình ảnh PIL đã khử nhiễu có độ dài `batch_size` hoặc mảng numpy có hình dạng `(batch_size, height, width, num_channels)`.

Lớp đầu ra cho pipeline Krea 2.

## Modular

Krea 2 cũng có sẵn dưới dạng [pipeline module hóa](../../modular_diffusers/overview). Classifier-free guidance được cấu hình thông qua thành phần `guider` thay vì tham số gọi `guidance_scale`. Krea 2 sử dụng CFG neo vào điều kiện (cond-anchored CFG), tức là [ClassifierFreeGuidance](/docs/diffusers/main/vi/api/modular_diffusers/guiders#diffusers.ClassifierFreeGuidance) với `use_original_formulation=True`.

```python
import torch
from diffusers import ClassifierFreeGuidance, ModularPipeline

pipe = ModularPipeline.from_pretrained("krea/Krea-2-Raw")
pipe.load_components(dtype=torch.bfloat16)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

image = pipe(
    prompt="a fox in the snow",
    height=1024,
    width=1024,
    num_inference_steps=28,
    generator=torch.Generator("cuda").manual_seed(0),
).images[0]
image.save("krea2.png")
```

Ngoài ra, chúng tôi cung cấp một ví dụ về việc sử dụng Krea2 Turbo. Checkpoint đã được chưng cất (distilled) được ánh xạ đến một bộ khối riêng ([Krea2TurboAutoBlocks](/docs/diffusers/main/vi/api/pipelines/krea2#diffusers.Krea2TurboAutoBlocks)): nó chạy không có guidance (không có `guider`), không nhận negative prompt và lấy mẫu trong vài bước. `ModularPipeline.from_pretrained` tự động chọn các khối turbo từ cấu hình `is_distilled` của checkpoint, do đó không cần cấu hình guidance:

```python
import torch
from diffusers import ModularPipeline

pipe = ModularPipeline.from_pretrained("krea/Krea-2-Turbo")
pipe.load_components(dtype=torch.bfloat16)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

image = pipe(
    prompt="a fox in the snow",
    height=1024,
    width=1024,
    num_inference_steps=8,
    generator=torch.Generator("cuda").manual_seed(0),
).images[0]
image.save("krea2_turbo.png")
```

## Krea2ModularPipeline[[diffusers.Krea2ModularPipeline]]

#### diffusers.Krea2ModularPipeline[[diffusers.Krea2ModularPipeline]]

```python
diffusers.Krea2ModularPipeline(blocks: diffusers.modular_pipelines.modular_pipeline.ModularPipelineBlocks | None = None, pretrained_model_name_or_path: str | os.PathLike | None = None, components_manager: diffusers.modular_pipelines.components_manager.ComponentsManager | None = None, collection: str | None = None, workflow: str | None = None, modular_config_dict: dict[str, typing.Any] | None = None, config_dict: dict[str, typing.Any] | None = None, **kwargs)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/krea2/modular_pipeline.py#L19)

Một ModularPipeline cho Krea 2.

## Krea2AutoBlocks[[diffusers.Krea2AutoBlocks]]

#### diffusers.Krea2AutoBlocks[[diffusers.Krea2AutoBlocks]]

```python
diffusers.Krea2AutoBlocks()
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/krea2/modular_blocks_krea2.py#L106)

Auto Modular pipeline cho việc tạo ảnh từ văn bản sử dụng Krea 2: mã hóa văn bản -> khử nhiễu lõi (CFG đối xứng) -> giải mã.

Các quy trình làm việc được hỗ trợ:
- `text2image`: yêu cầu `prompt`

Các thành phần: text_encoder (`Qwen3VLModel`): Bộ mã hóa văn bản của Qwen3-VL. tokenizer (`AutoTokenizer`): Bộ phân từ đi kèm với bộ mã hóa văn bản. guider (`ClassifierFreeGuidance`) transformer (`Krea2Transformer2DModel`) scheduler (`FlowMatchEulerDiscreteScheduler`) vae (`AutoencoderKLQwenImage`) image_processor (`VaeImageProcessor`)

Đầu vào: prompt (`str`): Prompt hoặc các prompt để định hướng việc tạo ảnh. negative_prompt (`str`, *tùy chọn*): Prompt âm (negative prompt) cho CFG. max_sequence_length (`int`, *tùy chọn*, mặc định là 512): Độ dài chuỗi tối đa cho việc mã hóa prompt. num_images_per_prompt (`int`, *tùy chọn*, mặc định là 1): Số lượng ảnh cần tạo cho mỗi prompt. latents (`Tensor`, *tùy chọn*): Các latents nhiễu đã tạo sẵn cho việc tạo ảnh. height (`int`, *tùy chọn*, mặc định là 1024): Chiều cao của ảnh được tạo, tính bằng pixel. width (`int`, *tùy chọn*, mặc định là 1024): Chiều rộng của ảnh được tạo, tính bằng pixel. generator (`Generator`, *tùy chọn*): Bộ tạo (generator) của Torch để tạo ảnh theo cách tất định. num_inference_steps (`int`, *tùy chọn*, mặc định là 28): Số bước khử nhiễu. sigmas (`list`, *tùy chọn*): Lịch sigma tùy chỉnh (mặc định là một đường dốc tuyến tính). attention_kwargs (`dict`, *tùy chọn*): Các kwargs bổ sung cho các bộ xử lý attention. output_type (`str`, *tùy chọn*, mặc định là pil): Định dạng đầu ra: 'pil', 'np', 'pt'.

Đầu ra: hình ảnh (`list`): Các hình ảnh được tạo ra.

## Krea2TurboModularPipeline[[diffusers.Krea2TurboModularPipeline]]

#### diffusers.Krea2TurboModularPipeline[[diffusers.Krea2TurboModularPipeline]]

```python
diffusers.Krea2TurboModularPipeline(blocks: diffusers.modular_pipelines.modular_pipeline.ModularPipelineBlocks | None = None, pretrained_model_name_or_path: str | os.PathLike | None = None, components_manager: diffusers.modular_pipelines.components_manager.ComponentsManager | None = None, collection: str | None = None, workflow: str | None = None, modular_config_dict: dict[str, typing.Any] | None = None, config_dict: dict[str, typing.Any] | None = None, **kwargs)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/krea2/modular_pipeline.py#L54)

ModularPipeline cho checkpoint Krea 2 turbo (TDM) đã được chưng cất. Nó chạy mà không cần classifier-free guidance, do đó không nhận negative prompt và không có guider.

## Krea2TurboAutoBlocks[[diffusers.Krea2TurboAutoBlocks]]

#### diffusers.Krea2TurboAutoBlocks[[diffusers.Krea2TurboAutoBlocks]]

```python
diffusers.Krea2TurboAutoBlocks()
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/krea2/modular_blocks_krea2_turbo.py#L102)

Auto Modular pipeline để tạo ảnh từ văn bản sử dụng checkpoint Krea 2 turbo đã được chưng cất: mã hóa văn bản -> khử nhiễu lõi (không có hướng dẫn) -> giải mã.

Các quy trình làm việc được hỗ trợ:
- `text2image`: yêu cầu `prompt`

Các thành phần: text_encoder (`Qwen3VLModel`): Bộ mã hóa văn bản của Qwen3-VL. tokenizer (`AutoTokenizer`): Bộ phân từ đi kèm với bộ mã hóa văn bản. transformer (`Krea2Transformer2DModel`) scheduler (`FlowMatchEulerDiscreteScheduler`) vae (`AutoencoderKLQwenImage`) image_processor (`VaeImageProcessor`)

Inputs: prompt (`str`): Prompt hoặc các prompt để định hướng tạo ảnh. max_sequence_length (`int`, *tuỳ chọn*, mặc định là 512): Độ dài chuỗi tối đa cho việc mã hóa prompt. num_images_per_prompt (`int`, *tuỳ chọn*, mặc định là 1): Số lượng ảnh cần tạo cho mỗi prompt. latents (`Tensor`, *tuỳ chọn*): Các latents nhiễu đã tạo sẵn cho việc tạo ảnh. height (`int`, *tuỳ chọn*, mặc định là 1024): Chiều cao của ảnh được tạo, tính bằng pixel. width (`int`, *tuỳ chọn*, mặc định là 1024): Chiều rộng của ảnh được tạo, tính bằng pixel. generator (`Generator`, *tuỳ chọn*): Bộ tạo Torch cho việc tạo ảnh tất định. num_inference_steps (`int`, *tuỳ chọn*, mặc định là 8): Số bước khử nhiễu. sigmas (`list`, *tuỳ chọn*): Lịch sigma tùy chỉnh (mặc định là một đường dốc tuyến tính). attention_kwargs (`dict`, *tuỳ chọn*): Các kwargs bổ sung cho các bộ xử lý attention. output_type (`str`, *tuỳ chọn*, mặc định là pil): Định dạng đầu ra: 'pil', 'np', 'pt'.

Đầu ra: hình ảnh (`list`): Các hình ảnh được tạo ra.

