Yusuf Anı
10/04/2024, 11:06 AMsvc = bentoml.Service("iris-classifier", runners=[runner])
input_spec = Multipart(arr=NumpyNdarray(), annotations=JSON())
output_spec = Multipart(output=NumpyNdarray(), result=JSON())
@svc.api(input=input_spec, output=output_spec)
async def predict(
arr: NDArray[Any], annotations: dict[str, Any]
) -> dict[str, NDArray[Any] | dict[str, Any]]:
res = await runner.run(arr)
return {"output": res, "result": annotations}
but I have a class like following which I do lots of stuff init, but I cant give multipart input to that
• input argument not exists instead there is input_spec which doesn't work either
import bentoml
bentoml.service(
)
class ClipService:
"""BentoML service for encoding text and images using CLIP models."""
def __init__(self):
super().__init__()
# I am doing something in here
@bentoml.api(input=Multipart(images=File(), metadata=JSON()), batchable=True)
async def encode_image(self, images: List[UploadFile], metadata: dict[str, Any]):
# this doesn't work
Any idea?Toke Emil Heldbo Reines
10/04/2024, 12:26 PMclass HeatmapConfiguration(BaseModel):
with_overlay: bool = False
class_index: int = 0
@bentoml.api
def heatmap(self, input_image: PILImage.Image, configuration: HeatmapConfiguration) -> PILImage.Image:
...Chaoyu
10/04/2024, 3:16 PM