Spaces:
Build error
Build error
File size: 1,317 Bytes
c080fe4 f2cc150 c080fe4 f2cc150 c080fe4 f2cc150 b326d68 c080fe4 f2cc150 c080fe4 f2cc150 |
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 |
import os
os.system("hub install deoldify==1.0.1")
import gradio as gr
import paddlehub as hub
from pathlib import Path
from datetime import datetime
from typing import Optional
model = hub.Module(name='deoldify')
# NOTE: Max is 45 with 11GB video cards. 35 is a good default
render_factor=35
def colorize_image(image):
# now = datetime.now().strftime("%Y%m%d-%H%M%S-%f")
if not os.path.exists("./output"):
os.makedirs("./output")
# if image is not None:
# image.save(f"./output/{now}-input.jpg")
model.predict(image.name)
return './output/DeOldify/'+Path(image.name).stem+".png"
def create_interface():
with gr.Blocks() as enhancer:
gr.Markdown("Colorize old black & white photos")
with gr.Column(scale=1, label = "Colorize photo", visible=True) as colorize_column:
colorize_input = gr.Image(type="file")
colorize_button = gr.Button("Colorize!")
colorize_output = gr.outputs.Image(type="numpy", label="Output(The colorized image)")
download_colorize_button = gr.outputs.File(label="Download colorized image!")
colorize_button.click(colorize_image, inputs=colorize_input, outputs=colorize_output)
enhancer.launch()
def run_code():
create_interface()
# The main function
run_code() |