Update app.py
Browse files
app.py
CHANGED
|
@@ -108,11 +108,9 @@ def enhance_face(img, face_helper, has_aligned, num_flow_steps, scale=2):
|
|
| 108 |
face_helper.get_face_landmarks_5(only_center_face=False, eye_dist_threshold=5)
|
| 109 |
face_helper.align_warp_face()
|
| 110 |
if len(face_helper.cropped_faces) == 0:
|
| 111 |
-
raise
|
| 112 |
if has_aligned and len(face_helper.cropped_faces) > 1:
|
| 113 |
-
raise
|
| 114 |
-
"You marked that the input image is aligned, but multiple faces were detected."
|
| 115 |
-
)
|
| 116 |
|
| 117 |
# face restoration
|
| 118 |
for i, cropped_face in tqdm(enumerate(face_helper.cropped_faces)):
|
|
@@ -157,14 +155,14 @@ def inference(
|
|
| 157 |
progress=gr.Progress(track_tqdm=True),
|
| 158 |
):
|
| 159 |
if img is None:
|
| 160 |
-
raise
|
| 161 |
if randomize_seed:
|
| 162 |
seed = random.randint(0, MAX_SEED)
|
| 163 |
torch.manual_seed(seed)
|
| 164 |
img = cv2.imread(img, cv2.IMREAD_COLOR)
|
| 165 |
h, w = img.shape[0:2]
|
| 166 |
if h > 4500 or w > 4500:
|
| 167 |
-
raise
|
| 168 |
|
| 169 |
face_helper = FaceRestoreHelper(
|
| 170 |
scale,
|
|
|
|
| 108 |
face_helper.get_face_landmarks_5(only_center_face=False, eye_dist_threshold=5)
|
| 109 |
face_helper.align_warp_face()
|
| 110 |
if len(face_helper.cropped_faces) == 0:
|
| 111 |
+
raise Exception("Could not identify any face in the image.")
|
| 112 |
if has_aligned and len(face_helper.cropped_faces) > 1:
|
| 113 |
+
raise Exception("You marked that the input image is aligned, but multiple faces were detected.")
|
|
|
|
|
|
|
| 114 |
|
| 115 |
# face restoration
|
| 116 |
for i, cropped_face in tqdm(enumerate(face_helper.cropped_faces)):
|
|
|
|
| 155 |
progress=gr.Progress(track_tqdm=True),
|
| 156 |
):
|
| 157 |
if img is None:
|
| 158 |
+
raise Exception("Please upload an image before submitting.")
|
| 159 |
if randomize_seed:
|
| 160 |
seed = random.randint(0, MAX_SEED)
|
| 161 |
torch.manual_seed(seed)
|
| 162 |
img = cv2.imread(img, cv2.IMREAD_COLOR)
|
| 163 |
h, w = img.shape[0:2]
|
| 164 |
if h > 4500 or w > 4500:
|
| 165 |
+
raise Exception("Image size too large.")
|
| 166 |
|
| 167 |
face_helper = FaceRestoreHelper(
|
| 168 |
scale,
|