MCPcopy Create free account
hub / github.com/modelscope/modelscope / ExampleDecoder

Function ExampleDecoder

modelscope/utils/service_utils.py:15–26  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

13# service data decoder func decodes data from network and convert it to pipeline's input
14# for example
15def 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)

Callers

nothing calls this directly

Calls 2

decode_base64_to_imageFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…