Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# ------------------ ENV FIRST ------------------
|
| 2 |
import os
|
| 3 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
| 4 |
os.environ["EASYOCR_NO_PROGRESS"] = "1"
|
|
@@ -19,11 +19,7 @@ import logging
|
|
| 19 |
from preprocess import read_image, extract_id_card, save_image
|
| 20 |
from ocr_engine import extract_text
|
| 21 |
from postprocess import extract_information
|
| 22 |
-
from face_verification import
|
| 23 |
-
detect_and_extract_face,
|
| 24 |
-
face_comparison,
|
| 25 |
-
get_face_embeddings,
|
| 26 |
-
)
|
| 27 |
from db import init_db, insert_record, check_duplicate
|
| 28 |
|
| 29 |
# ------------------ SETUP ------------------
|
|
@@ -65,12 +61,7 @@ if id_image and face_image:
|
|
| 65 |
"data/intermediate"
|
| 66 |
)
|
| 67 |
|
| 68 |
-
|
| 69 |
-
uploaded_face_path,
|
| 70 |
-
id_face_path
|
| 71 |
-
)
|
| 72 |
-
|
| 73 |
-
if not verified:
|
| 74 |
st.error("❌ Face verification failed")
|
| 75 |
st.stop()
|
| 76 |
|
|
@@ -78,7 +69,7 @@ if id_image and face_image:
|
|
| 78 |
info = extract_information(extracted_text)
|
| 79 |
|
| 80 |
if check_duplicate(info["ID"]):
|
| 81 |
-
st.warning("⚠ User already exists
|
| 82 |
else:
|
| 83 |
info["DOB"] = info["DOB"].strftime("%Y-%m-%d")
|
| 84 |
info["Embedding"] = get_face_embeddings(uploaded_face_path)
|
|
|
|
| 1 |
+
# ------------------ ENV FIRST (MUST BE FIRST) ------------------
|
| 2 |
import os
|
| 3 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
| 4 |
os.environ["EASYOCR_NO_PROGRESS"] = "1"
|
|
|
|
| 19 |
from preprocess import read_image, extract_id_card, save_image
|
| 20 |
from ocr_engine import extract_text
|
| 21 |
from postprocess import extract_information
|
| 22 |
+
from face_verification import detect_and_extract_face, face_comparison, get_face_embeddings
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
from db import init_db, insert_record, check_duplicate
|
| 24 |
|
| 25 |
# ------------------ SETUP ------------------
|
|
|
|
| 61 |
"data/intermediate"
|
| 62 |
)
|
| 63 |
|
| 64 |
+
if not face_comparison(uploaded_face_path, id_face_path):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
st.error("❌ Face verification failed")
|
| 66 |
st.stop()
|
| 67 |
|
|
|
|
| 69 |
info = extract_information(extracted_text)
|
| 70 |
|
| 71 |
if check_duplicate(info["ID"]):
|
| 72 |
+
st.warning("⚠ User already exists")
|
| 73 |
else:
|
| 74 |
info["DOB"] = info["DOB"].strftime("%Y-%m-%d")
|
| 75 |
info["Embedding"] = get_face_embeddings(uploaded_face_path)
|