Upload 5 files
Browse files- .gitignore +6 -0
- FaceRecognition.json +22 -0
- app.py +53 -0
- pyvenv.cfg +6 -0
- requirements.txt +11 -0
.gitignore
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# created by virtualenv automatically
|
| 2 |
+
# Ignore Python virtual environment
|
| 3 |
+
venv/
|
| 4 |
+
# Ignore the lib directory
|
| 5 |
+
Lib/
|
| 6 |
+
|
FaceRecognition.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"info": {
|
| 3 |
+
"name": "FastAPI API",
|
| 4 |
+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
| 5 |
+
},
|
| 6 |
+
"item": [
|
| 7 |
+
{
|
| 8 |
+
"name": "read_root",
|
| 9 |
+
"request": {
|
| 10 |
+
"url": "http://localhost:8000/",
|
| 11 |
+
"method": "GET"
|
| 12 |
+
}
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"name": "verify_image",
|
| 16 |
+
"request": {
|
| 17 |
+
"url": "http://localhost:8000/verify/",
|
| 18 |
+
"method": "GET"
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
]
|
| 22 |
+
}
|
app.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import pyrebase
|
| 3 |
+
import urllib
|
| 4 |
+
from retinaface import RetinaFace
|
| 5 |
+
from deepface import DeepFace
|
| 6 |
+
from fastapi import FastAPI
|
| 7 |
+
|
| 8 |
+
app = FastAPI()
|
| 9 |
+
|
| 10 |
+
@app.get("/")
|
| 11 |
+
def read_root():
|
| 12 |
+
return {"Hello": "World"}
|
| 13 |
+
|
| 14 |
+
@app.get("/verify/")
|
| 15 |
+
def verify_image(url1):
|
| 16 |
+
firebaseConfig = {
|
| 17 |
+
"apiKey": "AIzaSyClnRJAnrJgAgkYjuYnlvu-CJ6Cxyklebo",
|
| 18 |
+
"authDomain": "socioverse-2025.firebaseapp.com",
|
| 19 |
+
"projectId": "socioverse-2025",
|
| 20 |
+
"storageBucket": "socioverse-2025.appspot.com",
|
| 21 |
+
"messagingSenderId": "689574504641",
|
| 22 |
+
"appId": "1:689574504641:web:a22f6a2fa343e4221acc40",
|
| 23 |
+
"databaseURL": "https://console.firebase.google.com/project/socioverse-2025/storage/socioverse-2025.appspot.com/files",
|
| 24 |
+
"serviceAccount":"Firebase_Service_Account_Keys.json"
|
| 25 |
+
};
|
| 26 |
+
firebase = pyrebase.initialize_app(firebaseConfig)
|
| 27 |
+
storage = firebase.storage()
|
| 28 |
+
path = "Faces/"
|
| 29 |
+
files = storage.bucket.list_blobs(prefix=path)
|
| 30 |
+
flag = False
|
| 31 |
+
# url1 = "https://api.time.com/wp-content/uploads/2023/04/shah-rukh-khan-time100-2023-1.jpg"
|
| 32 |
+
for file in files:
|
| 33 |
+
if file.name.endswith(".jpg"):
|
| 34 |
+
# print(file.name)
|
| 35 |
+
url = storage.child(f"{file.name}").get_url(None)
|
| 36 |
+
# print(url)
|
| 37 |
+
with requests.get(url) as response:
|
| 38 |
+
result = DeepFace.verify(f"{url1}",url, model_name="Facenet", distance_metric='cosine')
|
| 39 |
+
if result['verified']:
|
| 40 |
+
flag = True
|
| 41 |
+
start_index = file.name.rfind('/')
|
| 42 |
+
end_index = file.name.rfind('$')
|
| 43 |
+
if start_index != -1 and end_index != -1:
|
| 44 |
+
name = file.name[start_index + 1:end_index]
|
| 45 |
+
return {"username": name}
|
| 46 |
+
break
|
| 47 |
+
|
| 48 |
+
if flag == False:
|
| 49 |
+
print("Not Verified")
|
| 50 |
+
return {"username": "Not Found"}
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
|
pyvenv.cfg
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
home = C:\Users\Jainam\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0
|
| 2 |
+
implementation = CPython
|
| 3 |
+
version_info = 3.10.11.final.0
|
| 4 |
+
virtualenv = 20.13.0
|
| 5 |
+
include-system-site-packages = false
|
| 6 |
+
version = 3.10.11
|
requirements.txt
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Pyrebase4==4.7.1
|
| 2 |
+
requests==2.23.0
|
| 3 |
+
opencv-python==4.8.1.78
|
| 4 |
+
urllib3==1.25.11
|
| 5 |
+
uvicorn==0.23.2
|
| 6 |
+
deepface==0.0.79
|
| 7 |
+
fastapi==0.104.0
|
| 8 |
+
python-dateutil==2.8.2
|
| 9 |
+
python-jwt==4.0.0
|
| 10 |
+
pydantic==2.4.2
|
| 11 |
+
pydantic_core==2.10.1
|