#
# Được cấp phép theo Giấy phép Apache, Phiên bản 2.0 (gọi là "Giấy phép");
# bạn có thể không sử dụng tệp này ngoại trừ tuân thủ theo Giấy phép.
# Bạn có thể nhận được một bản sao của Giấy phép tại
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Trừ khi được yêu cầu bởi luật pháp có hiệu lực hoặc được thỏa thuận bằng văn bản, phần mềm
# được phân phối theo Giấy phép được phân phối trên cơ sở
# KHÔNG CÓ BẢO HÀNH HOẶC ĐIỀU KIỆN DƯỚI BẤT KỲ HÌNH THỨC NÀO, dù được nêu rõ hay ngụ ý.
# Xem Giấy phép để biết ngôn ngữ cụ thể điều chỉnh các quyền và
# các hạn chế theo Giấy phép.
-->

# OmniGen

[OmniGen: Unified Image Generation](https://huggingface.co/papers/2409.11340) từ BAAI, bởi Shitao Xiao, Yueze Wang, Junjie Zhou, Huaying Yuan, Xingrun Xing, Ruiran Yan, Chaofan Li, Shuting Wang, Tiejun Huang, Zheng Liu.

Tóm tắt từ bài báo là:

*Sự ra đời của các Mô hình Ngôn ngữ Lớn (LLM) đã thống nhất các tác vụ tạo ngôn ngữ và cách mạng hóa tương tác giữa con người và máy móc. Tuy nhiên, trong lĩnh vực tạo ảnh, một mô hình thống nhất có khả năng xử lý nhiều tác vụ khác nhau trong cùng một khung kiến trúc vẫn chưa được khám phá nhiều. Trong công trình này, chúng tôi giới thiệu OmniGen, một mô hình khuếch tán mới cho tạo ảnh thống nhất. OmniGen có các đặc điểm sau: 1) Thống nhất: OmniGen không chỉ thể hiện khả năng tạo ảnh từ văn bản mà còn hỗ trợ nội tại nhiều tác vụ hạ nguồn khác nhau, chẳng hạn như chỉnh sửa ảnh, tạo ảnh theo chủ thể và tạo ảnh có điều kiện thị giác. 2) Đơn giản: Kiến trúc của OmniGen được đơn giản hóa cao, loại bỏ nhu cầu về các plugin bổ sung. Hơn nữa, so với các mô hình khuếch tán hiện có, nó thân thiện hơn với người dùng và có thể hoàn thành các tác vụ phức tạp theo hướng dẫn từ đầu đến cuối mà không cần các bước trung gian bổ sung, qua đó đơn giản hóa đáng kể quy trình tạo ảnh. 3) Chuyển giao kiến thức: Nhờ học tập theo định dạng thống nhất, OmniGen chuyển giao kiến thức hiệu quả giữa các tác vụ khác nhau, quản lý các tác vụ và miền chưa từng thấy, và thể hiện các khả năng mới. Chúng tôi cũng khám phá khả năng suy luận của mô hình và các ứng dụng tiềm năng của cơ chế chuỗi suy nghĩ. Công trình này đại diện cho nỗ lực đầu tiên về một mô hình tạo ảnh đa dụng, và chúng tôi sẽ phát hành tài nguyên của mình tại https://github.com/VectorSpaceLab/OmniGen để thúc đẩy các tiến bộ trong tương lai.*

