Slackbot
01/30/2024, 5:35 PMJian Shen Yap
01/31/2024, 1:31 PMlist[Image] next month!Sergej Dogadov
01/31/2024, 3:07 PMTom Matthews
03/06/2024, 12:21 PMlist[Image] yetJian Shen Yap
03/06/2024, 3:27 PMlist[Image] with the 1.2 SDK!
import bentoml
from PIL.Image import Image
@bentoml.service
class MnistPredictor:
@bentoml.api
def infer(self, image: list[Image])-> int:
return 1Tom Matthews
03/06/2024, 4:37 PM@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?Jian Shen Yap
03/06/2024, 4:38 PMJian Shen Yap
03/06/2024, 4:38 PMTom Matthews
03/06/2024, 4:42 PMbentoml==1.2.4 for this:
@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:
_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?Jian Shen Yap
03/06/2024, 4:43 PMTom Matthews
03/06/2024, 4:44 PMJian Shen Yap
03/06/2024, 4:46 PMTom Matthews
03/06/2024, 4:49 PMTom Matthews
03/06/2024, 4:49 PMTom Matthews
03/06/2024, 4:53 PMthis field only takes effect on BentoCloud ?Jian Shen Yap
03/06/2024, 4:53 PMJian Shen Yap
03/06/2024, 4:53 PMOh but resources only applies on the BentoCloudthats right. these field are newly added to help identified the needed resources to assign a machine when deployed in BentoCloud?this field only takes effect on BentoCloud
Tom Matthews
03/06/2024, 4:54 PMTom Matthews
03/06/2024, 4:54 PMtrafficTom Matthews
03/07/2024, 6:02 PMSUPPORTED_RESOURCES = ("cpu",)
SUPPORTS_CPU_MULTI_THREADING = True