Spaces:
Running
Running
app.py
CHANGED
@@ -21,14 +21,14 @@ def inference(file, mode):
|
|
21 |
if mode == "enhance":
|
22 |
model = {'name':'GPEN-512', 'size':512}
|
23 |
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
24 |
-
faceenhancer = FaceEnhancement(size=model['size'], model=model['name'], channel_multiplier=2)
|
25 |
img, orig_faces, enhanced_faces = faceenhancer.process(im)
|
26 |
return enhanced_faces[0][:,:,::-1]
|
27 |
else:
|
28 |
model = {'name':'GPEN-1024-Color', 'size':1024}
|
29 |
grayf = cv2.imread(file, cv2.IMREAD_GRAYSCALE)
|
30 |
grayf = cv2.cvtColor(grayf, cv2.COLOR_GRAY2BGR) # channel: 1->3
|
31 |
-
facecolorizer = FaceColorization(size=model['size'], model=model['name'])
|
32 |
colorf = facecolorizer.process(grayf)
|
33 |
|
34 |
colorf = cv2.resize(colorf, (grayf.shape[1], grayf.shape[0]))
|
|
|
21 |
if mode == "enhance":
|
22 |
model = {'name':'GPEN-512', 'size':512}
|
23 |
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
24 |
+
faceenhancer = FaceEnhancement(size=model['size'], model=model['name'], channel_multiplier=2, device='cpu')
|
25 |
img, orig_faces, enhanced_faces = faceenhancer.process(im)
|
26 |
return enhanced_faces[0][:,:,::-1]
|
27 |
else:
|
28 |
model = {'name':'GPEN-1024-Color', 'size':1024}
|
29 |
grayf = cv2.imread(file, cv2.IMREAD_GRAYSCALE)
|
30 |
grayf = cv2.cvtColor(grayf, cv2.COLOR_GRAY2BGR) # channel: 1->3
|
31 |
+
facecolorizer = FaceColorization(size=model['size'], model=model['name'], channel_multiplier=2, device='cpu')
|
32 |
colorf = facecolorizer.process(grayf)
|
33 |
|
34 |
colorf = cv2.resize(colorf, (grayf.shape[1], grayf.shape[0]))
|