> [!TIP]
> Hãy chắc chắn xem qua [hướng dẫn](../../using-diffusers/schedulers) về Schedulers để tìm hiểu cách khám phá sự đánh đổi giữa tốc độ và chất lượng của scheduler, và xem phần [tái sử dụng các thành phần giữa các pipeline](../../using-diffusers/loading#reusing-models-in-multiple-pipelines) để tìm hiểu cách nạp các thành phần giống nhau vào nhiều pipeline một cách hiệu quả.

Pipeline này được đóng góp bởi [staoxiao](https://github.com/staoxiao). Mã nguồn gốc có thể được tìm thấy [tại đây](https://github.com/VectorSpaceLab/OmniGen). Trọng số gốc có thể được tìm thấy tại [hf.co/shitao](https://huggingface.co/Shitao/OmniGen-v1).

## Tải các điểm kiểm tra của mô hình

Trọng số mô hình có thể được lưu trong các thư mục con riêng biệt trên Hub hoặc cục bộ, trong trường hợp đó, bạn nên sử dụng phương thức [from_pretrained()](/docs/diffusers/main/vi/api/pipelines/overview#diffusers.DiffusionPipeline.from_pretrained).

```python
import torch
from diffusers import OmniGenPipeline

pipe = OmniGenPipeline.from_pretrained("Shitao/OmniGen-v1-diffusers", dtype=torch.bfloat16)
```

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

Đối với text-to-image, hãy truyền một text prompt. Mặc định, OmniGen tạo ra hình ảnh kích thước 1024x1024. Bạn có thể thử đặt các tham số `height` và `width` để tạo hình ảnh với kích thước khác.

```python
import torch
from diffusers import OmniGenPipeline

pipe = OmniGenPipeline.from_pretrained(
    "Shitao/OmniGen-v1-diffusers",
    dtype=torch.bfloat16
)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

prompt = "Realistic photo. A young woman sits on a sofa, holding a book and facing the camera. She wears delicate silver hoop earrings adorned with tiny, sparkling diamonds that catch the light, with her long chestnut hair cascading over her shoulders. Her eyes are focused and gentle, framed by long, dark lashes. She is dressed in a cozy cream sweater, which complements her warm, inviting smile. Behind her, there is a table with a cup of water in a sleek, minimalist blue mug. The background is a serene indoor setting with soft natural light filtering through a window, adorned with tasteful art and flowers, creating a cozy and peaceful ambiance. 4K, HD."
image = pipe(
    prompt=prompt,
    height=1024,
    width=1024,
    guidance_scale=3,
    generator=torch.Generator(device="cpu").manual_seed(111),
).images[0]
image.save("output.png")
```

    

## Chỉnh sửa hình ảnh

OmniGen hỗ trợ đầu vào đa phương thức. Khi đầu vào bao gồm một hình ảnh, bạn cần thêm một ký tự thay thế `<img><|image_1|></img>` trong prompt văn bản để đại diện cho hình ảnh đó. Khuyến nghị bật `use_input_image_size_as_output` để giữ cho hình ảnh đã chỉnh sửa có cùng kích thước với hình ảnh gốc.

```python
import torch
from diffusers import OmniGenPipeline
from diffusers.utils import load_image 

pipe = OmniGenPipeline.from_pretrained(
    "Shitao/OmniGen-v1-diffusers",
    dtype=torch.bfloat16
)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

prompt="<img><|image_1|></img> Remove the woman's earrings. Replace the mug with a clear glass filled with sparkling iced cola."
input_images=[load_image("https://raw.githubusercontent.com/VectorSpaceLab/OmniGen/main/imgs/docs_img/t2i_woman_with_book.png")]
image = pipe(
    prompt=prompt, 
    input_images=input_images, 
    guidance_scale=2, 
    img_guidance_scale=1.6,
    use_input_image_size_as_output=True,
    generator=torch.Generator(device="cpu").manual_seed(222)
).images[0]
image.save("output.png")
```

  
    
    ảnh gốc
  
  
    
    hình ảnh đã chỉnh sửa
  

OmniGen có một số tính năng thú vị, chẳng hạn như suy luận trực quan, như được minh họa trong ví dụ bên dưới.

```python
prompt="If the woman is thirsty, what should she take? Find it in the image and highlight it in blue. <img><|image_1|></img>"
input_images=[load_image("https://raw.githubusercontent.com/VectorSpaceLab/OmniGen/main/imgs/docs_img/edit.png")]
image = pipe(
    prompt=prompt, 
    input_images=input_images, 
    guidance_scale=2, 
    img_guidance_scale=1.6,
    use_input_image_size_as_output=True,
    generator=torch.Generator(device="cpu").manual_seed(0)
).images[0]
image.save("output.png")
```

    

## Tạo có thể kiểm soát

OmniGen có thể xử lý một số tác vụ thị giác máy tính kinh điển. Như minh họa bên dưới, OmniGen có thể phát hiện bộ xương người trong các hình ảnh đầu vào, điều này có thể được sử dụng làm điều kiện điều khiển để tạo ra các hình ảnh mới.

```python
import torch
from diffusers import OmniGenPipeline
from diffusers.utils import load_image 

pipe = OmniGenPipeline.from_pretrained(
    "Shitao/OmniGen-v1-diffusers",
    dtype=torch.bfloat16
)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

prompt="Detect the skeleton of human in this image: <img><|image_1|></img>"
input_images=[load_image("https://raw.githubusercontent.com/VectorSpaceLab/OmniGen/main/imgs/docs_img/edit.png")]
image1 = pipe(
    prompt=prompt, 
    input_images=input_images, 
    guidance_scale=2, 
    img_guidance_scale=1.6,
    use_input_image_size_as_output=True,
    generator=torch.Generator(device="cpu").manual_seed(333)
).images[0]
image1.save("image1.png")

prompt="Generate a new photo using the following picture and text as conditions: <img><|image_1|></img>\n A young boy is sitting on a sofa in the library, holding a book. His hair is neatly combed, and a faint smile plays on his lips, with a few freckles scattered across his cheeks. The library is quiet, with rows of shelves filled with books stretching out behind him."
input_images=[load_image("https://raw.githubusercontent.com/VectorSpaceLab/OmniGen/main/imgs/docs_img/skeletal.png")]
image2 = pipe(
    prompt=prompt, 
    input_images=input_images, 
    guidance_scale=2, 
    img_guidance_scale=1.6,
    use_input_image_size_as_output=True,
    generator=torch.Generator(device="cpu").manual_seed(333)
).images[0]
image2.save("image2.png")
```

  
    
    ảnh gốc
  
  
    
    khung xương được phát hiện
  
  
    
    từ khung xương sang hình ảnh
  

OmniGen cũng có thể sử dụng trực tiếp các thông tin liên quan từ hình ảnh đầu vào để tạo ra hình ảnh mới.

```python
import torch
from diffusers import OmniGenPipeline
from diffusers.utils import load_image 

pipe = OmniGenPipeline.from_pretrained(
    "Shitao/OmniGen-v1-diffusers",
    dtype=torch.bfloat16
)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

prompt="Following the pose of this image <img><|image_1|></img>, generate a new photo: A young boy is sitting on a sofa in the library, holding a book. His hair is neatly combed, and a faint smile plays on his lips, with a few freckles scattered across his cheeks. The library is quiet, with rows of shelves filled with books stretching out behind him."
input_images=[load_image("https://raw.githubusercontent.com/VectorSpaceLab/OmniGen/main/imgs/docs_img/edit.png")]
image = pipe(
    prompt=prompt, 
    input_images=input_images, 
    guidance_scale=2, 
    img_guidance_scale=1.6,
    use_input_image_size_as_output=True,
    generator=torch.Generator(device="cpu").manual_seed(0)
).images[0]
image.save("output.png")
```

  
    
    hình ảnh được tạo
  

## Giữ nguyên ID và đối tượng

OmniGen có thể tạo ra nhiều hình ảnh dựa trên các nhân vật và đối tượng trong hình ảnh đầu vào và hỗ trợ nhập đồng thời nhiều hình ảnh. Ngoài ra, OmniGen có thể trích xuất các đối tượng mong muốn từ một hình ảnh chứa nhiều đối tượng dựa trên các chỉ dẫn.

```python
import torch
from diffusers import OmniGenPipeline
from diffusers.utils import load_image 

pipe = OmniGenPipeline.from_pretrained(
    "Shitao/OmniGen-v1-diffusers",
    dtype=torch.bfloat16
)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

prompt="A man and a woman are sitting at a classroom desk. The man is the man with yellow hair in <img><|image_1|></img>. The woman is the woman on the left of <img><|image_2|></img>"
input_image_1 = load_image("https://raw.githubusercontent.com/VectorSpaceLab/OmniGen/main/imgs/docs_img/3.png")
input_image_2 = load_image("https://raw.githubusercontent.com/VectorSpaceLab/OmniGen/main/imgs/docs_img/4.png")
input_images=[input_image_1, input_image_2]
image = pipe(
    prompt=prompt, 
    input_images=input_images, 
    height=1024,
    width=1024,
    guidance_scale=2.5, 
    img_guidance_scale=1.6,
    generator=torch.Generator(device="cpu").manual_seed(666)
).images[0]
image.save("output.png")
```

  
    
    input_image_1
  
  
    
    input_image_2
  
  
    
    hình ảnh được tạo
  

```py
import torch
from diffusers import OmniGenPipeline
from diffusers.utils import load_image 

pipe = OmniGenPipeline.from_pretrained(
    "Shitao/OmniGen-v1-diffusers",
    dtype=torch.bfloat16
)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

prompt="A woman is walking down the street, wearing a white long-sleeve blouse with lace details on the sleeves, paired with a blue pleated skirt. The woman is <img><|image_1|></img>. The long-sleeve blouse and a pleated skirt are <img><|image_2|></img>."
input_image_1 = load_image("https://raw.githubusercontent.com/VectorSpaceLab/OmniGen/main/imgs/docs_img/emma.jpeg")
input_image_2 = load_image("https://raw.githubusercontent.com/VectorSpaceLab/OmniGen/main/imgs/docs_img/dress.jpg")
input_images=[input_image_1, input_image_2]
image = pipe(
    prompt=prompt, 
    input_images=input_images, 
    height=1024,
    width=1024,
    guidance_scale=2.5, 
    img_guidance_scale=1.6,
    generator=torch.Generator(device="cpu").manual_seed(666)
).images[0]
image.save("output.png")
```

  
    
    hình ảnh người
  
  
    
    ảnh mặc quần áo
  
  
    
    hình ảnh được tạo
  

## Tối ưu hóa khi sử dụng nhiều hình ảnh 

Đối với tác vụ tạo ảnh từ văn bản, OmniGen yêu cầu chi phí bộ nhớ và thời gian tối thiểu (9GB bộ nhớ và 31 giây cho một ảnh 1024x1024 trên GPU A800). Tuy nhiên, khi sử dụng ảnh đầu vào, chi phí tính toán sẽ tăng lên.

Dưới đây là một số hướng dẫn giúp bạn giảm chi phí tính toán khi sử dụng nhiều hình ảnh. Các thí nghiệm được thực hiện trên GPU A800 với hai hình ảnh đầu vào.

Tương tự các pipeline khác, bạn có thể giảm mức sử dụng bộ nhớ bằng cách offload model: `pipe.enable_model_cpu_offload()` hoặc `pipe.enable_sequential_cpu_offload() `. Trong OmniGen, bạn cũng có thể giảm chi phí tính toán bằng cách giảm `max_input_image_size`. Mức tiêu thụ bộ nhớ cho các kích thước ảnh khác nhau được hiển thị trong bảng dưới đây:

| Phương pháp                    | Độ sử dụng bộ nhớ |
|---------------------------|--------------|
| max_input_image_size=1024 | 40GB         |
| max_input_image_size=512  | 17GB         |
| max_input_image_size=256  | 14GB         |

## OmniGenPipeline[[diffusers.OmniGenPipeline]]

#### diffusers.OmniGenPipeline[[diffusers.OmniGenPipeline]]

```python
diffusers.OmniGenPipeline(transformer: OmniGenTransformer2DModel, scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKL, tokenizer: LlamaTokenizer)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/omnigen/pipeline_omnigen.py#L119)

**Tham số:**

transformer ([OmniGenTransformer2DModel](/docs/diffusers/main/vi/api/models/omnigen_transformer#diffusers.OmniGenTransformer2DModel)) : Kiến trúc Transformer tự hồi quy cho OmniGen.

scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/vi/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : Một trình lập lịch được sử dụng kết hợp với `transformer` để khử nhiễu các latent ảnh đã mã hóa.

vae ([AutoencoderKL](/docs/diffusers/main/vi/api/models/autoencoderkl#diffusers.AutoencoderKL)) : Mô hình Variational Auto-Encoder (VAE) để mã hóa và giải mã hình ảnh sang và từ các biểu diễn ẩn.

tokenizer (`LlamaTokenizer`) : Bộ phân tách văn bản của lớp [LlamaTokenizer](https://huggingface.co/docs/transformers/main/model_doc/llama#transformers.LlamaTokenizer).

Pipeline OmniGen để tạo ảnh từ đa phương thức.

Tham khảo: https://huggingface.co/papers/2409.11340

#### __call__[[diffusers.OmniGenPipeline.__call__]]

```python
__call__(prompt: str | list[str], input_images: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor], list[typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]]] = None, height: int | None = None, width: int | None = None, num_inference_steps: int = 50, max_input_image_size: int = 1024, timesteps: list[int] = None, guidance_scale: float = 2.5, img_guidance_scale: float = 1.6, use_input_image_size_as_output: bool = False, num_images_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, output_type: str | None = 'pil', return_dict: bool = True, callback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'])
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/omnigen/pipeline_omnigen.py#L275)

**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 đầu vào bao gồm các hình ảnh, cần thêm các placeholder `<img><|image_i|></img>` trong prompt để chỉ định vị trí của hình ảnh thứ i.

input_images (`PipelineImageInput` hoặc `list[PipelineImageInput]`, *tùy chọn*) : Danh sách các hình ảnh đầu vào. Chúng tôi sẽ thay thế "<|image_i|>" trong prompt bằng hình ảnh thứ i trong danh sách.

height (`int`, *optional*, mặc định là self.unet.config.sample_size * self.vae_scale_factor) : Chiều cao của hình ảnh được tạo ra, tính bằng pixel. Giá trị mặc định là 1024 để đạt kết quả tốt nhất.

width (`int`, *optional*, mặc định là self.unet.config.sample_size * self.vae_scale_factor) : Độ rộng tính bằng pixel của hình ảnh được tạo ra. Mặc định được đặt là 1024 để đạt kết quả tốt nhất.

num_inference_steps (`int`, *optional*, mặc định là 50) : Số bước khử nhiễu. Số bước khử nhiễu nhiều hơn thường dẫn đến hình ảnh có chất lượng cao hơn, với cái giá là suy luận chậm hơn.

max_input_image_size (`int`, *optional*, mặc định là 1024) : kích thước tối đa của ảnh đầu vào, sẽ được sử dụng để cắt ảnh đầu vào xuống kích thước tối đa

timesteps (`list[int]`, *optional*) : Các bước thời gian (timesteps) tùy chỉnh để sử dụng cho quá trình khử nhiễu với các trình lập lịch (scheduler) hỗ trợ tham số `timesteps` trong phương thức `set_timesteps` của chúng. Nếu không được định nghĩa, hành vi mặc định khi `num_inference_steps` được truyền vào sẽ được sử dụng. Phải được sắp xếp theo thứ tự giảm dần.

guidance_scale (`float`, *optional*, mặc định là 2.5) : Thang độ dẫn hướng như được định nghĩa trong [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598). `guidance_scale` được định nghĩa là `w` của phương trình 2. trong [Imagen Paper](https://huggingface.co/papers/2205.11487). Thang độ dẫn hướng được kích hoạt bằng cách đặt `guidance_scale > 1`. Thang độ dẫn hướng cao hơn khuyến khích tạo ra các hình ảnh gắn kết chặt chẽ với `prompt` văn bản, thường phải đánh đổi bằng chất lượng hình ảnh thấp hơn.

img_guidance_scale (`float`, *tuỳ chọn*, mặc định là 1.6) : Được định nghĩa là phương trình 3 trong [Instrucpix2pix](https://huggingface.co/papers/2211.09800).

use_input_image_size_as_output (bool, mặc định là False) : có sử dụng kích thước ảnh đầu vào làm kích thước ảnh đầu ra hay không, có thể dùng cho đầu vào một ảnh, ví dụ như tác vụ chỉnh sửa ảnh

num_images_per_prompt (`int`, *tuỳ chọn*, 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 một danh sách [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 đã được tạo trước, được lấy mẫu từ phân phối Gaussian, dùng làm đầu vào cho việc tạo ảnh. Có thể được sử dụng để tinh chỉnh cùng một quá trình tạo với các prompt khác nhau. Nếu không được cung cấp, một tensor latents sẽ được tạo ra bằng cách lấy mẫu sử dụng `generator` ngẫu nhiên được cung cấp.

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. Chọn giữa [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` hoặc `np.array`.

return_dict (`bool`, *tùy chọn*, mặc định là `True`) : Có nên trả về một `~pipelines.flux.FluxPipelineOutput` 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 trong quá trình suy luận. Hàm này được gọi với các đối số sau: `callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)`. `callback_kwargs` sẽ bao gồm một danh sách tất cả các tensor như được chỉ định bởi `callback_on_step_end_tensor_inputs`.

callback_on_step_end_tensor_inputs (`list`, *optional*) : Danh sách các đầu vào tensor cho hàm `callback_on_step_end`. Các tensor được chỉ định trong danh sách sẽ được truyền dưới dạng tham số `callback_kwargs`. Bạn chỉ có thể bao gồm các biến được liệt kê trong thuộc tính `._callback_tensor_inputs` của lớp pipeline của bạn.

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

[ImagePipelineOutput](/docs/diffusers/main/vi/api/pipelines/consistency_models#diffusers.ImagePipelineOutput) nếu `return_dict` là True, ngược lại là một `tuple`. Khi trả về tuple, 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 OmniGenPipeline

>>> pipe = OmniGenPipeline.from_pretrained("Shitao/OmniGen-v1-diffusers", torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")

>>> prompt = "A cat holding a sign that says hello world"
>>> # Depending on the variant being used, the pipeline call will slightly vary.
>>> # Refer to the pipeline documentation for more details.
>>> image = pipe(prompt, num_inference_steps=50, guidance_scale=2.5).images[0]
>>> image.save("output.png")
```

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

#### encode_input_images[[diffusers.OmniGenPipeline.encode_input_images]]

```python
encode_input_images(input_pixel_values: list[torch.Tensor], device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```

[Nguồn](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/omnigen/pipeline_omnigen.py#L169)

**Tham số:**

input_pixel_values : pixel đã chuẩn hóa của các ảnh đầu vào

device --

lấy embedding tiếp tục của hình ảnh đầu vào bằng VAE

Trả về: torch.Tensor

