Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 916 Bytes
b116026 50ed895 d8bf5cd 50ed895 387bac2 |
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 |
import gradio as gr
import os
import cv2
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
import PIL
import numpy as np
img_colorization = pipeline(Tasks.image_colorization, model='iic/cv_ddcolor_image-colorization')
img_path = 'input.png'
##result = img_colorization(img_path)
##cv2.imwrite('result.png', result[OutputKeys.OUTPUT_IMG])
def color(image):
output = img_colorization(image[...,::-1])
result = output[OutputKeys.OUTPUT_IMG].astype(np.uint8)
result = result[...,::-1]
print('infer finished!')
return result
title = "old_photo_restoration"
description = "upload old photo, ddcolor image colorization"
examples = [['./input.jpg'],]
demo = gr.Interface(fn=color,inputs="image",outputs="image",examples=examples,title=title,description=description)
if __name__ == "__main__":
demo.launch(share=False) |