tensor2tensor icon indicating copy to clipboard operation
tensor2tensor copied to clipboard

How to form requests to docker served transformer_tiny model?

Open aleksasp opened this issue 5 years ago • 0 comments

Description

  • Trained translation problem transformer_tiny model.
  • Exported it and loaded for serving using t2t-exporter
  • Started tensorflow/serving docker to serve the exported model
  • converted input string to subword index list using encode function borrowed from deno t2t notebook

The question is how should the request json posted to the server look like?

I've tried {'inputs': [13230, 26, 5, 8050, 14, 6571, 1]} and got {'error': 'JSON Parse error: Invalid value. at offset: 0'}

code for request:

headers = {"content-type": "application/json"}
json_response = requests.post('http://localhost:8501/v1/models/transformer-lite-v1:predict', data=data, headers=headers)
predictions = json.loads(json_response.text)

print(predictions)

Environment information

TF 1.5.2

OS: Google Colab for training and exporting with `%tensorflow_version 1.x` setting

```sh
nvidia-docker run -t --rm -p 8501:8501 \
    -v "/path/to/transformer-lite-v1:/models/transformer-lite-v1" \
    -v "/path/to/translate_xy_wmt32k:/problems/translate_xy_wmt32k" \
    -e MODEL_NAME=transformer-lite-v1 \
    -e NVIDIA_VISIBLE_DEVICES=1 \
    tensorflow/serving

$ pip freeze | grep tensor

your output here

$ python -V

your output here

mesh-tensorflow==0.1.12
tensor2tensor==1.15.2
tensorboard==1.15.0
tensorboard-plugin-wit==1.7.0
tensorboardcolab==0.0.22
tensorflow==1.15.0
tensorflow-addons==0.8.3
tensorflow-datasets==3.0.0
tensorflow-estimator==1.15.1
tensorflow-gan==2.0.0
tensorflow-gcs-config==2.3.0
tensorflow-gpu==1.15.2
tensorflow-hub==0.5.0
tensorflow-metadata==0.25.0
tensorflow-privacy==0.2.2
tensorflow-probability==0.7.0
tensorflowjs==1.3.2

### For bugs: reproduction and error logs

Steps to reproduce:

...


Error logs:

...

aleksasp avatar Nov 29 '20 02:11 aleksasp