Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,7 @@ from io import BytesIO
|
|
18 |
import os
|
19 |
from PIL import Image
|
20 |
import gdown
|
|
|
21 |
|
22 |
def download_gdrive_url():
|
23 |
url = 'https://drive.google.com/u/0/uc?id=1PPO2MCttsmSqyB-vKh5C7SumwFKuhgyj&export=download'
|
@@ -47,17 +48,15 @@ def inpaint(p, init_image, mask_image=None, strength=0.75, guidance_scale=7.5, g
|
|
47 |
return return_image
|
48 |
|
49 |
def identify_face(user_image):
|
50 |
-
img = cv2.imread(user_image.name) # read the resized image in cv2
|
|
|
51 |
print(img.shape)
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
for (x, y, w, h) in faces_rect[:1]:
|
57 |
-
mask = np.zeros(img.shape[:2], dtype="uint8")
|
58 |
-
print(mask.shape)
|
59 |
-
cv2.rectangle(mask, (x, y), (x+w, y+h), 255, -1)
|
60 |
print(mask.shape)
|
|
|
61 |
inverted_image = cv2.bitwise_not(mask)
|
62 |
return inverted_image
|
63 |
|
|
|
18 |
import os
|
19 |
from PIL import Image
|
20 |
import gdown
|
21 |
+
import face_recognition
|
22 |
|
23 |
def download_gdrive_url():
|
24 |
url = 'https://drive.google.com/u/0/uc?id=1PPO2MCttsmSqyB-vKh5C7SumwFKuhgyj&export=download'
|
|
|
48 |
return return_image
|
49 |
|
50 |
def identify_face(user_image):
|
51 |
+
# img = cv2.imread(user_image.name) # read the resized image in cv2
|
52 |
+
img = face_recognition.load_image_file(user_image.name)
|
53 |
print(img.shape)
|
54 |
+
face_locations = face_recognition.face_locations(img)
|
55 |
+
for face_location in face_locations:
|
56 |
+
top, right, bottom, left = face_location
|
57 |
+
mask = np.zeros(image.shape[:2], dtype="uint8")
|
|
|
|
|
|
|
|
|
58 |
print(mask.shape)
|
59 |
+
cv2.rectangle(mask, (left, top), (right, bottom), 255, -1)
|
60 |
inverted_image = cv2.bitwise_not(mask)
|
61 |
return inverted_image
|
62 |
|