ravinder2024 commited on
Commit
0095c47
·
verified ·
1 Parent(s): 5c559f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -1
app.py CHANGED
@@ -6,6 +6,7 @@ import pandas as pd
6
  from PIL import Image
7
  import io
8
 
 
9
  def create_database():
10
  """Creates the attendance database."""
11
  conn = sqlite3.connect('attendance.db')
@@ -59,7 +60,7 @@ def capture_photo():
59
  create_database()
60
  st.title("Attendance System")
61
 
62
- menu = st.sidebar.selectbox("Menu", ["Click Photo", "Database"])
63
 
64
  if menu == "Click Photo":
65
  st.header("Mark Attendance by Clicking Photo")
@@ -76,3 +77,31 @@ elif menu == "Database":
76
  records = get_attendance_records()
77
  df = pd.DataFrame(records, columns=["ID", "Name", "Timestamp"])
78
  st.dataframe(df)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  from PIL import Image
7
  import io
8
 
9
+
10
  def create_database():
11
  """Creates the attendance database."""
12
  conn = sqlite3.connect('attendance.db')
 
60
  create_database()
61
  st.title("Attendance System")
62
 
63
+ #upload_choice = st.sidebar.selectbox("Menu", ["Click Photo", "Database"])
64
 
65
  if menu == "Click Photo":
66
  st.header("Mark Attendance by Clicking Photo")
 
77
  records = get_attendance_records()
78
  df = pd.DataFrame(records, columns=["ID", "Name", "Timestamp"])
79
  st.dataframe(df)
80
+
81
+ # Sidebar for input source
82
+ upload_choice = st.sidebar.radio("Choose Input Source", ["Upload Image", "Upload Video", "Camera"])
83
+
84
+ if upload_choice == "Camera":
85
+ image = st.camera_input("Take a picture")
86
+ if image:
87
+ frame = np.array(Image.open(image))
88
+ frame, result_text = process_frame(frame)
89
+ st.image(frame, caption='Processed Image', use_column_width=True)
90
+ st.markdown(f"<h3 style='text-align: center;'>{result_text}</h3>", unsafe_allow_html=True)
91
+
92
+ elif upload_choice == "Upload Image":
93
+ uploaded_image = st.file_uploader("Upload Image", type=["png", "jpg", "jpeg"])
94
+ if uploaded_image:
95
+ image = Image.open(uploaded_image)
96
+ frame = np.array(image)
97
+ frame, result_text = process_frame(frame)
98
+ st.image(frame, caption='Processed Image', use_column_width=True)
99
+ st.markdown(f"<h3 style='text-align: center;'>{result_text}</h3>", unsafe_allow_html=True)
100
+
101
+ elif upload_choice == "Upload Video":
102
+ uploaded_video = st.file_uploader("Upload Video", type=["mp4", "mov", "avi"])
103
+ if uploaded_video:
104
+ with tempfile.NamedTemporaryFile(delete=False) as tfile:
105
+ tfile.write(uploaded_video.read())
106
+ video_source = cv2.VideoCapture(tfile.name)
107
+ video_feed(video_source)