1

I am trying to use Tensorflow serving to host my model and get predictions on image data. REST API requires binary inputs to be encoded as Base64 and wrapped in an object containing 'b64' key. Therefore, I give the encoded image to the curl request using the 'b64' key. However, when I tried executing the command, I am getting an error 'Unable to base64 decode'. Here is the code that I ran:

curl -X POST http://localhost:9001/v1/models/sanskrit:predict -H 'cache-control: no-cache' -H 'content-type: application/json' -d '{"signature_name": "serving_default", "inputs": {"input": { "b64": "$( base64 /data2/hdia_ocr_data/data/books2/books_3p/nirnaya_sindhu/61/2.jpg)" }}}'

I have also tried to pass base64 string directly to the 'b64' key as shown below:

curl -X POST http://localhost:9001/v1/models/sanskrit:predict -H 'cache-control: no-cache' -H 'content-type: application/json' -d '{"signature_name": "serving_default", "inputs": {"input": { "b64": "<base64_of_image>" }}}'

But this gives an error curl: argument list too long. This is probably because of my image data large size(~200kb). And it is working for images with a smaller size.

Am I missing something while executing these commands?

Agam
  • 11
  • 4
  • Can you try the solution specified in the link, https://stackoverflow.com/a/54091092/11530462. Thanks! –  May 02 '20 at 05:17
  • Hey. I think in the answer @filename.txt refers to the file with base64 content. How am I going to specify this file as the value respective to the 'b64' key – Agam May 02 '20 at 14:18
  • You can try `{"instances": [{"b64": ""}]}` or `{"image_bytes": {"b64": ""}}`. If that doesn't solve your problem, Can you share your SignatureDef so that we can investigate further? –  May 03 '20 at 03:28
  • Yes. I have used {"b64": "} format. Here is how I sent the prediction request: curl -X POST http://localhost:9001/v1/models/aocr:predict -H 'cache-control: no-cache' -H 'content-type: application/json' -d '{"signature_name": "serving_default", "inputs": {"input": { "b64": "" }}}'. How can I pass a file with base64 string in this instead of directly the base64 value? – Agam May 03 '20 at 15:00

0 Answers0