Spaces:
Runtime error
Runtime error
File size: 878 Bytes
6ed3de5 c080fe4 228d4a3 f2cc150 228d4a3 c080fe4 228d4a3 c080fe4 228d4a3 b326d68 228d4a3 c080fe4 228d4a3 6ed3de5 c080fe4 |
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 |
import subprocess
import os
import gradio as gr
import paddlehub as hub
from pathlib import Path
# Install DeOldify model
os.system("hub install deoldify==1.0.1")
# Load the DeOldify model
model = hub.Module(name='deoldify')
# Function to colorize an image
def colorize_image(image):
# Colorize the image using the DeOldify model
model.predict(images=[str(image)], output_dir='./output')
output_path = './output/' + Path(image.name).stem + ".png"
return output_path
# Create the Gradio interface
def create_interface():
gr.Interface(
fn=colorize_image,
inputs="image",
outputs="image",
live=True,
title="DeOldify - Colorize Black & White Photos",
description="Upload a black and white photo to colorize it.",
).launch()
if __name__ == "__main__":
# Run the Gradio interface
create_interface()
|