LogicGoInfotechSpaces commited on
Commit
aa366ec
·
1 Parent(s): 8bc66d4

Remove dlib dependency and make face alignment optional

Browse files
Files changed (2) hide show
  1. requirements.txt +0 -1
  2. runners/simple_runner.py +5 -2
requirements.txt CHANGED
@@ -19,4 +19,3 @@ torch
19
  torchvision
20
  clip @ git+https://github.com/openai/CLIP.git@a1d071733d7111c9c014f024669f959182114e33
21
  spaces>=0.28.3
22
- dlib
 
19
  torchvision
20
  clip @ git+https://github.com/openai/CLIP.git@a1d071733d7111c9c014f024669f959182114e33
21
  spaces>=0.28.3
 
runners/simple_runner.py CHANGED
@@ -63,8 +63,11 @@ def extract_mask(image_path, save_dir_path, trash=0.995):
63
 
64
 
65
  def run_alignment(image_path):
66
- import dlib
67
- from scripts.align_all_parallel import align_face
 
 
 
68
 
69
  predictor = dlib.shape_predictor("pretrained_models/shape_predictor_68_face_landmarks.dat")
70
  aligned_image, unalign_dict = align_face(filepath=image_path, predictor=predictor)
 
63
 
64
 
65
  def run_alignment(image_path):
66
+ try:
67
+ import dlib
68
+ from scripts.align_all_parallel import align_face
69
+ except ImportError:
70
+ raise ImportError("dlib is required for face alignment. Please install dlib or disable face alignment.")
71
 
72
  predictor = dlib.shape_predictor("pretrained_models/shape_predictor_68_face_landmarks.dat")
73
  aligned_image, unalign_dict = align_face(filepath=image_path, predictor=predictor)