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 |
-
from super_image import EdsrModel, ImageLoader
|
| 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 |
-
model_scale = EdsrModel.from_pretrained('eugenesiow/edsr-base', scale=2)
|
| 14 |
|
| 15 |
def preprocess(img):
|
| 16 |
return (img / 255. - 0.5) * 2
|
|
@@ -44,10 +44,11 @@ def inference(A,B):
|
|
| 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 |
|
| 52 |
|
| 53 |
|
|
@@ -61,10 +62,10 @@ def makeupTransfer(arr1,arr2):
|
|
| 61 |
cv2.imwrite("input/ref.png",output2)
|
| 62 |
no_makeup = "input/original.png"
|
| 63 |
makeup = "input/ref.png"
|
| 64 |
-
inference(no_makeup, makeup)
|
| 65 |
-
img = cv2.imread("output/scaled_2x.png")
|
| 66 |
-
return cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 67 |
-
|
| 68 |
|
| 69 |
examples = [['faces/no_makeup/xfsy_0226.png', 'faces/makeup/XMY-136.png'],
|
| 70 |
['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
|
|
|
|
| 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 |
+
tr_out = 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'],
|