import os
import warnings
from pathlib import Path
import gradio as gr
from deoldify import device
from deoldify.device_id import DeviceId
from deoldify.visualize import get_image_colorizer
from huggingface_hub import snapshot_download
os.system("pip freeze")
warnings.filterwarnings("ignore", category=UserWarning, message=".*?Your .*? set is empty.*?")
device.set(device=DeviceId.CPU)
REPO_ID = "leonelhs/deoldify"
snapshot_folder = snapshot_download(repo_id=REPO_ID)
device.set(device=DeviceId.GPU0)
colorizer = get_image_colorizer(root_folder=Path(snapshot_folder), artistic=True)
def predict(image):
return colorizer.get_transformed_image(image, render_factor=35, watermarked=False)
title = "DeOldify"
description = r"""
## Colorize image
This is an implementation of DeOldify.
It has no any particular purpose than start research on AI models.
"""
article = r"""
Questions, doubts, comments, please email 📧 `leonelhs@gmail.com`
This demo is running on a CPU, if you like this project please make us a donation to run on a GPU or just give us a Github ⭐