跳到内容

InferenceEndpointsImageGeneration

运行异步 API 客户端的 Inference Endpoint 图像生成实现。

属性

  • model_id: 用于 ImageGenerationModel 的模型 ID,可在 Hugging Face Hub 中找到,用于解析无服务器 Inference Endpoints API 请求的基础 URL。默认为 None

  • endpoint_name: 用于 LLM 的 Inference Endpoint 的名称。默认为 None

  • endpoint_namespace: 用于 LLM 的 Inference Endpoint 的命名空间。默认为 None

  • base_url: 用于 Inference Endpoints API 请求的基础 URL。

  • api_key: 用于验证对 Inference Endpoints API 请求的 API 密钥。

示例

从文本提示生成图像

from distilabel.models.image_generation import InferenceEndpointsImageGeneration

igm = InferenceEndpointsImageGeneration(model_id="black-forest-labs/FLUX.1-schnell", api_key="api.key")
igm.load()

output = igm.generate_outputs(
    inputs=["a white siamese cat"],
)
# [{"images": ["iVBORw0KGgoAAAANSUhEUgA..."]}]