Spaces:
Runtime error
Runtime error
Commit
·
fe07cf7
1
Parent(s):
4162d5c
resize output image
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ pb = 'dmt.pb'
|
|
| 10 |
style_dim = 8
|
| 11 |
img_size=256
|
| 12 |
|
| 13 |
-
model_scale = EdsrModel.from_pretrained('eugenesiow/edsr-base', scale=
|
| 14 |
|
| 15 |
def preprocess(img):
|
| 16 |
return (img / 255. - 0.5) * 2
|
|
@@ -47,8 +47,7 @@ def inference(A,B):
|
|
| 47 |
image = Image.fromarray(output)
|
| 48 |
inputs = ImageLoader.load_image(image)
|
| 49 |
preds = model_scale(inputs)
|
| 50 |
-
|
| 51 |
-
ImageLoader.save_image(preds, 'output/scaled_2x.png')
|
| 52 |
|
| 53 |
|
| 54 |
|
|
@@ -63,7 +62,12 @@ def makeupTransfer(arr1,arr2):
|
|
| 63 |
no_makeup = "input/original.png"
|
| 64 |
makeup = "input/ref.png"
|
| 65 |
inference(no_makeup, makeup)
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
|
| 69 |
examples = [['faces/no_makeup/xfsy_0226.png', 'faces/makeup/XMY-136.png'],
|
|
|
|
| 10 |
style_dim = 8
|
| 11 |
img_size=256
|
| 12 |
|
| 13 |
+
model_scale = EdsrModel.from_pretrained('eugenesiow/edsr-base', scale=3)
|
| 14 |
|
| 15 |
def preprocess(img):
|
| 16 |
return (img / 255. - 0.5) * 2
|
|
|
|
| 47 |
image = Image.fromarray(output)
|
| 48 |
inputs = ImageLoader.load_image(image)
|
| 49 |
preds = model_scale(inputs)
|
| 50 |
+
ImageLoader.save_image(preds, 'output/scaled_3x.png')
|
|
|
|
| 51 |
|
| 52 |
|
| 53 |
|
|
|
|
| 62 |
no_makeup = "input/original.png"
|
| 63 |
makeup = "input/ref.png"
|
| 64 |
inference(no_makeup, makeup)
|
| 65 |
+
img = cv2.imread("output/scaled_3x.png")
|
| 66 |
+
h,w,_ = img.shape
|
| 67 |
+
h_new = 256
|
| 68 |
+
w_new = int((256/h)*w)
|
| 69 |
+
resize_img = cv2.resize(img,(w_new,h_new))
|
| 70 |
+
return cv2.cvtColor(resize_img, cv2.COLOR_BGR2RGB)
|
| 71 |
|
| 72 |
|
| 73 |
examples = [['faces/no_makeup/xfsy_0226.png', 'faces/makeup/XMY-136.png'],
|