(data)
| 29 | # service data encoder func encodes data from pipeline outputs and convert to network response (such as json) |
| 30 | # for example |
| 31 | def ExampleEncoder(data): |
| 32 | # Assuming the pipeline outputs is a dict contains an image and a text, |
| 33 | # and transmit it through network, this func encode image to base64 and dumps into json |
| 34 | # data (for e.g. python dict): |
| 35 | # {"image": a numpy array represents a image, "text": "output"} |
| 36 | image = data['image'] |
| 37 | text = data['text'] |
| 38 | data = {'image': encode_array_to_img_base64(image), 'text': text} |
| 39 | return json.dumps(data, cls=NumpyEncoder) |
| 40 | |
| 41 | |
| 42 | CustomEncoder = { |
nothing calls this directly
no test coverage detected
searching dependent graphs…