Makhinur commited on
Commit
cafcff1
·
verified ·
1 Parent(s): a8db7a5

Update face_detection.py

Browse files
Files changed (1) hide show
  1. face_detection.py +2 -3
face_detection.py CHANGED
@@ -2,10 +2,11 @@ import insightface
2
  import numpy as np
3
  from PIL import Image, ImageOps
4
  import cv2
 
5
 
6
  # Load InsightFace models
7
  try:
8
- detector = insightface.model_zoo.get_model('retinaface_r50_v1')
9
  detector.prepare(ctx_id=-1) # Use CPU, set ctx_id=0 for GPU
10
  except Exception as e:
11
  print(f"Error loading face detection model: {e}")
@@ -52,8 +53,6 @@ def get_landmarks(image):
52
  landmarks = landmark_model.get(img, bbox)
53
  yield landmarks
54
 
55
- # Remaining functions remain unchanged
56
-
57
  def image_align(src_img, face_landmarks, output_size=512, transform_size=2048, enable_padding=True, x_scale=1, y_scale=1, em_scale=0.1, alpha=False):
58
  # Align function modified from ffhq-dataset
59
  # See https://github.com/NVlabs/ffhq-dataset for license
 
2
  import numpy as np
3
  from PIL import Image, ImageOps
4
  import cv2
5
+ from scipy.ndimage import gaussian_filter
6
 
7
  # Load InsightFace models
8
  try:
9
+ detector = insightface.model_zoo.get_model('retinaface_mnet025_v2')
10
  detector.prepare(ctx_id=-1) # Use CPU, set ctx_id=0 for GPU
11
  except Exception as e:
12
  print(f"Error loading face detection model: {e}")
 
53
  landmarks = landmark_model.get(img, bbox)
54
  yield landmarks
55
 
 
 
56
  def image_align(src_img, face_landmarks, output_size=512, transform_size=2048, enable_padding=True, x_scale=1, y_scale=1, em_scale=0.1, alpha=False):
57
  # Align function modified from ffhq-dataset
58
  # See https://github.com/NVlabs/ffhq-dataset for license