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

Function ExampleEncoder

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

Source from the content-addressed store, hash-verified

29# service data encoder func encodes data from pipeline outputs and convert to network response (such as json)
30# for example
31def 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
42CustomEncoder = {

Callers

nothing calls this directly

Calls 2

dumpsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…