Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -91,7 +91,7 @@ def inference(file, mode):
|
|
| 91 |
elif mode == "colorize":
|
| 92 |
model = {'name':'GPEN-1024-Color', 'size':1024}
|
| 93 |
grayf = cv2.imread("e.png", cv2.IMREAD_GRAYSCALE)
|
| 94 |
-
grayf = cv2.cvtColor(grayf, cv2.COLOR_GRAY2BGR)
|
| 95 |
facecolorizer = FaceColorization(size=model['size'], model=model['name'], channel_multiplier=2, device='cpu')
|
| 96 |
colorf = facecolorizer.process(grayf)
|
| 97 |
|
|
@@ -101,8 +101,8 @@ def inference(file, mode):
|
|
| 101 |
elif mode == "inpainting":
|
| 102 |
model = {'name':'GPEN-Inpainting-1024', 'size':1024}
|
| 103 |
faceinpainter = FaceInpainting(size=model['size'], model=model['name'], channel_multiplier=2, device='cpu')
|
| 104 |
-
|
| 105 |
-
inpaint = faceinpainter.process(
|
| 106 |
|
| 107 |
cv2.imwrite(os.path.join("output.png"), inpaint)
|
| 108 |
return os.path.join("output.png")
|
|
|
|
| 91 |
elif mode == "colorize":
|
| 92 |
model = {'name':'GPEN-1024-Color', 'size':1024}
|
| 93 |
grayf = cv2.imread("e.png", cv2.IMREAD_GRAYSCALE)
|
| 94 |
+
grayf = cv2.cvtColor(grayf, cv2.COLOR_GRAY2BGR) # channel: 1->3
|
| 95 |
facecolorizer = FaceColorization(size=model['size'], model=model['name'], channel_multiplier=2, device='cpu')
|
| 96 |
colorf = facecolorizer.process(grayf)
|
| 97 |
|
|
|
|
| 101 |
elif mode == "inpainting":
|
| 102 |
model = {'name':'GPEN-Inpainting-1024', 'size':1024}
|
| 103 |
faceinpainter = FaceInpainting(size=model['size'], model=model['name'], channel_multiplier=2, device='cpu')
|
| 104 |
+
im = np.asarray(brush_stroke_mask(Image.fromarray(im)))
|
| 105 |
+
inpaint = faceinpainter.process(im)
|
| 106 |
|
| 107 |
cv2.imwrite(os.path.join("output.png"), inpaint)
|
| 108 |
return os.path.join("output.png")
|