Closed bojiang closed 2 years ago
input_names (string[]]): A tuple of acceptable input name for HTTP request.
Default value is (image,)
Why do we want to use this instead of passing along all of the files and letting the consumer decide which files they will use?
@akainth015 great question, I think it makes sense to support inputs of a variable-length list of files/images instead of only fixed-length, named images. The original design allows us to give the user a columnar
look of a batch of input, e.g. {'image1': [<image_file>, ...], 'image2': [<image_file>] }
, but I think it makes more sense to group input images in rows considering this case, e.g. [ [<image_file>, ..], [<image_file>, ..], ... ]
or [ {'image1': <image_file>, 'image2': <image_file>}, ... ]
, cc @bojiang
The current design is exactly what you said:
image_array_x = image_group['imageX']
->
{'image1': <image_file>, 'image2': <image_file>}, ... ]
In most cases, the API developer doesn't need file inputs with dynamic names. The input_names
would be useful for API users, for example, shown in the swagger.
Hi @parano @bojiang is it possible currently to post multiple files/images without the input_names
. For my use case, the number of images can vary per request, and I don't need to have input names for each image. I would like to just post an array of images e.g [ [<image_file>, ..], [<image_file>, ..], ... ]
My cURL looks something like this:
curl -i -X POST "localhost:5000/predict" -H "Content-Type: multipart/form-data" -F "image=@002.jpg" -F "image=@image.jpg"
At the moment with MultiFileInput(input_names=['image'])
only the first image file is received
hi @jkuypers93 - unfortunately, this is not supported in the current version of BentoML. could you tell me a bit more about your use case? @bojiang and I were just discussing how to support handling requests with a variable number of files in the future version but could not find a good use case for it, would love to learn more.
Hey @parano, thanks for getting back to me!
I have an application where users can upload a variable number of images (sent as an array of images). My model then creates a batch using this array of files and return a prediction for each image. I could query the API one image at the time but that is less efficient.
Previously, I was deploying my model with FastAPI and was using their List[FileUpload] class.
Is it ok if I re-open this issue for this? I would like to contribute :)
@jkuypers93 are you in the BentoML slack channel? feel free to ping me and discuss more before you started to make the contribution. The team is actively developing a new version in the 1.0 branch and a lot of things have changed
This is now supported in BentoML 1.0, via the Multipart
IO descriptor: https://docs.bentoml.org/en/latest/api/api_io_descriptors.html#bentoml-io-multipart
I am also trying to convert a FastAPI classifying batches of images to bentoml, previously i used the List[FileUpload] as @jkuypers93 did.
Sorry if i'm missing something obvious, but its not clear to me how you would use the Multipart
IO Descriptor in this scenario? Is there an example of this anywhere?
Is your feature request related to a problem? Please describe.
The new ImageInput with micro-batching support does not allow multiple image inputs, comparing to the old ImageHandler
Describe the solution you'd like Add
bentoml.adapters.MultiImageInput
input adapter type: