Spaces:
Build error
Build error
emirhanbilgic
commited on
Commit
•
c9970db
1
Parent(s):
ef101b1
Update app.py
Browse files
app.py
CHANGED
@@ -71,10 +71,28 @@ def setup():
|
|
71 |
app, ip_model = setup()
|
72 |
|
73 |
def get_face_landmarks(image_path):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
detector = dlib.get_frontal_face_detector()
|
75 |
predictor = dlib.shape_predictor('faceid/shape_predictor_68_face_landmarks.dat')
|
|
|
76 |
image = cv2.imread(image_path)
|
77 |
image = imutils.resize(image, width=512)
|
|
|
|
|
|
|
|
|
78 |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
79 |
rects = detector(gray, 1)
|
80 |
for (i, rect) in enumerate(rects):
|
|
|
71 |
app, ip_model = setup()
|
72 |
|
73 |
def get_face_landmarks(image_path):
|
74 |
+
def add_padding(image, padding_size=50):
|
75 |
+
height, width = image.shape[:2]
|
76 |
+
padded_image = cv2.copyMakeBorder(
|
77 |
+
image,
|
78 |
+
top=padding_size,
|
79 |
+
bottom=padding_size,
|
80 |
+
left=padding_size,
|
81 |
+
right=padding_size,
|
82 |
+
borderType=cv2.BORDER_CONSTANT,
|
83 |
+
value=[255, 255, 255] # White padding
|
84 |
+
)
|
85 |
+
return padded_image
|
86 |
+
|
87 |
detector = dlib.get_frontal_face_detector()
|
88 |
predictor = dlib.shape_predictor('faceid/shape_predictor_68_face_landmarks.dat')
|
89 |
+
|
90 |
image = cv2.imread(image_path)
|
91 |
image = imutils.resize(image, width=512)
|
92 |
+
|
93 |
+
# Add padding to the image
|
94 |
+
image = add_padding(image)
|
95 |
+
|
96 |
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
97 |
rects = detector(gray, 1)
|
98 |
for (i, rect) in enumerate(rects):
|