Slackbot
10/18/2022, 1:39 PMAaron Pham
10/18/2022, 11:28 PMScott Hedstrom
10/19/2022, 5:06 PMAaron Pham
10/19/2022, 7:40 PMsd_runner = bentoml.transformers.get("stable_diffusion:latest").to_runner()
gan_runner = bentoml.pytorch.get("esrgan").to_runner()
svc = bentoml.Service("service", runners = [sd_runner, gan_runner])
@svc.api(input=bentoml.io.Image(), output=bentoml.io.Image())
async def generate_image(input_data):
return await gan_runner.async_run(input_data)
@svc.api(input=bentoml.io.Text(), output=bentoml.io.Image())
async def text_to_image(input_data):
return await sd_runner.async_run(input_data)
You can read more about how you can define our service hereScott Hedstrom
10/20/2022, 12:08 AMAaron Pham
10/20/2022, 12:12 AMScott Hedstrom
10/20/2022, 12:19 AMAaron Pham
10/20/2022, 12:24 AM1. Do you think it would be possible to pass the image around on the service between the two models so I could generate the image then upscale it?You can do this perfectly by making a sequential graph
@svc.api(input=bentoml.io.Text(), output=bentoml.io.Image())
async def generate_image(input_text):
image = await sd_runner.async_run(input_text)
return await gan_runner.async_run(image) # upscale
Is there any way to get the progress on the service side?I mean here by āprogressā you mean how long it takes to run the inference? You can use library such as tqdm to show progress of the inference task. https://github.com/tqdm/tqdm
Scott Hedstrom
10/20/2022, 12:24 AMAaron Pham
10/20/2022, 2:56 AMbentoml.metrics
will allow user to create Prometheus metrics to inside their service. This plays well with these sorts of metrics
h = bentoml.metrics.Histogram("inference_duration", "Duration of a given inference graph")
@svc.api(input=bentoml.io.Text(), output=bentoml.io.Image())
async def generate_image(input_text):
start = time.perf_timer()
image = await sd_runner.async_run(input_text)
res = await gan_runner.async_run(image) # upscale
total = time.per_timer() - start
h.observe(total)
return res