BasitAliii commited on
Commit
02d08c9
·
verified ·
1 Parent(s): 57618ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -21,6 +21,8 @@ except ImportError as e:
21
  class FaceRecognitionSystem:
22
  def __init__(self):
23
  self.setup_database()
 
 
24
  if FACE_NET_AVAILABLE:
25
  try:
26
  self.mtcnn = MTCNN(keep_all=True, device='cpu')
@@ -28,7 +30,6 @@ class FaceRecognitionSystem:
28
  print("✅ FaceNet models loaded successfully")
29
  except Exception as e:
30
  print(f"❌ Error loading FaceNet models: {e}")
31
- global FACE_NET_AVAILABLE
32
  FACE_NET_AVAILABLE = False
33
 
34
  def setup_database(self):
@@ -66,6 +67,8 @@ class FaceRecognitionSystem:
66
  """
67
  Extract face embedding from image using FaceNet
68
  """
 
 
69
  if not FACE_NET_AVAILABLE:
70
  return None, "Face recognition not available"
71
 
@@ -129,6 +132,8 @@ class FaceRecognitionSystem:
129
  """
130
  Recognize face from image and mark attendance
131
  """
 
 
132
  if not FACE_NET_AVAILABLE:
133
  return image, "Face recognition not available"
134
 
 
21
  class FaceRecognitionSystem:
22
  def __init__(self):
23
  self.setup_database()
24
+ global FACE_NET_AVAILABLE # Declare global at the start of method
25
+
26
  if FACE_NET_AVAILABLE:
27
  try:
28
  self.mtcnn = MTCNN(keep_all=True, device='cpu')
 
30
  print("✅ FaceNet models loaded successfully")
31
  except Exception as e:
32
  print(f"❌ Error loading FaceNet models: {e}")
 
33
  FACE_NET_AVAILABLE = False
34
 
35
  def setup_database(self):
 
67
  """
68
  Extract face embedding from image using FaceNet
69
  """
70
+ global FACE_NET_AVAILABLE
71
+
72
  if not FACE_NET_AVAILABLE:
73
  return None, "Face recognition not available"
74
 
 
132
  """
133
  Recognize face from image and mark attendance
134
  """
135
+ global FACE_NET_AVAILABLE
136
+
137
  if not FACE_NET_AVAILABLE:
138
  return image, "Face recognition not available"
139