Spaces:
Running
Running
Test
Browse files
app.py
CHANGED
@@ -28,8 +28,15 @@ def inference(file, mode):
|
|
28 |
cv2.imwrite(os.path.join("output.png"), img)
|
29 |
return os.path.join("output.png")
|
30 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
model = {'name':'GPEN-1024-Color', 'size':1024}
|
32 |
-
grayf = cv2.imread(
|
33 |
grayf = cv2.cvtColor(grayf, cv2.COLOR_GRAY2BGR) # channel: 1->3
|
34 |
facecolorizer = FaceColorization(size=model['size'], model=model['name'], channel_multiplier=2, device='cpu')
|
35 |
colorf = facecolorizer.process(grayf)
|
|
|
28 |
cv2.imwrite(os.path.join("output.png"), img)
|
29 |
return os.path.join("output.png")
|
30 |
else:
|
31 |
+
emodel = {'name':'GPEN-512', 'size':512}
|
32 |
+
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
33 |
+
im = cv2.resize(im, (0,0), fx=2, fy=2)
|
34 |
+
faceenhancer = FaceEnhancement(size=model['size'], model=emodel['name'], channel_multiplier=2, device='cpu')
|
35 |
+
img, orig_faces, enhanced_faces = faceenhancer.process(im)
|
36 |
+
cv2.imwrite(os.path.join("enhanced.png"), img)
|
37 |
+
|
38 |
model = {'name':'GPEN-1024-Color', 'size':1024}
|
39 |
+
grayf = cv2.imread("enhanced.png", cv2.IMREAD_GRAYSCALE)
|
40 |
grayf = cv2.cvtColor(grayf, cv2.COLOR_GRAY2BGR) # channel: 1->3
|
41 |
facecolorizer = FaceColorization(size=model['size'], model=model['name'], channel_multiplier=2, device='cpu')
|
42 |
colorf = facecolorizer.process(grayf)
|