This message was deleted.
# ask-for-help
s
This message was deleted.
j
yes you will have to use multipart, but we are releasing a new version of bentoml which will natively support
list[Image]
next month!
👍 1
s
Great to know! Then, I'll come up with a single Image first wait for your updates towards list[Image] However, would you mind to give an example on how to apply Multipart for multiple images.
t
I'm trying to do the same now, do you have any pointers please @Sergej Dogadov @Jian Shen Yap? I've checked the latest bentoml releases and can't see support for
list[Image]
yet
j
i believe this is possible
list[Image]
with the 1.2 SDK!
Copy code
import bentoml
from PIL.Image import Image

@bentoml.service
class MnistPredictor:
    @bentoml.api
    def infer(self, image: list[Image])-> int:
        return 1
🙌 1
t
Oh so you wouldn't use the bentoml.io.Image descriptor:
Copy code
@svc.api(input=list[bentoml.io.Image()], output=bentoml.io.JSON(), route="/image_ocr")
async def ocr(file) -> dict:
    encoded_images = await read_file(file)
    result = await ocr_pipeline.recognise_text([encoded_images])
    return result[0]
as this didn't work for me?
j
oh, list of X doesn't work for bentoml <1.2!
you would use the latest SDK for this
t
On
bentoml==1.2.4
for this:
Copy code
@svc.api(
    input=list[bentoml.io.Image()], output=bentoml.io.JSON(), route="/image_ocr/batch"
)
async def ocr_batch(files) -> dict:
    encoded_images = await asyncio.gather(*[read_file(file) for file in files])
    results = await ocr_pipeline.recognise_text(encoded_images=encoded_images)
    return results
I get:
Copy code
_api = InferenceAPI[IOType](
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/.pyenv/versions/3.11.7/lib/python3.11/typing.py", line 1275, in __call__
    result = self.__origin__(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/ocr/venv/lib/python3.11/site-packages/bentoml/_internal/service/inference_api.py", line 50, in __init__
    input_type = input_descriptor.input_type()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'list' has no attribute 'input_type'
Is this not expected?
j
you would not use the IO descriptor anymore with the new SDK. https://docs.bentoml.com/en/latest/guides/iotypes.html service definition is also revamped! https://docs.bentoml.com/en/latest/guides/services.html
t
Ahh i see - sorry i missed the revamp. Thanks @Jian Shen Yap!
j
we should have probably be more clear with our docs! we will work on that
t
I'd just been using bentoml a lot the last few months to deploy Whisper and had learnt how to use bentoml, so wasn't expecting a new interface in the same major version! Looking forward to trying it though. Interesting that configuration is no longer controlled by the yamls now too!
I like it!
Oh but resources only applies on the BentoCloud
this field only takes effect on BentoCloud
?
j
Yaml are still available! but doing it in code we felt its closer to the right mental model
Oh but resources only applies on the BentoCloud
this field only takes effect on BentoCloud
?
thats right. these field are newly added to help identified the needed resources to assign a machine when deployed in BentoCloud
t
Makes sense 👍
I temporarily confused that for
traffic
I'm just converting my custom Runnable's into services now under the new distributed services documentation. One thing i can't see is where to specify the equivalent for these, as service resources only applies to cloud:
Copy code
SUPPORTED_RESOURCES = ("cpu",)
    SUPPORTS_CPU_MULTI_THREADING = True