Spaces:
Build error
Build error
LovnishVerma
commited on
Commit
•
ea55b53
1
Parent(s):
231888b
Update app.py
Browse files
app.py
CHANGED
@@ -39,12 +39,35 @@ def validate_aadhaar(aadhaar):
|
|
39 |
# For simplicity, let's assume any 6-digit number is a valid Aadhaar card
|
40 |
return len(aadhaar) == 6 and aadhaar.isdigit()
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
# Take input Aadhaar card details
|
43 |
aadhaar_number = st.text_input("Enter Aadhaar Number:")
|
44 |
|
45 |
# Take picture using the camera
|
46 |
img_file_buffer = st.camera_input("Take a picture")
|
47 |
|
|
|
|
|
48 |
|
49 |
if img_file_buffer is not None:
|
50 |
# Validate Aadhaar card number
|
@@ -76,16 +99,9 @@ if img_file_buffer is not None:
|
|
76 |
cv2.putText(image, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
|
77 |
|
78 |
if name != "Unknown":
|
79 |
-
|
80 |
-
url = "https://attendanceviaface.000webhostapp.com"
|
81 |
-
url1 = "/update.php"
|
82 |
-
data1 = {'name': name, 'aadhaar': aadhaar_number}
|
83 |
-
response = requests.post(url + url1, data=data1)
|
84 |
|
85 |
-
|
86 |
-
st.success("Data updated on: " + url)
|
87 |
-
else:
|
88 |
-
st.warning("Data not updated")
|
89 |
|
90 |
# Display the name corresponding to the entered Aadhaar number
|
91 |
if name == "Unknown":
|
@@ -98,9 +114,5 @@ if img_file_buffer is not None:
|
|
98 |
else:
|
99 |
st.warning("Aadhaar number is valid, but face recognition failed.")
|
100 |
|
101 |
-
# Apply styling with CSS
|
102 |
-
st.markdown('<style>img { animation: pulse 2s infinite; }</style>', unsafe_allow_html=True)
|
103 |
-
st.image(image, use_column_width=True, output_format="PNG")
|
104 |
-
|
105 |
else:
|
106 |
st.error("Invalid Aadhaar card number. Please enter a valid 6-digit Aadhaar number.")
|
|
|
39 |
# For simplicity, let's assume any 6-digit number is a valid Aadhaar card
|
40 |
return len(aadhaar) == 6 and aadhaar.isdigit()
|
41 |
|
42 |
+
# Function to update Aadhaar data
|
43 |
+
def update_data(name, aadhaar_number):
|
44 |
+
url = "https://attendanceviaface.000webhostapp.com"
|
45 |
+
url1 = "/update.php"
|
46 |
+
data = {'name': name, 'aadhaar': aadhaar_number}
|
47 |
+
response = requests.post(url + url1, data=data)
|
48 |
+
|
49 |
+
if response.status_code == 200:
|
50 |
+
st.success("Data updated on: " + url)
|
51 |
+
else:
|
52 |
+
st.warning("Data not updated")
|
53 |
+
|
54 |
+
# Function to display image with overlay
|
55 |
+
def display_image_with_overlay(image, name):
|
56 |
+
# Add overlay to the image (e.g., bounding box and name)
|
57 |
+
# ...
|
58 |
+
|
59 |
+
# Apply styling with CSS
|
60 |
+
st.markdown('<style>img { animation: pulse 2s infinite; }</style>', unsafe_allow_html=True)
|
61 |
+
st.image(image, use_column_width=True, output_format="PNG")
|
62 |
+
|
63 |
# Take input Aadhaar card details
|
64 |
aadhaar_number = st.text_input("Enter Aadhaar Number:")
|
65 |
|
66 |
# Take picture using the camera
|
67 |
img_file_buffer = st.camera_input("Take a picture")
|
68 |
|
69 |
+
# Load images for face recognition
|
70 |
+
encodeListknown = [face_recognition.face_encodings(img)[0] for img in Images]
|
71 |
|
72 |
if img_file_buffer is not None:
|
73 |
# Validate Aadhaar card number
|
|
|
99 |
cv2.putText(image, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
|
100 |
|
101 |
if name != "Unknown":
|
102 |
+
update_data(name, aadhaar_number)
|
|
|
|
|
|
|
|
|
103 |
|
104 |
+
display_image_with_overlay(image, name)
|
|
|
|
|
|
|
105 |
|
106 |
# Display the name corresponding to the entered Aadhaar number
|
107 |
if name == "Unknown":
|
|
|
114 |
else:
|
115 |
st.warning("Aadhaar number is valid, but face recognition failed.")
|
116 |
|
|
|
|
|
|
|
|
|
117 |
else:
|
118 |
st.error("Invalid Aadhaar card number. Please enter a valid 6-digit Aadhaar number.")
|