serve icon indicating copy to clipboard operation
serve copied to clipboard

Passing multiple(variable) input images to the handler via curl

Open anustupc opened this issue 6 years ago • 4 comments

Hello,

I am trying to pass multiple images using a custom handler that I build. I understand that in order to pass a single image during inference I have to give the command as follows: curl localhost:8080/predictions/ -F "[email protected]"

On looking online, I found that in order to give multiple images, I need to give it as an array as follows: curl localhost:8080/predictions/ -F "data[][email protected]" -F "data[][email protected]" However, that doesn't seem to work. The dictionary containing the data just has a single key with the name as data[] (containing information of image2.jpg) instead of it being an array containing information about both image1.jpg and image2.jpg.

Any thoughts regarding how I can pass a variable number of images to the handler using an array?

Thanks

anustupc avatar Nov 26 '20 04:11 anustupc

@anustupc: Please refer to the following comment :

https://github.com/pytorch/serve/issues/529#issuecomment-658012913

harshbafna avatar Nov 26 '20 05:11 harshbafna

Hi @harshbafna , Thanks for your reply. I understand that it can be done by giving a different key value for each image. I was wondering if it is possible to pass everything as elements of one list. If not, the solution as stated right now should work for me (for now).

anustupc avatar Nov 26 '20 06:11 anustupc

@anustupc

you could use the -d flag of curl command as follows:

-d '["data1", "data2", "data3"]'

harshbafna avatar Nov 26 '20 11:11 harshbafna

Thanks for your suggestion @harshbafna . I haven't really tested the -d option but I can make do with using multiple names with -F. I think we can close this for now and if need be reopen it later.

anustupc avatar Nov 30 '20 23:11 anustupc