Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import tensorflow as tf
|
|
| 2 |
import numpy as np
|
| 3 |
from imageio.v2 import imread
|
| 4 |
import os, glob, cv2, shutil
|
| 5 |
-
|
| 6 |
from PIL import Image
|
| 7 |
import gradio as gr
|
| 8 |
|
|
@@ -10,7 +10,7 @@ pb = 'dmt.pb'
|
|
| 10 |
style_dim = 8
|
| 11 |
img_size=256
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
def preprocess(img):
|
| 16 |
return (img / 255. - 0.5) * 2
|
|
@@ -42,13 +42,13 @@ def inference(A,B):
|
|
| 42 |
Xs_ = sess.run(Xs, feed_dict={X: A_img_, Y: B_img_})
|
| 43 |
output = deprocess(Xs_)[0]
|
| 44 |
output = np.array(np.array(output)*255,dtype=np.uint8)
|
| 45 |
-
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
return output
|
| 52 |
|
| 53 |
|
| 54 |
|
|
@@ -62,10 +62,10 @@ def makeupTransfer(arr1,arr2):
|
|
| 62 |
cv2.imwrite("input/ref.png",output2)
|
| 63 |
no_makeup = "input/original.png"
|
| 64 |
makeup = "input/ref.png"
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
return tr_out
|
| 69 |
|
| 70 |
examples = [['faces/no_makeup/xfsy_0226.png', 'faces/makeup/XMY-136.png'],
|
| 71 |
['faces/no_makeup/XYUH-006.png', 'faces/makeup/XMY-266.png'],
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
from imageio.v2 import imread
|
| 4 |
import os, glob, cv2, shutil
|
| 5 |
+
from super_image import EdsrModel, ImageLoader
|
| 6 |
from PIL import Image
|
| 7 |
import gradio as gr
|
| 8 |
|
|
|
|
| 10 |
style_dim = 8
|
| 11 |
img_size=256
|
| 12 |
|
| 13 |
+
model_scale = EdsrModel.from_pretrained('eugenesiow/edsr-base', scale=2)
|
| 14 |
|
| 15 |
def preprocess(img):
|
| 16 |
return (img / 255. - 0.5) * 2
|
|
|
|
| 42 |
Xs_ = sess.run(Xs, feed_dict={X: A_img_, Y: B_img_})
|
| 43 |
output = deprocess(Xs_)[0]
|
| 44 |
output = np.array(np.array(output)*255,dtype=np.uint8)
|
| 45 |
+
output = cv2.cvtColor(output, cv2.COLOR_RGB2BGR)
|
| 46 |
|
| 47 |
+
image = Image.fromarray(output)
|
| 48 |
+
inputs = ImageLoader.load_image(image)
|
| 49 |
+
preds = model_scale(inputs)
|
| 50 |
+
ImageLoader.save_image(preds, 'output/scaled_2x.png')
|
| 51 |
+
# return output
|
| 52 |
|
| 53 |
|
| 54 |
|
|
|
|
| 62 |
cv2.imwrite("input/ref.png",output2)
|
| 63 |
no_makeup = "input/original.png"
|
| 64 |
makeup = "input/ref.png"
|
| 65 |
+
inference(no_makeup, makeup)
|
| 66 |
+
img = cv2.imread("output/scaled_2x.png")
|
| 67 |
+
return cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 68 |
+
# return tr_out
|
| 69 |
|
| 70 |
examples = [['faces/no_makeup/xfsy_0226.png', 'faces/makeup/XMY-136.png'],
|
| 71 |
['faces/no_makeup/XYUH-006.png', 'faces/makeup/XMY-266.png'],
|