File size: 1,840 Bytes
56ecbb4
cd7fe04
83d740b
56ecbb4
 
 
 
cd7fe04
83d740b
56ecbb4
 
cd7fe04
56ecbb4
 
 
83d740b
 
 
cd7fe04
83d740b
56ecbb4
 
d33cf3c
cd7fe04
56ecbb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d33cf3c
cd7fe04
56ecbb4
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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 <a href='https://github.com/jantic/DeOldify' target='_blank'>DeOldify</a>.
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 <a href='https://github.com/jantic/DeOldify' target='_blank'>Github ⭐</a>

<a href="https://www.buymeacoffee.com/leonelhs"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=leonelhs&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff" /></a>

<center><img src='https://visitor-badge.glitch.me/badge?page_id=deoldify.visitor-badge' alt='visitor badge'></center>
"""

demo = gr.Interface(
    predict, [
        gr.Image(type="filepath", label="Image gray scale"),
    ], [
        gr.Image(type="pil", label="Image color")
    ],
    title=title,
    description=description,
    article=article)

demo.queue().launch()