Created
June 2, 2021 19:19
-
-
Save sgl0v/2a766f2e7b2538f4838e698c94a08842 to your computer and use it in GitHub Desktop.
This file contains 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
extension ImageColorizer { | |
private func colorize(image inputImage: UIImage) -> Result<UIImage, Error> { | |
do { | |
let inputImageLab = try preProcess(inputImage: inputImage) // ➊ | |
let input = try colorizerInput(from: inputImageLab) // ➋ | |
let output = try coremlColorizer(configuration: MLModelConfiguration()).prediction(input: input) // ➌ | |
let outputImageLab = imageLab(from: output, inputImageLab: inputImageLab) // ➍ | |
let resultImage = try postProcess(outputLAB: outputImageLab, inputImage: inputImage) // ➎ | |
return .success(resultImage) | |
} catch { | |
return .failure(error) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment