Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,8 +6,6 @@ import numpy as np
|
|
| 6 |
import os
|
| 7 |
import sqlite3
|
| 8 |
from datetime import datetime
|
| 9 |
-
from huggingface_hub import Repository
|
| 10 |
-
import pandas as pd
|
| 11 |
|
| 12 |
# Establish connection to SQLite database
|
| 13 |
conn = sqlite3.connect('attendance.db')
|
|
@@ -46,43 +44,6 @@ def add_attendance(name):
|
|
| 46 |
c.execute("INSERT INTO attendance (name, time) VALUES (?, ?)", (username, current_datetime))
|
| 47 |
conn.commit()
|
| 48 |
|
| 49 |
-
def addAttendance(name):
|
| 50 |
-
directory_name = "my_directory"
|
| 51 |
-
|
| 52 |
-
# Check if the repository exists, if not, create it
|
| 53 |
-
if not hf_repo_exists(directory_name):
|
| 54 |
-
hf_repo_create(directory_name)
|
| 55 |
-
print(f"Repository '{directory_name}' created successfully!")
|
| 56 |
-
else:
|
| 57 |
-
repo = Repository()
|
| 58 |
-
|
| 59 |
-
# Create the directory
|
| 60 |
-
repo.create_directory(directory_name)
|
| 61 |
-
|
| 62 |
-
# Define recognized results (example)
|
| 63 |
-
recognized_results = [
|
| 64 |
-
{"Name": "{name}", "Status": "Present"},
|
| 65 |
-
{"Name": "Alice", "Status": "Absent"},
|
| 66 |
-
{"Name": "Bob", "Status": "Present"}
|
| 67 |
-
]
|
| 68 |
-
|
| 69 |
-
# Convert recognized results to DataFrame
|
| 70 |
-
df = pd.DataFrame(recognized_results)
|
| 71 |
-
|
| 72 |
-
# Define the path to save the Excel file
|
| 73 |
-
excel_file_path = "recognized_results.xlsx"
|
| 74 |
-
|
| 75 |
-
# Save DataFrame to Excel file
|
| 76 |
-
df.to_excel(excel_file_path, index=False)
|
| 77 |
-
|
| 78 |
-
# Define the destination path within the directory
|
| 79 |
-
destination_path = os.path.join(directory_name, excel_file_path)
|
| 80 |
-
|
| 81 |
-
# Move the Excel file to the destination path
|
| 82 |
-
os.system(f"mv {excel_file_path} {destination_path}")
|
| 83 |
-
|
| 84 |
-
print(f"Excel file '{excel_file_path}' added to directory '{directory_name}' successfully!")
|
| 85 |
-
|
| 86 |
if file_name is not None:
|
| 87 |
col1, col2 = st.columns(2)
|
| 88 |
|
|
@@ -123,7 +84,7 @@ if file_name is not None:
|
|
| 123 |
cv2.putText(image, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
|
| 124 |
|
| 125 |
# Store attendance in SQLite database
|
| 126 |
-
|
| 127 |
|
| 128 |
# Display the image with recognized faces
|
| 129 |
st.image(image, use_column_width=True, output_format="PNG")
|
|
@@ -134,4 +95,3 @@ if file_name is not None:
|
|
| 134 |
st.write(f"Face {i+1}: {name}")
|
| 135 |
else:
|
| 136 |
st.warning("No faces detected in the image. Face recognition failed.")
|
| 137 |
-
|
|
|
|
| 6 |
import os
|
| 7 |
import sqlite3
|
| 8 |
from datetime import datetime
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Establish connection to SQLite database
|
| 11 |
conn = sqlite3.connect('attendance.db')
|
|
|
|
| 44 |
c.execute("INSERT INTO attendance (name, time) VALUES (?, ?)", (username, current_datetime))
|
| 45 |
conn.commit()
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
if file_name is not None:
|
| 48 |
col1, col2 = st.columns(2)
|
| 49 |
|
|
|
|
| 84 |
cv2.putText(image, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
|
| 85 |
|
| 86 |
# Store attendance in SQLite database
|
| 87 |
+
add_attendance(name)
|
| 88 |
|
| 89 |
# Display the image with recognized faces
|
| 90 |
st.image(image, use_column_width=True, output_format="PNG")
|
|
|
|
| 95 |
st.write(f"Face {i+1}: {name}")
|
| 96 |
else:
|
| 97 |
st.warning("No faces detected in the image. Face recognition failed.")
|
|
|