Prateek954 commited on
Commit
a5bd6c9
1 Parent(s): d445308

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import streamlit as st
3
  from PIL import Image
4
  import face_recognition
@@ -7,7 +6,8 @@ import numpy as np
7
  import requests
8
  import os
9
 
10
- st.title("PROJECT-1 Face Recognition")
 
11
 
12
  # create list of encoding of all images in photos folder
13
  # Load images for face recognition
@@ -18,7 +18,7 @@ myList = os.listdir(directory)
18
 
19
  st.write("Photographs found in folder : ")
20
  for cls in myList:
21
- if os.path.splitext(cls)[1] in [".jpg", ".jpeg",".jfif"]:
22
  img_path = os.path.join(directory, cls)
23
  curImg = cv2.imread(img_path)
24
  Images.append(curImg)
@@ -30,17 +30,16 @@ encodeListknown = [face_recognition.face_encodings(img)[0] for img in Images]
30
 
31
  # camera to take photo of user in question
32
  file_name = st.camera_input("Take a picture") #st.file_uploader("Upload image ")
33
-
34
- # Function to update Aadhaar data
35
  def update_data(name):
36
- url = "https://albadi-hood-chd.glitch.me/showattendance" #?rollno=222&name="+name
37
- data = {'rollno':'222','name': name}
 
38
  response = requests.post(url , data=data )
39
 
40
  if response.status_code == 200:
41
- st.success("Data updated on: " + url)
42
  else:
43
- st.warning("Data not updated")
44
 
45
  if file_name is not None:
46
  col1, col2 = st.columns(2)
@@ -81,8 +80,10 @@ if file_name is not None:
81
  # update the database
82
  update_data(name)
83
 
 
84
  st.image(image_copy, use_column_width=True, output_format="PNG")
85
  else:
86
  st.warning("No faces detected in the image. Face recognition failed.")
87
 
88
-
 
 
 
1
  import streamlit as st
2
  from PIL import Image
3
  import face_recognition
 
6
  import requests
7
  import os
8
 
9
+
10
+ st.title("Project_1 - Face Recognition")
11
 
12
  # create list of encoding of all images in photos folder
13
  # Load images for face recognition
 
18
 
19
  st.write("Photographs found in folder : ")
20
  for cls in myList:
21
+ if os.path.splitext(cls)[1] in [".jpg", ".jpeg"]:
22
  img_path = os.path.join(directory, cls)
23
  curImg = cv2.imread(img_path)
24
  Images.append(curImg)
 
30
 
31
  # camera to take photo of user in question
32
  file_name = st.camera_input("Take a picture") #st.file_uploader("Upload image ")
 
 
33
  def update_data(name):
34
+
35
+ url = "https://bhagya-attendance-system.glitch.me/adduserdata1" #?rollno=222&name="+name
36
+ data = {'name': name}
37
  response = requests.post(url , data=data )
38
 
39
  if response.status_code == 200:
40
+ st.success("Your attendance is marked.Have a good day!")
41
  else:
42
+ st.warning("Sorry attendance is not marked")
43
 
44
  if file_name is not None:
45
  col1, col2 = st.columns(2)
 
80
  # update the database
81
  update_data(name)
82
 
83
+
84
  st.image(image_copy, use_column_width=True, output_format="PNG")
85
  else:
86
  st.warning("No faces detected in the image. Face recognition failed.")
87
 
88
+ # image = Image.open(file_name)
89
+ # col1.image(image, use_column_width=True)