Skip to content

Commit

Permalink
refactor: remove useless conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
saidsay-so committed Sep 12, 2023
1 parent 0eb3eeb commit 466c859
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions howdy/src/cli/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@

use_cnn = config.getboolean("core", "use_cnn", fallback=False)
if use_cnn:
face_detector = dlib.cnn_face_detection_model_v1(str(paths_factory.mmod_human_face_detector_path()))
face_detector = dlib.cnn_face_detection_model_v1(paths_factory.mmod_human_face_detector_path())
else:
face_detector = dlib.get_frontal_face_detector()

pose_predictor = dlib.shape_predictor(str(paths_factory.shape_predictor_5_face_landmarks_path()))
face_encoder = dlib.face_recognition_model_v1(str(paths_factory.dlib_face_recognition_resnet_model_v1_path()))
pose_predictor = dlib.shape_predictor(paths_factory.shape_predictor_5_face_landmarks_path())
face_encoder = dlib.face_recognition_model_v1(paths_factory.dlib_face_recognition_resnet_model_v1_path())

user = builtins.howdy_user
# The permanent file to store the encoded model in
enc_file = str(paths_factory.user_model_path(user))
enc_file = paths_factory.user_model_path(user)
# Known encodings
encodings = []

Expand Down
6 changes: 3 additions & 3 deletions howdy/src/cli/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ def print_text(line_number, text):

if use_cnn:
face_detector = dlib.cnn_face_detection_model_v1(
str(paths_factory.mmod_human_face_detector_path())
paths_factory.mmod_human_face_detector_path()
)
else:
face_detector = dlib.get_frontal_face_detector()

pose_predictor = dlib.shape_predictor(str(paths_factory.shape_predictor_5_face_landmarks_path()))
face_encoder = dlib.face_recognition_model_v1(str(paths_factory.dlib_face_recognition_resnet_model_v1_path()))
pose_predictor = dlib.shape_predictor(paths_factory.shape_predictor_5_face_landmarks_path())
face_encoder = dlib.face_recognition_model_v1(paths_factory.dlib_face_recognition_resnet_model_v1_path())

encodings = []
models = None
Expand Down
8 changes: 4 additions & 4 deletions howdy/src/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def init_detector(lock):
global face_detector, pose_predictor, face_encoder

# Test if at lest 1 of the data files is there and abort if it's not
if not os.path.isfile(str(paths_factory.shape_predictor_5_face_landmarks_path())):
if not os.path.isfile(paths_factory.shape_predictor_5_face_landmarks_path()):
print(_("Data files have not been downloaded, please run the following commands:"))
print("\n\tcd " + paths_factory.dlib_data_dir_path())
print("\tsudo ./install.sh\n")
Expand All @@ -54,13 +54,13 @@ def init_detector(lock):

# Use the CNN detector if enabled
if use_cnn:
face_detector = dlib.cnn_face_detection_model_v1(str(paths_factory.mmod_human_face_detector_path()))
face_detector = dlib.cnn_face_detection_model_v1(paths_factory.mmod_human_face_detector_path())
else:
face_detector = dlib.get_frontal_face_detector()

# Start the others regardless
pose_predictor = dlib.shape_predictor(str(paths_factory.shape_predictor_5_face_landmarks_path()))
face_encoder = dlib.face_recognition_model_v1(str(paths_factory.dlib_face_recognition_resnet_model_v1_path()))
pose_predictor = dlib.shape_predictor(paths_factory.shape_predictor_5_face_landmarks_path())
face_encoder = dlib.face_recognition_model_v1(paths_factory.dlib_face_recognition_resnet_model_v1_path())

# Note the time it took to initialize detectors
timings["ll"] = time.time() - timings["ll"]
Expand Down
3 changes: 1 addition & 2 deletions howdy/src/pam/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ subdir('po')
paths_h = configure_file(
input: 'paths.hh.in',
output: 'paths.hh',
configuration: pam_module_conf_data,
install_dir: get_option('pam_dir')
configuration: pam_module_conf_data
)

pamdir = get_option('pam_dir') != '' ? get_option('pam_dir') : join_paths(get_option('prefix'), get_option('libdir'), 'security')
Expand Down
4 changes: 2 additions & 2 deletions howdy/src/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def generate(frames, text_lines):
# Add the Howdy logo if there's space to do so
if len(frames) > 1:
# Load the logo from file
logo = cv2.imread(str(paths_factory.logo_path()))
logo = cv2.imread(paths_factory.logo_path())
# Calculate the position of the logo
logo_y = frame_height + 20
logo_x = frame_width * len(frames) - 210
Expand All @@ -54,7 +54,7 @@ def generate(frames, text_lines):

# Generate a filename based on the current time
filename = datetime.datetime.utcnow().strftime("%Y%m%dT%H%M%S.jpg")
filepath = str(paths_factory.snapshot_path(filename))
filepath = paths_factory.snapshot_path(filename)
# Write the image to that file
cv2.imwrite(filepath, snap)

Expand Down

0 comments on commit 466c859

Please sign in to comment.