常规包算法服务,就是比较简单,直接起一个fastapi就可以了。
import time
import asyncio
from aidraw import engineer_log as eng
from fastapi import FastAPI
from pydantic import BaseModel
from typing import Optional
from aidraw.ardraw import run_aidraw_api# 起 fastapi
app = FastAPI(description="FastAPI for txt2img_adetailer_controlnet Application", version="1.1.0")
# 创建一个异步锁,阻塞处理并发的异步请求。
lock = asyncio.Lock()class Item(BaseModel):prompt: Optional[str] = ""negative_prompt: Optional[str] = ""atmosphere: Optional[str] = ""location: Optional[str] = ""image_nums: Optional[int] = 1size: Optional[int] = 1upload_image: Optional[dict] = {}sketch_image: Optional[dict] = {}reference_image: Optional[dict] = {}style: Optional[str] = ""@app.post("/archdraw")
async def apply(input_json: Item):