Spaces:
Runtime error
Runtime error
add upscale limit.
Browse files
app.py
CHANGED
|
@@ -109,8 +109,12 @@ def inference(image, background_enhance, face_upsample, upscale, codeformer_fide
|
|
| 109 |
only_center_face = False
|
| 110 |
draw_box = False
|
| 111 |
detection_model = "retinaface_resnet50"
|
|
|
|
| 112 |
|
| 113 |
upscale = int(upscale) # covert type to int
|
|
|
|
|
|
|
|
|
|
| 114 |
face_helper = FaceRestoreHelper(
|
| 115 |
upscale,
|
| 116 |
face_size=512,
|
|
@@ -125,6 +129,8 @@ def inference(image, background_enhance, face_upsample, upscale, codeformer_fide
|
|
| 125 |
|
| 126 |
img = cv2.imread(str(image), cv2.IMREAD_COLOR)
|
| 127 |
|
|
|
|
|
|
|
| 128 |
if has_aligned:
|
| 129 |
# the input faces are already cropped and aligned
|
| 130 |
img = cv2.resize(img, (512, 512), interpolation=cv2.INTER_LINEAR)
|
|
@@ -241,8 +247,8 @@ demo = gr.Interface(
|
|
| 241 |
gr.inputs.Image(type="filepath", label="Input"),
|
| 242 |
gr.inputs.Checkbox(default=True, label="Background_Enhance"),
|
| 243 |
gr.inputs.Checkbox(default=True, label="Face_Upsample"),
|
| 244 |
-
gr.inputs.Number(default=2, label="Rescaling_Factor"),
|
| 245 |
-
gr.Slider(0, 1, value=0.5, step=0.01, label='Codeformer_Fidelity: 0
|
| 246 |
], [
|
| 247 |
gr.outputs.Image(type="numpy", label="Output"),
|
| 248 |
gr.outputs.File(label="Download the output")
|
|
|
|
| 109 |
only_center_face = False
|
| 110 |
draw_box = False
|
| 111 |
detection_model = "retinaface_resnet50"
|
| 112 |
+
print(image, background_enhance, face_upsample, upscale, codeformer_fidelity)
|
| 113 |
|
| 114 |
upscale = int(upscale) # covert type to int
|
| 115 |
+
if upscale > 4:
|
| 116 |
+
upscale = 4 # avoid momory exceeded due to too large upscale
|
| 117 |
+
|
| 118 |
face_helper = FaceRestoreHelper(
|
| 119 |
upscale,
|
| 120 |
face_size=512,
|
|
|
|
| 129 |
|
| 130 |
img = cv2.imread(str(image), cv2.IMREAD_COLOR)
|
| 131 |
|
| 132 |
+
print('Image size:', img.shape)
|
| 133 |
+
|
| 134 |
if has_aligned:
|
| 135 |
# the input faces are already cropped and aligned
|
| 136 |
img = cv2.resize(img, (512, 512), interpolation=cv2.INTER_LINEAR)
|
|
|
|
| 247 |
gr.inputs.Image(type="filepath", label="Input"),
|
| 248 |
gr.inputs.Checkbox(default=True, label="Background_Enhance"),
|
| 249 |
gr.inputs.Checkbox(default=True, label="Face_Upsample"),
|
| 250 |
+
gr.inputs.Number(default=2, label="Rescaling_Factor (up to 4)"),
|
| 251 |
+
gr.Slider(0, 1, value=0.5, step=0.01, label='Codeformer_Fidelity: 0 better quality, 1 better identity')
|
| 252 |
], [
|
| 253 |
gr.outputs.Image(type="numpy", label="Output"),
|
| 254 |
gr.outputs.File(label="Download the output")
|