(data)
| 13 | # service data decoder func decodes data from network and convert it to pipeline's input |
| 14 | # for example |
| 15 | def ExampleDecoder(data): |
| 16 | # Assuming the pipeline inputs is a dict contains an image and a text, |
| 17 | # to decode the data from network we decode the image as base64 |
| 18 | data_json = json.loads(data) |
| 19 | # data: {"image": "xxxxxxxx=="(base64 str), "text": "a question"} |
| 20 | # pipeline(inputs) as follows: |
| 21 | # pipeline({'image': image, 'text': text}) |
| 22 | inputs = { |
| 23 | 'image': decode_base64_to_image(data_json.get('image')), |
| 24 | 'text': data_json.get('text') |
| 25 | } |
| 26 | return inputs |
| 27 | |
| 28 | |
| 29 | # service data encoder func encodes data from pipeline outputs and convert to network response (such as json) |
nothing calls this directly
no test coverage detected
searching dependent graphs…