LongCat-Image

LongCat-Image

LongCat-Image는 Meituan의 텍스트-투-이미지 모델입니다. SGLang이 그 Qwen2.5-VL 프롬프트 리라이터를 네이티브 SGLang 런타임과 함께 프로세스 내에서 실행합니다. 프롬프트 리라이팅과 디퓨전을 하나의 OpenAI 호환 이미지 엔드포인트 뒤에 유지해요.

출처: 문서

본문

<DiffusionModelTags tags={["image", "text-to-image", "prompt rewriting", "Qwen2.5-VL"]} />

1. 모델 소개 (Model Introduction)

LongCat-Image는 Meituan의 텍스트-투-이미지 모델입니다. SGLang은 텍스트 인코딩과 디노이징 전에 Qwen2.5-VL 프롬프트 리라이터를 네이티브 SGLang 런타임과 함께 프로세스 내에서 실행합니다.

네이티브 파이프라인은 프롬프트 리라이팅과 디퓨전을 하나의 OpenAI 호환 이미지 엔드포인트 뒤에 유지합니다. 리라이팅은 더 강력한 프롬프트 확장을 위해 기본 활성화되지만, 각 요청은 리라이트된 프롬프트 품질보다 지연이 더 중요할 때 비활성화할 수 있습니다.

2. 설치 (Installation)

디퓨전 의존성으로 SGLang을 설치합니다:

pip install -e "python[diffusion]"

다른 설치 옵션은 SGLang Diffusion installation guide를 참고하세요.

3. 모델 서빙 (Serve the model)

sglang serve \
  --model-path meituan-longcat/LongCat-Image \
  --performance-mode auto \
  --port 30010

LongCat-Image는 프롬프트 리라이팅이 기본 활성화됩니다. 디퓨전 전에 자동회귀 Qwen2.5-VL 패스를 추가합니다. 지연이 리라이트된 프롬프트 품질보다 더 중요할 때는 요청에 enable_prompt_rewrite=false를 설정하세요.

4. 이미지 생성 (Generate an image)

import base64
from openai import OpenAI

client = OpenAI(api_key="EMPTY", base_url="http://127.0.0.1:30010/v1")

response = client.images.generate(
    model="meituan-longcat/LongCat-Image",
    prompt="A quiet bookshop on a rainy evening, warm light in the windows",
    n=1,
    response_format="b64_json",
)

image_bytes = base64.b64decode(response.data[0].b64_json)
with open("longcat_image.png", "wb") as f:
    f.write(image_bytes)

OpenAI 클라이언트로 프롬프트 리라이팅을 건너뛰려면 extra_body를 통해 모델별 요청 필드를 전달하세요:

response = client.images.generate(
    model="meituan-longcat/LongCat-Image",
    prompt="A quiet bookshop on a rainy evening",
    extra_body={"enable_prompt_rewrite": False},
)

5. 메모리 배치 (Memory placement)

전체 파이프라인이 가속기에 맞지 않을 때 통합 컴포넌트 상주 선택기를 사용하세요. 예를 들어 반복 사용되는 DiT를 상주시키고 보조 컴포넌트를 스테이지 사이에 CPU로 옮깁니다:

sglang serve \
  --model-path meituan-longcat/LongCat-Image \
  --component-residency dit=resident text_encoder=component-offload vae=component-offload \
  --pin-cpu-memory \
  --port 30010

모드 의미와 기존 CPU-offload 플래그와의 호환성은 Component Residency를 참고하세요.

더 알아보기 (Learn more)