def predictfunc_main(item:Item):
example_inference(item.input_path, item.output_path)
return {
"input": item.input_path,
"output": item.output_path
}
@app.post("/predictfunc")
async def predictfunc(item: Item):
# 使用asyncio.to_thread()在单独的线程中运行predict_in_thread
result = await asyncio.to_thread(predictfunc_main, item)
return result