import gradio as gr
import numpy as np
import colorizers as c
from colorizers.util import postprocess_tens, preprocess_img
def interface(image, model: str = "eccv16"):
if model == "eccv16":
img = c.eccv16(pretrained=True).eval()
else:
img = c.siggraph17(pretrained=True).eval()
oimg = np.asarray(image)
if(oimg.ndim == 2):
oimg = np.tile(oimg[:,:,None], 3)
(tens_l_orig, tens_l_rs) = preprocess_img(oimg)
output_img = postprocess_tens(
tens_l_orig,
img(tens_l_rs).cpu()
)
return output_img
title = "Image Colorization Using AI Models"
description = r"""An automatic colorization functionality for Real-Time User-Guided Image Colorization with Learned Deep Priors,ECCV16 & SIGGRAPH 2017 Models!
Practically the algorithm is used to COLORIZE your **old BLACK & WHITE / GRAYSCALE photos**.
To use it, simply just upload the concerned image.
"""
article = r"""
Given a grayscale photograph as input, this demo attacks the problem of hallucinating a plausible color version of the photograph. This problem is clearly underconstrained, so previous approaches have either relied on significant user interaction or resulted in desaturated colorizations. A fully automatic approach has been proposed that produces vibrant and realistic colorizations. The underlying uncertainty of the problem was embraced by posing it as a classification task and use class-rebalancing at training time to increase the diversity of colors in the result. The system is implemented as a feed-forward pass in a CNN at test time and is trained on over a million color images. The algorithm is evaluated using a "colorization Turing test," asking human participants to choose between a generated and ground truth color image. The method used here successfully fools humans on 32% of the trials, significantly higher than other methodology used by the other photo automation tools. Moreover, the colorization can be a powerful pretext task for self-supervised feature learning, acting as a cross-channel encoder. This approach results in state-of-the-art performance on several feature learning benchmarks.
richzhang/colorization is licensed under the
A permissive license that comes in two variants, the BSD 2-Clause and BSD 3-Clause. Both have very minute differences to the MIT license.