Created
December 14, 2017 13:38
-
-
Save drch-/bdfd2360bfa7f13c3ce595f02722436a 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
FROM python:3 | |
WORKDIR /usr/src/app | |
COPY requirements.txt ./ | |
RUN pip install --no-cache-dir -r requirements.txt | |
COPY . . | |
CMD [ "python", "./tint.py" ] |
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
{ | |
"image": "camodules.azurecr.io/tint", | |
"spec": { | |
"inputs": { | |
"input_image": { | |
"type:file": {} | |
}, | |
"red": { | |
"type:number": { | |
"lower_inclusive": 0.0, | |
"upper_inclusive": 1.0 | |
} | |
}, | |
"green": { | |
"type:number": { | |
"lower_inclusive": 0.0, | |
"upper_inclusive": 1.0 | |
} | |
}, | |
"blue": { | |
"type:number": { | |
"lower_inclusive": 0.0, | |
"upper_inclusive": 1.0 | |
} | |
} | |
}, | |
"outputs": { | |
"tinted_image": { | |
"type:file": {} | |
} | |
} | |
}, | |
"ui": { | |
"inputs": { | |
"red": { | |
"index": 51, | |
"label": "Red channel", | |
"widget:slider": { | |
"step": 0.1 | |
} | |
}, | |
"green": { | |
"index": 52, | |
"label": "Green channel", | |
"widget:slider": { | |
"step": 0.1 | |
} | |
}, | |
"blue": { | |
"index": 53, | |
"label": "Blue channel", | |
"widget:slider": { | |
"step": 0.1 | |
} | |
} | |
}, | |
"outputs": {} | |
} | |
} |
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 json | |
import os | |
input_json = json.loads(os.environ['WFE_INPUT_JSON']) | |
#// end of loading input params | |
import matplotlib.pyplot as plt | |
from skimage import color, data, img_as_float, io | |
original_image = io.imread(input_json['input_image']) | |
grayscale_image = img_as_float(original_image[::2, ::2]) | |
image = color.gray2rgb(grayscale_image) | |
multiplier = [float(input_json['red']), float(input_json['green']), float(input_json['blue'])] | |
io.imsave("/output/tinted.jpg", multiplier * image) | |
#// begin of params output definition | |
output_json = { | |
"tinted_image": "/output/tinted.jpg" | |
} | |
with open("/output/" + input_json['WFE_output_params_file'], 'w') as f: | |
json.dump(output_json, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment