Update app.py
Browse files
app.py
CHANGED
|
@@ -26,7 +26,7 @@ DB_FILE = "face_db.pkl"
|
|
| 26 |
|
| 27 |
@st.cache_resource
|
| 28 |
def load_ai_engine():
|
| 29 |
-
# Đọc mô hình trực tiếp từ thư mục models đã upload
|
| 30 |
app = FaceAnalysis(name='buffalo_sc', root='./models', providers=['CPUExecutionProvider'])
|
| 31 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
| 32 |
return app
|
|
@@ -87,23 +87,22 @@ tab1, tab2, tab3 = st.tabs(["Quét Điểm Danh", "Đăng Ký Sinh Viên", "Dữ
|
|
| 87 |
with tab1:
|
| 88 |
c1, c2 = st.columns([7, 3])
|
| 89 |
with c1:
|
| 90 |
-
#
|
| 91 |
ctx = webrtc_streamer(
|
| 92 |
key="multi-face-scanner",
|
| 93 |
video_processor_factory=MultiFaceProcessor,
|
| 94 |
rtc_configuration={
|
| 95 |
"iceServers": [
|
| 96 |
{"urls": ["stun:stun.l.google.com:19302"]},
|
| 97 |
-
{
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
| 100 |
]
|
| 101 |
},
|
| 102 |
media_stream_constraints={
|
| 103 |
-
"video": {
|
| 104 |
-
"width": {"ideal": 640},
|
| 105 |
-
"height": {"ideal": 480}
|
| 106 |
-
},
|
| 107 |
"audio": False
|
| 108 |
},
|
| 109 |
)
|
|
@@ -113,7 +112,6 @@ with tab1:
|
|
| 113 |
|
| 114 |
with c2:
|
| 115 |
st.subheader("Danh sách điểm danh")
|
| 116 |
-
|
| 117 |
st.button("🔄 LÀM MỚI DANH SÁCH")
|
| 118 |
|
| 119 |
db = get_face_db()
|
|
@@ -150,18 +148,11 @@ with tab2:
|
|
| 150 |
with open(DB_FILE, 'wb') as f: pickle.dump(db, f)
|
| 151 |
st.success(f"Đã cập nhật: {name}")
|
| 152 |
st.rerun()
|
| 153 |
-
elif len(res) == 0:
|
| 154 |
-
st.error("Không tìm thấy khuôn mặt!")
|
| 155 |
else:
|
| 156 |
-
st.error("
|
| 157 |
|
| 158 |
with tab3:
|
| 159 |
st.subheader("Quản trị hệ thống")
|
| 160 |
if st.button("XÓA DANH SÁCH ĐIỂM DANH"):
|
| 161 |
st.session_state.live_attendance = {}
|
| 162 |
-
|
| 163 |
-
st.success("Đã reset!"); st.rerun()
|
| 164 |
-
|
| 165 |
-
if st.button("XÓA TOÀN BỘ DATABASE", type="primary"):
|
| 166 |
-
if os.path.exists(DB_FILE): os.remove(DB_FILE)
|
| 167 |
-
st.session_state.clear(); st.rerun()
|
|
|
|
| 26 |
|
| 27 |
@st.cache_resource
|
| 28 |
def load_ai_engine():
|
| 29 |
+
# Đọc mô hình trực tiếp từ thư mục models đã upload
|
| 30 |
app = FaceAnalysis(name='buffalo_sc', root='./models', providers=['CPUExecutionProvider'])
|
| 31 |
app.prepare(ctx_id=0, det_size=(640, 640))
|
| 32 |
return app
|
|
|
|
| 87 |
with tab1:
|
| 88 |
c1, c2 = st.columns([7, 3])
|
| 89 |
with c1:
|
| 90 |
+
# Cấu hình TURN Server đục tường lửa từ tài khoản Metered của bạn
|
| 91 |
ctx = webrtc_streamer(
|
| 92 |
key="multi-face-scanner",
|
| 93 |
video_processor_factory=MultiFaceProcessor,
|
| 94 |
rtc_configuration={
|
| 95 |
"iceServers": [
|
| 96 |
{"urls": ["stun:stun.l.google.com:19302"]},
|
| 97 |
+
{
|
| 98 |
+
"urls": ["turn:vovansy-turn.metered.live:80", "turn:vovansy-turn.metered.live:443"],
|
| 99 |
+
"username": "662b60daad0aa933efe44472",
|
| 100 |
+
"credential": "FA4w+gPK7n7yCVAP"
|
| 101 |
+
}
|
| 102 |
]
|
| 103 |
},
|
| 104 |
media_stream_constraints={
|
| 105 |
+
"video": {"width": {"ideal": 640}, "height": {"ideal": 480}},
|
|
|
|
|
|
|
|
|
|
| 106 |
"audio": False
|
| 107 |
},
|
| 108 |
)
|
|
|
|
| 112 |
|
| 113 |
with c2:
|
| 114 |
st.subheader("Danh sách điểm danh")
|
|
|
|
| 115 |
st.button("🔄 LÀM MỚI DANH SÁCH")
|
| 116 |
|
| 117 |
db = get_face_db()
|
|
|
|
| 148 |
with open(DB_FILE, 'wb') as f: pickle.dump(db, f)
|
| 149 |
st.success(f"Đã cập nhật: {name}")
|
| 150 |
st.rerun()
|
|
|
|
|
|
|
| 151 |
else:
|
| 152 |
+
st.error("Vui lòng chỉ để 1 khuôn mặt trong khung hình.")
|
| 153 |
|
| 154 |
with tab3:
|
| 155 |
st.subheader("Quản trị hệ thống")
|
| 156 |
if st.button("XÓA DANH SÁCH ĐIỂM DANH"):
|
| 157 |
st.session_state.live_attendance = {}
|
| 158 |
+
st.success("Đã reset!"); st.rerun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|