Kaushik066 commited on
Commit
89b1493
·
verified ·
1 Parent(s): e6bd663

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -30
app.py CHANGED
@@ -194,8 +194,9 @@ prod_dl = DataLoader(prod_ds, batch_size=BATCH_SIZE)
194
  #st.write(prod_inputs['pixel_values'].shape)
195
 
196
 
197
- #st.markdown("# AI Face Recognition app for automated employee attendance")
198
  #about_tab, app_tab = st.tabs(["About the app", "Face Recognition"])
 
199
  ## About the app Tab
200
  #with about_tab:
201
  # st.markdown(
@@ -223,33 +224,33 @@ prod_dl = DataLoader(prod_ds, batch_size=BATCH_SIZE)
223
  # """)
224
 
225
  # Gesture recognition Tab
226
- #with app_tab:
227
- # Read image from Camera
228
- enable = st.checkbox("Enable camera")
229
- picture = st.camera_input("Take a picture", disabled=not enable)
230
- if picture is not None:
231
- #img = Image.open(picture)
232
- #picture.save(webcam_path, "JPEG")
233
- #st.write('Image saved as:',webcam_path)
234
-
235
- ## Create DataLoader for Webcam Image
236
- webcam_ds = dataset_prod_obj.create_dataset(picture, webcam=True)
237
- webcam_dl = DataLoader(webcam_ds, batch_size=BATCH_SIZE)
238
-
239
- ## Testing the dataloader
240
- #prod_inputs = next(iter(webcam_dl))
241
- #st.write(prod_inputs['pixel_values'].shape)
242
-
243
- with st.spinner("Wait for it...", show_time=True):
244
- # Run the predictions
245
- prediction = prod_function(model_pretrained, prod_dl, webcam_dl)
246
- predictions = torch.cat(prediction, 0).to(device)
247
- match_idx = torch.argmin(predictions)
248
- st.write(predictions)
249
- st.write(image_paths)
250
 
251
- # Display the results
252
- if predictions[match_idx] <= 0.3:
253
- st.write('Welcome: ',image_paths[match_idx].split('/')[-1].split('.')[0])
254
- else:
255
- st.write("Match not found")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  #st.write(prod_inputs['pixel_values'].shape)
195
 
196
 
197
+ st.markdown("# AI Face Recognition app for automated employee attendance")
198
  #about_tab, app_tab = st.tabs(["About the app", "Face Recognition"])
199
+ app_tab = st.tabs(["Face Recognition"])
200
  ## About the app Tab
201
  #with about_tab:
202
  # st.markdown(
 
224
  # """)
225
 
226
  # Gesture recognition Tab
227
+ with app_tab:
228
+ # Read image from Camera
229
+ enable = st.checkbox("Enable camera")
230
+ picture = st.camera_input("Take a picture", disabled=not enable)
231
+ if picture is not None:
232
+ #img = Image.open(picture)
233
+ #picture.save(webcam_path, "JPEG")
234
+ #st.write('Image saved as:',webcam_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
 
236
+ ## Create DataLoader for Webcam Image
237
+ webcam_ds = dataset_prod_obj.create_dataset(picture, webcam=True)
238
+ webcam_dl = DataLoader(webcam_ds, batch_size=BATCH_SIZE)
239
+
240
+ ## Testing the dataloader
241
+ #prod_inputs = next(iter(webcam_dl))
242
+ #st.write(prod_inputs['pixel_values'].shape)
243
+
244
+ with st.spinner("Wait for it...", show_time=True):
245
+ # Run the predictions
246
+ prediction = prod_function(model_pretrained, prod_dl, webcam_dl)
247
+ predictions = torch.cat(prediction, 0).to(device)
248
+ match_idx = torch.argmin(predictions)
249
+ st.write(predictions)
250
+ st.write(image_paths)
251
+
252
+ # Display the results
253
+ if predictions[match_idx] <= 0.3:
254
+ st.write('Welcome: ',image_paths[match_idx].split('/')[-1].split('.')[0])
255
+ else:
256
+ st.write("Match not found")