Sean
02/17/2023, 5:00 PMv1.0.15
release is here featuring the introduction of the bentoml.diffusers
framework.
• Learn more about the capabilities of the bentoml.diffusers
framework in the Creating Stable Diffusion 2.0 Services With BentoML And Diffusers blog and BentoML Diffusers example project.
• Import a diffusion model with the bentoml.diffusers.import_model
API.
bentoml.diffusers.import_model(
"sd2",
"stabilityai/stable-diffusion-2",
)
• Create a text2img
service using a Stable Diffusion 2.0 model runner with the familiar to_runner
API from the bentoml.diffuser
framework.
import torch
from diffusers import StableDiffusionPipeline
import bentoml
from <http://bentoml.io|bentoml.io> import Image, JSON, Multipart
bento_model = bentoml.diffusers.get("sd2:latest")
stable_diffusion_runner = bento_model.to_runner()
svc = bentoml.Service("stable_diffusion_v2", runners=[stable_diffusion_runner])
@svc.api(input=JSON(), output=Image())
def txt2img(input_data):
images, _ = stable_diffusion_runner.run(**input_data)
return images[0]
⭐ Fixed a incompatibility change introduced in starlette==0.25.0
result in the type MultiPartMessage
not being found in starlette.formparsers
.
ImportError: cannot import name 'MultiPartMessage' from 'starlette.formparsers' (/opt/miniconda3/envs/bentoml/lib/python3.10/site-packages/starlette/formparsers.py)