# LongCat-Image

  

我们推出了 LongCat-Image，这是一款开创性的开源双语（中英）图像生成基础模型，旨在解决当前主流模型中普遍存在的多语言文本渲染、照片级真实感、部署效率以及开发者易用性方面的核心挑战。

### 主要功能
- 🌟 **卓越的效率与性能**：仅凭借 **6B 参数**，LongCat-Image 在多项基准测试中超越了多个规模数倍于它的开源模型，充分展现了高效模型设计的巨大潜力。
- 🌟 **卓越的编辑性能**：LongCat-Image-Edit 模型在开源模型中达到了最先进的性能，在指令遵循和图像质量方面表现领先，并具备出色的视觉一致性。
- 🌟 **强大的中文文本渲染能力**：与现有的 SOTA 开源模型相比，LongCat-Image 在渲染常用汉字方面展现出更高的准确性和稳定性，并实现了对中文字典的行业领先覆盖。
- 🌟 **出色的照片级真实感**：通过创新的数据策略和训练框架，LongCat-Image 在生成的图像中实现了出色的照片级真实感。
- 🌟 **全面的开源生态系统**：我们提供完整的工具链，从中间检查点到完整的训练代码，大幅降低了进一步研究和开发的门槛。

有关更多详细信息，请参阅全面的 [***LongCat-Image 技术报告***](https://arxiv.org/abs/2412.11963)

## 使用示例

```py
import torch
import diffusers
from diffusers import LongCatImagePipeline

weight_dtype = torch.bfloat16
pipe = LongCatImagePipeline.from_pretrained("meituan-longcat/LongCat-Image", dtype=torch.bfloat16 )
pipe.to('cuda')  # or "mps", "xpu", "cpu"
# pipe.enable_model_cpu_offload()

prompt = '一个年轻的亚裔女性，身穿黄色针织衫，搭配白色项链。她的双手放在膝盖上，表情恬静。背景是一堵粗糙的砖墙，午后的阳光温暖地洒在她身上，营造出一种宁静而温馨的氛围。镜头采用中距离视角，突出她的神态和服饰的细节。光线柔和地打在她的脸上，强调她的五官和饰品的质感，增加画面的层次感与亲和力。整个画面构图简洁，砖墙的纹理与阳光的光影效果相得益彰，突显出人物的优雅与从容。'
image = pipe(
    prompt,
    height=768,
    width=1344,
    guidance_scale=4.0,
    num_inference_steps=50,
    num_images_per_prompt=1,
    generator=torch.Generator("cpu").manual_seed(43),
    enable_cfg_renorm=True,
    enable_prompt_rewrite=True,
).images[0]
image.save(f'./longcat_image_t2i_example.png')
```

此流水线由 LongCat-Image 团队贡献。原始代码库可在[此处](https://github.com/meituan-longcat/LongCat-Image)找到。

可用模型：

  
    
      
        模型 类型 描述 下载链接
      
    
    
      
        LongCat&#8209;Image 文生图最终版发布。开箱即用的标准推理模型。
        
          🤗&nbsp;Huggingface
        
      
      
        LongCat&#8209;Image&#8209;Dev 文生图开发。中期训练检查点，适用于微调。
        
          🤗&nbsp;Huggingface
        
      
      
        LongCat&#8209;Image&#8209;Edit 图像编辑 专用于图像编辑的模型。
        
          🤗&nbsp;Huggingface
        
      
    
  

## LongCatImagePipeline[[diffusers.LongCatImagePipeline]]

#### diffusers.LongCatImagePipeline[[diffusers.LongCatImagePipeline]]

```python
diffusers.LongCatImagePipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKL, text_encoder: Qwen2_5_VLForConditionalGeneration, tokenizer: Qwen2Tokenizer, text_processor: Qwen2VLProcessor, transformer: LongCatImageTransformer2DModel)
```

[源代码](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/longcat_image/pipeline_longcat_image.py#L205)

用于文本到图像生成的流水线。

- 全部
- __调用__

## LongCatImagePipelineOutput[[diffusers.pipelines.longcat_image.LongCatImagePipelineOutput]]

#### diffusers.pipelines.longcat_image.LongCatImagePipelineOutput[[diffusers.pipelines.longcat_image.LongCatImagePipelineOutput]]

```python
diffusers.pipelines.longcat_image.LongCatImagePipelineOutput(images: list[PIL.Image.Image, numpy.ndarray])
```

[源代码](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/longcat_image/pipeline_output.py#L10)

**参数：**

images (`list[PIL.Image.Image]` 或 `np.ndarray`)：长度为 `batch_size` 的去噪 PIL 图像列表，或形状为 `(batch_size, height, width, num_channels)` 的 numpy 数组。PIL 图像或 numpy 数组表示扩散流水线生成的去噪图像。

Stable Diffusion 管道的输出类。

