Class Introduction
Function
Interconnects and interacts with an image-to-image model.
Currently, only the IP-Adapter-based stable-diffusion-v1-5 model is supported.
Prototype
from mx_rag.llm import Img2ImgMultiModel Img2ImgMultiModel(url, model_name, client_param)
Parameters
Parameter |
Data Type |
Required/Optional |
Description |
|---|---|---|---|
url |
str |
Required |
URL for accessing a foundation model. The length range is [1, 128]. |
model_name |
str |
No |
Name of a Stable Diffusion model. The default value is None. The length range is [1, 128]. |
client_param |
ClientParam |
Optional |
HTTPS client configuration parameter. The default value is ClientParam(). For details, see ClientParam. |
Return Value
Img2ImgMultiModel object.
Example
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)
Parent topic: Img2ImgMultiModel