runwayml / model-sdk

💥🐍 Runway Model SDK: port your own machine learning models to Runway

Home Page:https://sdk.runwayml.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support multiple image formats encoded as base64

brannondorsey opened this issue · comments

Right now, runway.data_types.image support serialization via a JPEG encoded image only.

def serialize(self, value):
if type(value) is np.ndarray:
im_pil = Image.fromarray(value)
elif type(value) is Image.Image:
im_pil = value
buffer = IO()
im_pil.save(buffer, format='JPEG')
return 'data:image/jpeg;base64,' + base64.b64encode(buffer.getvalue()).decode('utf8')

We should support multiple image formats, as well as exploring support for higher bit-depth images.