Skip to content

Commit 8e4adf0

Browse files
committed
Updated main.py
src/model.py Signed-off-by: Mpho Mphego <mpho112@gmail.com>
1 parent f660015 commit 8e4adf0

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ def main(args):
141141
logger.info(f"Total time taken to load all the models: {model_load_time:.2f} secs.")
142142

143143
for frame in video_feed.next_frame():
144-
predict_end_time, _, face_bboxes = face_detection.predict(frame, draw=True)
144+
if args.debug:
145+
video_feed.show(video_feed.resize(frame))
146+
147+
predict_end_time, face_bboxes = face_detection.predict(frame, draw=True)
145148
text = f"Face Detection Inference time: {predict_end_time:.3f} s"
146149
face_detection.add_text(text, frame, (15, video_feed.source_height - 80))
147150

@@ -164,15 +167,12 @@ def main(args):
164167
if face_height < 20 or face_width < 20:
165168
continue
166169

167-
predict_end_time, _, landmarks_bboxes = facial_landmarks.predict(face, draw=True)
170+
predict_end_time, eyes_coords = facial_landmarks.predict(face, draw=True)
168171
text = f"Facial Landmarks Est. Inference time: {predict_end_time:.3f} s"
169172
facial_landmarks.add_text(
170173
text, frame, (15, video_feed.source_height - 60)
171174
)
172175

173-
if args.debug:
174-
video_feed.show(video_feed.resize(frame))
175-
176176
video_feed.close()
177177

178178

src/model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def predict(self, image, request_id=0, draw=False):
109109
predict_end_time = float(time.time() - predict_start_time) * 1000
110110
if draw:
111111
bbox, _ = self.preprocess_output(pred_result, image, show_bbox=draw)
112-
return (predict_end_time, pred_result, bbox)
112+
return (predict_end_time, bbox)
113113

114114
@abstractmethod
115115
def preprocess_output(self, inference_results, image, show_bbox=False):
@@ -257,14 +257,15 @@ def preprocess_output(self, inference_results, image, show_bbox=False):
257257
}
258258
if show_bbox:
259259
self.draw_output(image, eyes_coords)
260-
return eyes_coords
260+
return eyes_coords, image
261261

262262
@staticmethod
263263
def draw_output(image, eyes_coords, radius=10, color=(0, 0, 255), thickness=2):
264264
"""Draw a circle around ROI"""
265265
for eye, coords in eyes_coords.items():
266266
cv2.circle(image, (coords[0], coords[1]), radius, color, thickness)
267267

268+
268269
class Head_Pose_Estimation(Base):
269270
"""Class for the Head Pose Estimation Model."""
270271

0 commit comments

Comments
 (0)