Spaces:
Build error
Build error
Update app.py
Browse files
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 = '
|
| 15 |
SCOPES = ['https://www.googleapis.com/auth/drive']
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
drive_service = build('drive', 'v3', credentials=credentials)
|
| 18 |
|
| 19 |
# Folder IDs
|
| 20 |
-
aadhar_folder_id = '
|
| 21 |
-
cphotos_folder_id = '
|
| 22 |
-
suspects_folder_id = '
|
| 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():
|