BentoDiffusion
1.0.0
該存儲庫包含一系列Bentoml示例項目,演示瞭如何在穩定擴散(SD)家族中部署不同模型,該模型專門根據文本提示來生成和操縱圖像或視頻剪輯。
有關Bentoml示例項目的完整列表,請參見此處。
以下指南以SDXL Turbo為例。
如果您想在本地測試該服務,我們建議您使用至少12GB VRAM的NVIDIA GPU。
git clone https://github.com/bentoml/BentoDiffusion.git
cd BentoDiffusion/sdxl-turbo
# Recommend Python 3.11
pip install -r requirements.txt我們已經在service.py中定義了Bentoml服務。在您的項目目錄中運行bentoml serve以啟動服務。
$ bentoml serve .
2024 - 01 - 18 T18 : 31 : 49 + 0800 [ INFO ] [ cli ] Starting production HTTP BentoServer from "service:SDXLTurboService" listening on http : // localhost : 3000 ( Press CTRL + C to quit )
Loading pipeline components ...: 100 %該服務器現在處於http:// localhost:3000的活動。您可以使用Swagger UI或其他不同的方式與之互動。
捲曲
curl -X ' POST '
' http://localhost:3000/txt2img '
-H ' accept: image/* '
-H ' Content-Type: application/json '
-d ' {
"prompt": "A cinematic shot of a baby racoon wearing an intricate italian priest robe.",
"num_inference_steps": 1,
"guidance_scale": 0
} 'Python客戶端
import bentoml
with bentoml . SyncHTTPClient ( "http://localhost:3000" ) as client :
result = client . txt2img (
prompt = "A cinematic shot of a baby racoon wearing an intricate italian priest robe." ,
num_inference_steps = 1 ,
guidance_scale = 0.0
)有關服務代碼的詳細說明,請參見穩定的擴散XL Turbo。
服務準備好後,您可以將應用程序部署到Bentocloud,以更好地管理和可擴展性。如果您沒有Bentocloud帳戶,請註冊。
確保已登錄到Bentocloud,然後運行以下命令將其部署。
bentoml deploy .應用程序啟動並在Bentocloud上運行後,您可以通過暴露的URL訪問它。
注意:對於您自己的基礎架構中的自定義部署,請使用Bentoml生成符合OCI的圖像。
要部署不同的擴散模型,請轉到此存儲庫的相應子目錄。