Ajay98 commited on
Commit
ca4d11e
·
verified ·
1 Parent(s): 63c3f4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -9,17 +9,23 @@ import torch
9
  import numpy as np
10
  from PIL import Image
11
  from facenet_pytorch import MTCNN, InceptionResnetV1
 
12
 
13
  # Load Google Drive API credentials from the uploaded JSON file
14
- SERVICE_ACCOUNT_FILE = './salesforce-api-439514-d6b432a2e20e.json' # Assuming the JSON file is in the root directory
15
  SCOPES = ['https://www.googleapis.com/auth/drive']
16
- credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES)
 
 
 
 
 
17
  drive_service = build('drive', 'v3', credentials=credentials)
18
 
19
  # Folder IDs
20
- aadhar_folder_id = '1jXklVbxTni1gnduuKgJ7zI6zVks6s0LP'
21
- cphotos_folder_id = '1JVJMtHuIHxZyxAekT6ZQFkEWePOimIlX'
22
- suspects_folder_id = '1LJE5aw_g5Jvqd5cLZ7UiJ8LyR36JkBKP'
23
 
24
  # Initialize MTCNN for face detection and InceptionResnetV1 for face recognition
25
  mtcnn = MTCNN(image_size=160, margin=0, min_face_size=20)
@@ -141,7 +147,7 @@ def process_images(aadhar_folder_id, cphotos_folder_id, suspects_folder_id):
141
  if not matched:
142
  upload_file(file_path, suspects_folder_id)
143
  print(f"Unmatched image uploaded: {file['name']}")
144
-
145
  print("Processing of images completed.")
146
 
147
  def main():
 
9
  import numpy as np
10
  from PIL import Image
11
  from facenet_pytorch import MTCNN, InceptionResnetV1
12
+ import json
13
 
14
  # Load Google Drive API credentials from the uploaded JSON file
15
+ SERVICE_ACCOUNT_FILE = './.env' # Assuming the uploaded JSON file is named '.env'
16
  SCOPES = ['https://www.googleapis.com/auth/drive']
17
+
18
+ # Load credentials from the JSON file
19
+ with open(SERVICE_ACCOUNT_FILE, 'r') as json_file:
20
+ credentials_info = json.load(json_file)
21
+
22
+ credentials = service_account.Credentials.from_service_account_info(credentials_info, scopes=SCOPES)
23
  drive_service = build('drive', 'v3', credentials=credentials)
24
 
25
  # Folder IDs
26
+ aadhar_folder_id = '1Qtb5DYzSFE67Mbb5ZgDIqWUtdJaDD2F4'
27
+ cphotos_folder_id = '1DGeRqRbCPcfLDdEgP0h5fyX-MF8EQ8AH'
28
+ suspects_folder_id = '1N3RMhVD0OygeufLPYod6IYLtqzvlm3Jv'
29
 
30
  # Initialize MTCNN for face detection and InceptionResnetV1 for face recognition
31
  mtcnn = MTCNN(image_size=160, margin=0, min_face_size=20)
 
147
  if not matched:
148
  upload_file(file_path, suspects_folder_id)
149
  print(f"Unmatched image uploaded: {file['name']}")
150
+
151
  print("Processing of images completed.")
152
 
153
  def main():