Skip to content

Instantly share code, notes, and snippets.

@cvalenzuela
Created June 17, 2020 23:15
Show Gist options
  • Save cvalenzuela/37dc39c06599b4d37ba6e75c842dc788 to your computer and use it in GitHub Desktop.
Save cvalenzuela/37dc39c06599b4d37ba6e75c842dc788 to your computer and use it in GitHub Desktop.
import runway
from runway.data_types import number, text, image
import numpy as np
from scipy import ndimage
import time
@runway.command(name='convert',
inputs={ 'image': image },
outputs={ 'image': image })
def generate(model, inputs):
img = np.array(inputs['image'])[:,:,:3]
# invert colors
# img = np.invert(img)[:,:,:3]
# to grayscale
img = np.dot(img[...,:3], [0.299, 0.587, 0.114])
# rotate
# img = ndimage.rotate(img, 30, mode='constant')
return {
'image': img.astype(np.uint8)
}
if __name__ == '__main__':
runway.run(host='0.0.0.0', port=8080, debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment