Created
June 17, 2020 23:15
-
-
Save cvalenzuela/37dc39c06599b4d37ba6e75c842dc788 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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