Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,6 @@
|
|
1 |
import requests
|
2 |
import pyrebase
|
3 |
import urllib
|
4 |
-
from PIL import Image
|
5 |
-
from io import BytesIO
|
6 |
from retinaface import RetinaFace
|
7 |
from deepface import DeepFace
|
8 |
from fastapi import FastAPI
|
@@ -30,33 +28,26 @@ def verify_image(url1):
|
|
30 |
path = "Faces/"
|
31 |
files = storage.bucket.list_blobs(prefix=path)
|
32 |
flag = False
|
33 |
-
|
34 |
-
|
35 |
for file in files:
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
if flag:
|
59 |
-
return {"username": username}
|
60 |
-
else:
|
61 |
-
print("Not Verified")
|
62 |
-
return {"username": "Not Found"}
|
|
|
1 |
import requests
|
2 |
import pyrebase
|
3 |
import urllib
|
|
|
|
|
4 |
from retinaface import RetinaFace
|
5 |
from deepface import DeepFace
|
6 |
from fastapi import FastAPI
|
|
|
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") or file.name.endswith(".jpeg")) :
|
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 |
+
|
47 |
+
|
48 |
+
if flag == False:
|
49 |
+
print("Not Verified")
|
50 |
+
return {"username": "Not Found"}
|
51 |
+
|
52 |
+
|
53 |
+
|
|
|
|
|
|
|
|
|
|
|
|