Spaces:
Runtime error
Runtime error
fix huggingface queue jam.
Browse files
app.py
CHANGED
@@ -16,6 +16,7 @@ from torchvision.transforms.functional import normalize
|
|
16 |
from basicsr.utils import imwrite, img2tensor, tensor2img
|
17 |
from basicsr.utils.download_util import load_file_from_url
|
18 |
from facelib.utils.face_restoration_helper import FaceRestoreHelper
|
|
|
19 |
from basicsr.archs.rrdbnet_arch import RRDBNet
|
20 |
from basicsr.utils.realesrgan_utils import RealESRGANer
|
21 |
|
@@ -108,6 +109,7 @@ def inference(image, background_enhance, face_upsample, upscale, codeformer_fide
|
|
108 |
draw_box = False
|
109 |
detection_model = "retinaface_resnet50"
|
110 |
|
|
|
111 |
face_helper = FaceRestoreHelper(
|
112 |
upscale,
|
113 |
face_size=512,
|
@@ -125,6 +127,9 @@ def inference(image, background_enhance, face_upsample, upscale, codeformer_fide
|
|
125 |
if has_aligned:
|
126 |
# the input faces are already cropped and aligned
|
127 |
img = cv2.resize(img, (512, 512), interpolation=cv2.INTER_LINEAR)
|
|
|
|
|
|
|
128 |
face_helper.cropped_faces = [img]
|
129 |
else:
|
130 |
face_helper.read_image(img)
|
@@ -228,7 +233,7 @@ If you have any questions, please feel free to reach me out at <b>shangchenzhou@
|
|
228 |

|
229 |
"""
|
230 |
|
231 |
-
gr.Interface(
|
232 |
inference, [
|
233 |
gr.inputs.Image(type="filepath", label="Input"),
|
234 |
gr.inputs.Checkbox(default=True, label="Background_Enhance"),
|
@@ -249,3 +254,6 @@ gr.Interface(
|
|
249 |
['05.jpg', True, True, 2, 0.1]
|
250 |
]
|
251 |
).launch()
|
|
|
|
|
|
|
|
16 |
from basicsr.utils import imwrite, img2tensor, tensor2img
|
17 |
from basicsr.utils.download_util import load_file_from_url
|
18 |
from facelib.utils.face_restoration_helper import FaceRestoreHelper
|
19 |
+
from facelib.utils.misc import is_gray
|
20 |
from basicsr.archs.rrdbnet_arch import RRDBNet
|
21 |
from basicsr.utils.realesrgan_utils import RealESRGANer
|
22 |
|
|
|
109 |
draw_box = False
|
110 |
detection_model = "retinaface_resnet50"
|
111 |
|
112 |
+
upscale = int(upscale) # covert type to int
|
113 |
face_helper = FaceRestoreHelper(
|
114 |
upscale,
|
115 |
face_size=512,
|
|
|
127 |
if has_aligned:
|
128 |
# the input faces are already cropped and aligned
|
129 |
img = cv2.resize(img, (512, 512), interpolation=cv2.INTER_LINEAR)
|
130 |
+
face_helper.is_gray = is_gray(img, threshold=5)
|
131 |
+
if face_helper.is_gray:
|
132 |
+
print('Grayscale input: True')
|
133 |
face_helper.cropped_faces = [img]
|
134 |
else:
|
135 |
face_helper.read_image(img)
|
|
|
233 |

|
234 |
"""
|
235 |
|
236 |
+
demo = gr.Interface(
|
237 |
inference, [
|
238 |
gr.inputs.Image(type="filepath", label="Input"),
|
239 |
gr.inputs.Checkbox(default=True, label="Background_Enhance"),
|
|
|
254 |
['05.jpg', True, True, 2, 0.1]
|
255 |
]
|
256 |
).launch()
|
257 |
+
|
258 |
+
demo.queue(concurrency_count=4)
|
259 |
+
demo.launch()
|