Signed-off-by: NumberWan <wantszkin2003@gmail.com> Signed-off-by: SamitHuang <285365963@qq.com> Signed-off-by: Samit <285365963@qq.com> Co-authored-by: Isotr0py <Isotr0py@outlook.com> Co-authored-by: Tianyu Guo <guoty9@mail2.sysu.edu.cn> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: SamitHuang <285365963@qq.com> Co-authored-by: Gao Han <hgaoaf@connect.ust.hk>
29 lines
772 B
Python
29 lines
772 B
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from PIL import Image
|
|
|
|
|
|
def build_image_to_image_prompt(
|
|
prompt: str,
|
|
negative_prompt: str | None,
|
|
input_image: Image.Image | list[Image.Image],
|
|
height: int | None = None,
|
|
width: int | None = None,
|
|
) -> dict[str, Any]:
|
|
img_prompt: dict[str, Any] = {
|
|
"prompt": prompt,
|
|
"multi_modal_data": {"image": input_image},
|
|
}
|
|
if height is not None:
|
|
img_prompt["height"] = height
|
|
if width is not None:
|
|
img_prompt["width"] = width
|
|
if negative_prompt is not None:
|
|
img_prompt["negative_prompt"] = negative_prompt
|
|
return img_prompt
|