Spaces:
Running
Running
Upload 4 files
Browse files- .gitattributes +1 -0
- app.py +34 -0
- input.jpg +0 -0
- output.png +3 -0
- requirements.txt +6 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
output.png filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import cv2
|
3 |
+
import tempfile
|
4 |
+
from modelscope.outputs import OutputKeys
|
5 |
+
from modelscope.pipelines import pipeline
|
6 |
+
from modelscope.utils.constant import Tasks
|
7 |
+
import PIL
|
8 |
+
from pathlib import Path
|
9 |
+
import gradio as gr
|
10 |
+
import numpy as np
|
11 |
+
|
12 |
+
"""Load the model into memory to make running multiple predictions efficient"""
|
13 |
+
img_colorization = pipeline(Tasks.image_colorization, model='iic/cv_ddcolor_image-colorization')
|
14 |
+
|
15 |
+
|
16 |
+
def inference(img):
|
17 |
+
image = cv2.imread(str(img))
|
18 |
+
|
19 |
+
output = img_colorization(image[..., ::-1])
|
20 |
+
result = output[OutputKeys.OUTPUT_IMG].astype(np.uint8)
|
21 |
+
|
22 |
+
temp_dir = tempfile.mkdtemp()
|
23 |
+
out_path = os.path.join(temp_dir, 'old-to-color.png')
|
24 |
+
cv2.imwrite(out_path, result)
|
25 |
+
return Path(out_path)
|
26 |
+
|
27 |
+
|
28 |
+
title = "Color Restorization Model"
|
29 |
+
gr.Interface(
|
30 |
+
inference,
|
31 |
+
[gr.inputs.Image(type="filepath", label="Input")],
|
32 |
+
gr.outputs.Image(type="pil", label="Output"),
|
33 |
+
title=title
|
34 |
+
).launch(enable_queue=True)
|
input.jpg
ADDED
output.png
ADDED
Git LFS Details
|
requirements.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
modelscope
|
2 |
+
Pillow
|
3 |
+
numpy
|
4 |
+
torch
|
5 |
+
sentencepiece
|
6 |
+
timm
|