conciomith commited on
Commit
8e9300e
1 Parent(s): 90634dc

Update RetinaFace.py

Browse files
Files changed (1) hide show
  1. RetinaFace.py +16 -1
RetinaFace.py CHANGED
@@ -36,7 +36,22 @@ def build_model():
36
  return model
37
 
38
  def get_image(img_path):
39
- return img_path
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  def detect_faces(img_path, threshold=0.9, model = None, allow_upscaling = True):
42
  """
 
36
  return model
37
 
38
  def get_image(img_path):
39
+ if type(img_path) == str: # Load from file path
40
+ if not os.path.isfile(img_path):
41
+ raise ValueError("Input image file path (", img_path, ") does not exist.")
42
+ img = cv2.imread(img_path)
43
+
44
+ elif isinstance(img_path, np.ndarray): # Use given NumPy array
45
+ img = img_path.copy()
46
+
47
+ else:
48
+ raise ValueError("Invalid image input. Only file paths or a NumPy array accepted.")
49
+
50
+ # Validate image shape
51
+ if len(img.shape) != 3 or np.prod(img.shape) == 0:
52
+ raise ValueError("Input image needs to have 3 channels at must not be empty.")
53
+
54
+ return img
55
 
56
  def detect_faces(img_path, threshold=0.9, model = None, allow_upscaling = True):
57
  """