美团龙猫开源6B文生图模型——LongCat-Image

简介

我们推出LongCat-Image——一个开创性的开源双语(中英)图像生成基础模型,旨在解决当前主流模型在多语言文本渲染、照片级真实感、部署效率和开发者易用性方面的核心痛点。

在这里插入图片描述

核心特点

  • 🌟 卓越的效能与性能:仅用60亿参数,LongCat-Image便在多项基准测试中超越众多参数规模数倍的开源模型,展现了高效模型设计的巨大潜力。
  • 🌟 强大的中文文本渲染能力:相比现有SOTA开源模型,LongCat-Image在常见中文字符渲染上展现出更优的准确性与稳定性,并实现了业界领先的中文字典覆盖率。
  • 🌟 惊人的写实表现:通过创新的数据策略与训练框架,LongCat-Image在生成图像上实现了令人惊叹的写实效果。

🎨 展示

在这里插入图片描述

快速开始

安装

克隆仓库:

git clone --single-branch --branch main https://github.com/meituan-longcat/LongCat-Image
cd LongCat-Image

安装依赖项:

# create conda environment
conda create -n longcat-image python=3.10
conda activate longcat-image

# install other requirements
pip install -r requirements.txt
python setup.py develop

运行文本到图像生成

💡 提示:使用更强大的LLM模型进行提示词工程可以进一步提升图像生成质量。详细用法请参考 inference_t2i.py

import torch
from transformers import AutoProcessor
from longcat_image.models import LongCatImageTransformer2DModel
from longcat_image.pipelines import LongCatImagePipeline

device = torch.device('cuda')
checkpoint_dir = './weights/LongCat-Image'

text_processor = AutoProcessor.from_pretrained( checkpoint_dir, subfolder = 'tokenizer'  )
transformer = LongCatImageTransformer2DModel.from_pretrained( checkpoint_dir , subfolder = 'transformer', 
    torch_dtype=torch.bfloat16, use_safetensors=True).to(device)

pipe = LongCatImagePipeline.from_pretrained(
    checkpoint_dir,
    transformer=transformer,
    text_processor=text_processor
)
pipe.to(device, torch.bfloat16)

prompt = '一个年轻的亚裔女性,身穿黄色针织衫,搭配白色项链。她的双手放在膝盖上,表情恬静。背景是一堵粗糙的砖墙,午后的阳光温暖地洒在她身上,营造出一种宁静而温馨的氛围。镜头采用中距离视角,突出她的神态和服饰的细节。光线柔和地打在她的脸上,强调她的五官和饰品的质感,增加画面的层次感与亲和力。整个画面构图简洁,砖墙的纹理与阳光的光影效果相得益彰,突显出人物的优雅与从容。'

image = pipe(
    prompt,
    height=768,
    width=1344,
    guidance_scale=4.5,
    num_inference_steps=50,
    num_images_per_prompt=1,
    generator=torch.Generator("cpu").manual_seed(43),
    enable_cfg_renorm=True,
    enable_prompt_rewrite=True # Reusing the text encoder as a built-in prompt rewriter
).images[0]
image.save('./t2i_example.png')

模型

meituan-longcat/LongCat-Image

代码

https://github.com/meituan-longcat/LongCat-Image

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值