Skip to content

Instantly share code, notes, and snippets.

@drch-
Created December 14, 2017 13:38
Show Gist options
  • Save drch-/bdfd2360bfa7f13c3ce595f02722436a to your computer and use it in GitHub Desktop.
Save drch-/bdfd2360bfa7f13c3ce595f02722436a to your computer and use it in GitHub Desktop.
FROM python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "./tint.py" ]
{
"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": {}
}
}
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