Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,7 +112,7 @@ def image_resize(image, width = None, height = None, inter = cv2.INTER_AREA):
|
|
| 112 |
def inference(file, mode):
|
| 113 |
|
| 114 |
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
| 115 |
-
im = cv2.resize(im, (0,0), fx=
|
| 116 |
faceenhancer = FaceEnhancement(size=512, model='GPEN-512', channel_multiplier=2, device='cpu', u=False)
|
| 117 |
img, orig_faces, enhanced_faces = faceenhancer.process(im)
|
| 118 |
cv2.imwrite(os.path.join("e.png"), img)
|
|
@@ -133,11 +133,10 @@ def inference(file, mode):
|
|
| 133 |
elif mode == "inpainting":
|
| 134 |
im1 = cv2.imread(file, cv2.IMREAD_COLOR)
|
| 135 |
im2 = image_resize(im1, width = 1024)
|
| 136 |
-
im3 = cv2.resize(im2, (0,0), fx=3, fy=3)
|
| 137 |
model = {'name':'GPEN-Inpainting-1024', 'size':1024}
|
| 138 |
faceinpainter = FaceInpainting(size=model['size'], model=model['name'], channel_multiplier=2, device='cpu')
|
| 139 |
-
|
| 140 |
-
inpaint = faceinpainter.process(
|
| 141 |
|
| 142 |
cv2.imwrite(os.path.join("output.png"), inpaint)
|
| 143 |
return os.path.join("output.png")
|
|
|
|
| 112 |
def inference(file, mode):
|
| 113 |
|
| 114 |
im = cv2.imread(file, cv2.IMREAD_COLOR)
|
| 115 |
+
im = cv2.resize(im, (0,0), fx=2, fy=2)
|
| 116 |
faceenhancer = FaceEnhancement(size=512, model='GPEN-512', channel_multiplier=2, device='cpu', u=False)
|
| 117 |
img, orig_faces, enhanced_faces = faceenhancer.process(im)
|
| 118 |
cv2.imwrite(os.path.join("e.png"), img)
|
|
|
|
| 133 |
elif mode == "inpainting":
|
| 134 |
im1 = cv2.imread(file, cv2.IMREAD_COLOR)
|
| 135 |
im2 = image_resize(im1, width = 1024)
|
|
|
|
| 136 |
model = {'name':'GPEN-Inpainting-1024', 'size':1024}
|
| 137 |
faceinpainter = FaceInpainting(size=model['size'], model=model['name'], channel_multiplier=2, device='cpu')
|
| 138 |
+
im3 = np.asarray(brush_stroke_mask(Image.fromarray(im2)))
|
| 139 |
+
inpaint = faceinpainter.process(im3)
|
| 140 |
|
| 141 |
cv2.imwrite(os.path.join("output.png"), inpaint)
|
| 142 |
return os.path.join("output.png")
|