Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -18,21 +18,20 @@ from face_colorization import FaceColorization
|
|
18 |
|
19 |
|
20 |
def inference(file, mode):
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
if mode == "enhance":
|
23 |
-
model = {'name':'GPEN-512', 'size':512}
|
24 |
-
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
25 |
-
im = cv2.resize(im, (0,0), fx=2, fy=2)
|
26 |
-
faceenhancer = FaceEnhancement(size=model['size'], model=model['name'], channel_multiplier=2, device='cpu')
|
27 |
-
img, orig_faces, enhanced_faces = faceenhancer.process(im)
|
28 |
cv2.imwrite(os.path.join("output.png"), img)
|
29 |
return os.path.join("output.png")
|
30 |
else:
|
31 |
-
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
32 |
-
im = cv2.resize(im, (0,0), fx=2, fy=2)
|
33 |
-
faceenhancer = FaceEnhancement(size=512, model='GPEN-512', channel_multiplier=2, device='cpu')
|
34 |
-
img, orig_faces, enhanced_faces = faceenhancer.process(im)
|
35 |
-
|
36 |
model = {'name':'GPEN-1024-Color', 'size':1024}
|
37 |
grayf = cv2.imread("enhanced.png", cv2.IMREAD_GRAYSCALE)
|
38 |
grayf = cv2.cvtColor(grayf, cv2.COLOR_GRAY2BGR) # channel: 1->3
|
|
|
18 |
|
19 |
|
20 |
def inference(file, mode):
|
21 |
+
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
22 |
+
im = cv2.resize(im, (0,0), fx=2, fy=2)
|
23 |
+
faceenhancer = FaceEnhancement(size=512, model='GPEN-512', channel_multiplier=2, device='cpu')
|
24 |
+
img, orig_faces, enhanced_faces = faceenhancer.process(im)
|
25 |
+
|
26 |
if mode == "enhance":
|
27 |
+
# model = {'name':'GPEN-512', 'size':512}
|
28 |
+
# im = cv2.imread(file, cv2.IMREAD_COLOR)
|
29 |
+
# im = cv2.resize(im, (0,0), fx=2, fy=2)
|
30 |
+
# faceenhancer = FaceEnhancement(size=model['size'], model=model['name'], channel_multiplier=2, device='cpu')
|
31 |
+
# img, orig_faces, enhanced_faces = faceenhancer.process(im)
|
32 |
cv2.imwrite(os.path.join("output.png"), img)
|
33 |
return os.path.join("output.png")
|
34 |
else:
|
|
|
|
|
|
|
|
|
|
|
35 |
model = {'name':'GPEN-1024-Color', 'size':1024}
|
36 |
grayf = cv2.imread("enhanced.png", cv2.IMREAD_GRAYSCALE)
|
37 |
grayf = cv2.cvtColor(grayf, cv2.COLOR_GRAY2BGR) # channel: 1->3
|