Spaces:
Sleeping
Sleeping
File size: 1,353 Bytes
8eec341 c22c563 8eec341 |
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 |
import gradio as gr
from PIL import Image
import os
import numpy as np
# from outpaint import outpainting
# from model import colorazation, UNETmodel, utils1
# from model import inference, model
# from model import colorazation, deeplabmodel, utils
from model import MainModel
import inference as inf
# pretrained model
def colorize_image(image):
# Load the model
# file_path = 'ImageColorizationModel10.pth'
file_path = './model/model_final.pth'
model_2 = inf.load_model(model_class=MainModel, file_path=file_path)
output_img = inf.predict_color(model_2, image=image)
return output_img
# pretrained model
colorization_interface = gr.Interface(
colorize_image,
gr.Image(type="pil", label="Input Image"),
[gr.Image(type="pil", label="Output Image")],
title="Image Colorization",
description="Upload an image to perform colorization.",
)
# deeplab model
# depinterface = gr.Interface(
# depColorize_image,
# gr.Image(type="pil", label="Input Image"),
# [gr.Image(type="pil", label="Output Image")],
# title="Image Colorization",
# description="Upload an image to perform colorization.",
# )
# scratch mod
# Launch the interface
# interface.launch(share=True)
with gr.TabbedInterface([ colorization_interface ], ["Colorization_pretrain_unet"]) as tabs:
tabs.launch(share=True) |