Skip to content
目录

预置文生图模型服务接口说明

接口地址:https://platform.wair.ac.cn/maas/v2/api

请求方式:post 请求

文生图模型 Taichu-text2Image

快速开始

安装依赖

container 启动后,运行以下命令安装依赖

bash
pip install -r requirements.txt

启动服务

运行以下命令启动服务

bash
sh start.sh

测试服务

运行以下代码/命令测试服务

bash
import requests
url = 'http://172.16.10.2:8080/text2image_multires'
inputs = {
    "input_text": "一张秦始皇的图片,真人,古装,高清摄影",
    "num_images": 1,
    "scale":6,
    "seed":0,
    "steps":20,
    "height":1024,
    "width":1024
    "return_type":"base64"  
}

header = {'content-type': 'application/json'}
res = requests.post(url, json=inputs, headers=header)

print(res.text)
curl
curl --location --request POST '172.16.10.2:8080/text2image_multires' --header 'Content-Type: application/json' --data-raw '{"input_text":"童话般的华丽城堡,唯美,油画","num_images":1,"scale":12,"steps":100,"height":768,"width":1024}'

输入描述以及示例

  • 描述 swagger: '4' info: description: 文生图 API title: text2image API version: '4'
    consumes:
    • application/json
      produces:
    • application/json
      paths: /text2image: post: tags: - luoshendit-text2image
      operationId: app.luoshendit-text2image
      summary: luoshendit-text2image文生图
      consumes: - application/json parameters:
      • name: input_data
        in: body
        description: text
        required: true
        schema: type: object
        • properties:
          input_text: type: array items: type: string description: 输入的文字
          num_images: type: array items: type: int description: 输入文字一次生成的图片的数量,建议为1
          scale: type: array items: type: float description: 引导力度
          steps: type: array items: type: int description: 解噪步数
          height: type: array items: type: int description: 长度
          width: type: array items: type: int description: 宽度
          return_type: type: array items: type: int description: 返回类型。为"obs_url"或"base64",默认"obs_url,返回图片网址;若为"base64",则返回图像base64编码。
          seed: type: array items: type: int description: 随机种子
          required:

输出描述以及示例

  • 描述

    yaml
    schema:
        type: array
        items:
          type: object
          properties:
            input_text:
              type: string
              description: 输入的文本
            output_image_url:
              type: object
              description: 该文本生成的图像的url地址
  • 示例

json
{
    "status": 5,
    "input_text": "一张秦始皇的图片,真人,古装,高清摄影",
    "output_image_url": "https://publish-data.obs.cn-central-221.ovaijisuan.com/server/text2image/text2image_luoshen_dit/b725a4e802228f13c3881eae2ee08f20_一张秦始皇真人古装高清摄影_8219_0.jpg",
    "relative_dir": "/static/b725a4e802228f13c3881eae2ee08f20_一张秦始皇的图片真人古装高清摄影_8219_0.jpg",
    "seed": 8219
}