Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -193,32 +193,56 @@ prod_dl = DataLoader(prod_ds, batch_size=BATCH_SIZE)
|
|
193 |
#prod_inputs = next(iter(prod_dl))
|
194 |
#st.write(prod_inputs['pixel_values'].shape)
|
195 |
|
196 |
-
|
197 |
-
|
198 |
-
picture = st.camera_input("Take a picture", disabled=not enable)
|
199 |
-
if picture is not None:
|
200 |
-
#img = Image.open(picture)
|
201 |
-
#picture.save(webcam_path, "JPEG")
|
202 |
-
#st.write('Image saved as:',webcam_path)
|
203 |
-
|
204 |
-
## Create DataLoader for Webcam Image
|
205 |
-
webcam_ds = dataset_prod_obj.create_dataset(picture, webcam=True)
|
206 |
-
webcam_dl = DataLoader(webcam_ds, batch_size=BATCH_SIZE)
|
207 |
-
|
208 |
-
## Testing the dataloader
|
209 |
-
#prod_inputs = next(iter(webcam_dl))
|
210 |
-
#st.write(prod_inputs['pixel_values'].shape)
|
211 |
-
|
212 |
-
with st.spinner("Wait for it...", show_time=True):
|
213 |
-
# Run the predictions
|
214 |
-
prediction = prod_function(model_pretrained, prod_dl, webcam_dl)
|
215 |
-
predictions = torch.cat(prediction, 0).to(device)
|
216 |
-
match_idx = torch.argmin(predictions)
|
217 |
-
st.write(predictions)
|
218 |
-
st.write(image_paths)
|
219 |
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
#prod_inputs = next(iter(prod_dl))
|
194 |
#st.write(prod_inputs['pixel_values'].shape)
|
195 |
|
196 |
+
with gr.Blocks(css=custom_css) as demo:
|
197 |
+
gr.Markdown("# AI Face Recognition app for automated employee attendance")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
+
# About the app Tab
|
200 |
+
with gr.Tab("About the app"):
|
201 |
+
gr.Markdown(
|
202 |
+
"""
|
203 |
+
## Product Description/Objective
|
204 |
+
An AI face recognition app for automated employee attendance uses advanced facial recognition technology to accurately and efficiently track employee attendance.
|
205 |
+
By simply scanning employees' faces upon arrival and departure, the app eliminates the need for traditional timecards or biometric devices, reducing errors and fraud.
|
206 |
+
It provides real-time attendance data, enhances workplace security, and streamlines HR processes for greater productivity and accuracy.
|
207 |
+
|
208 |
+
## How does it work ?
|
209 |
+
Our app leverages Google's advanced **Vision Transformer (ViT)** architecture, trained on the **LFW (Labeled Faces in the Wild) dataset**, to deliver highly accurate employee attendance tracking through facial recognition.
|
210 |
+
The AI model intelligently extracts distinct facial features and compares them to the stored data of registered employees. When an employee’s face is scanned, the model analyzes the key features, and a confidence score is generated.
|
211 |
+
A high score indicates a match, confirming the employee’s identity and marking their attendance automatically. This seamless, secure process ensures precise tracking while minimizing errors and enhancing workplace efficiency.
|
212 |
+
|
213 |
+
## About the architecture.
|
214 |
+
|
215 |
+
## About the Dataset the app is trained on
|
216 |
+
""")
|
217 |
+
|
218 |
+
# Gesture recognition Tab
|
219 |
+
with gr.Tab("About the app"):
|
220 |
+
# Read image from Camera
|
221 |
+
enable = st.checkbox("Enable camera")
|
222 |
+
picture = st.camera_input("Take a picture", disabled=not enable)
|
223 |
+
if picture is not None:
|
224 |
+
#img = Image.open(picture)
|
225 |
+
#picture.save(webcam_path, "JPEG")
|
226 |
+
#st.write('Image saved as:',webcam_path)
|
227 |
+
|
228 |
+
## Create DataLoader for Webcam Image
|
229 |
+
webcam_ds = dataset_prod_obj.create_dataset(picture, webcam=True)
|
230 |
+
webcam_dl = DataLoader(webcam_ds, batch_size=BATCH_SIZE)
|
231 |
+
|
232 |
+
## Testing the dataloader
|
233 |
+
#prod_inputs = next(iter(webcam_dl))
|
234 |
+
#st.write(prod_inputs['pixel_values'].shape)
|
235 |
+
|
236 |
+
with st.spinner("Wait for it...", show_time=True):
|
237 |
+
# Run the predictions
|
238 |
+
prediction = prod_function(model_pretrained, prod_dl, webcam_dl)
|
239 |
+
predictions = torch.cat(prediction, 0).to(device)
|
240 |
+
match_idx = torch.argmin(predictions)
|
241 |
+
st.write(predictions)
|
242 |
+
st.write(image_paths)
|
243 |
+
|
244 |
+
# Display the results
|
245 |
+
if predictions[match_idx] <= 0.3:
|
246 |
+
st.write('Welcome: ',image_paths[match_idx].split('/')[-1].split('.')[0])
|
247 |
+
else:
|
248 |
+
st.write("Match not found")
|