类功能
功能描述
对接图生图大模型服务,提供大模型交互功能。
当前只支持IP-Adapter搭建的模型:stable-diffusion-v1-5
函数原型
from mx_rag.llm import Img2ImgMultiModel Img2ImgMultiModel(url, model_name, client_param)
输入参数说明
参数名 |
数据类型 |
可选/必选 |
说明 |
|---|---|---|---|
url |
str |
必选 |
大模型访问url。长度取值范围[1, 128]。 |
model_name |
str |
可选 |
SD模型名称。默认值为“None”。长度取值范围[1, 128]。 |
client_param |
ClientParam |
可选 |
https客户端配置参数,默认值为“ClientParam()”,具体描述请参见ClientParam类。 |
返回值说明
Img2ImgMultiModel对象。
调用示例
import sys
from mx_rag.document.loader import ImageLoader
from mx_rag.llm import Img2ImgMultiModel
from mx_rag.utils import ClientParam
multi_model = Img2ImgMultiModel(url="image to image url", model_name="sd",
client_param=ClientParam(ca_file="/path/to/ca.crt")
)
loader = ImageLoader("image path")
docs = loader.load()
if len(docs) < 1:
print("load image failed")
sys.exit(1)
res = multi_model.img2img(
prompt="he is a knight, wearing armor, big sword in right hand. Blur the background, focus on the knight",
image_content=docs[0].page_content,
size="512*512")
print(res)
父主题: Img2ImgMultiModel类