pranav-5644
commited on
Commit
•
33e3fdb
1
Parent(s):
4a49b01
removed the cv windows
Browse files- Attendance.txt +6 -0
- __pycache__/processing.cpython-311.pyc +0 -0
- app.py +6 -9
- attendance_folder/face_136_92.jpg +0 -0
- attendance_folder/face_246_141.jpg +0 -0
- attendance_folder/face_378_25.jpg +0 -0
- attendance_folder/face_382_183.jpg +0 -0
- attendance_folder/face_551_110.jpg +0 -0
- attendance_folder/face_674_188.jpg +0 -0
- class_attendance.jpg +0 -0
- embeddings.pkl +2 -2
- image_detected.jpg +0 -0
- image_grid.jpg +0 -0
- processing.py +8 -8
Attendance.txt
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ross
|
2 |
+
phoebe
|
3 |
+
chandler
|
4 |
+
rachel
|
5 |
+
joe
|
6 |
+
monica
|
__pycache__/processing.cpython-311.pyc
ADDED
Binary file (9.44 kB). View file
|
|
app.py
CHANGED
@@ -2,15 +2,12 @@ import gradio as gr
|
|
2 |
from PIL import Image
|
3 |
from processing import process_image, generate_embeddings , recognize_faces
|
4 |
|
5 |
-
def driver(image,zip_file
|
6 |
image.save('class_attendance.jpg')
|
7 |
fig = process_image('class_attendance.jpg')
|
8 |
generate_embeddings(zip_file)
|
9 |
-
recognize_faces("embeddings.pkl"
|
10 |
-
file_name =
|
11 |
-
|
12 |
-
with open(file_name, 'r') as file:
|
13 |
-
content = file.read()
|
14 |
image_detected = Image.open('image_detected.jpg')
|
15 |
image_grid = Image.open('image_grid.jpg')
|
16 |
return file_name,image_detected,image_grid
|
@@ -22,11 +19,11 @@ with open("description.md", "r") as file:
|
|
22 |
|
23 |
demo = gr.Interface(
|
24 |
fn=driver,
|
25 |
-
inputs=[gr.Image(label="Upload the image of group/class",type="pil"),gr.File(label="Upload ZIP file containing images of students/employees")
|
26 |
outputs=[gr.File(label="Download Attendance File"),gr.Image(label="Image with face detections"),"image"],
|
27 |
title="Automated Attendance System",
|
28 |
description=description_text,
|
29 |
-
examples=[["abc1.jpg","friends.zip"
|
30 |
article="<b>if you find any unexpected or wrong results please flag them so that we can improve our model for those type of inputs.<b>"
|
31 |
)
|
32 |
-
demo.launch(
|
|
|
2 |
from PIL import Image
|
3 |
from processing import process_image, generate_embeddings , recognize_faces
|
4 |
|
5 |
+
def driver(image,zip_file):
|
6 |
image.save('class_attendance.jpg')
|
7 |
fig = process_image('class_attendance.jpg')
|
8 |
generate_embeddings(zip_file)
|
9 |
+
recognize_faces("embeddings.pkl")
|
10 |
+
file_name = "Attendance.txt"
|
|
|
|
|
|
|
11 |
image_detected = Image.open('image_detected.jpg')
|
12 |
image_grid = Image.open('image_grid.jpg')
|
13 |
return file_name,image_detected,image_grid
|
|
|
19 |
|
20 |
demo = gr.Interface(
|
21 |
fn=driver,
|
22 |
+
inputs=[gr.Image(label="Upload the image of group/class",type="pil"),gr.File(label="Upload ZIP file containing images of students/employees")],
|
23 |
outputs=[gr.File(label="Download Attendance File"),gr.Image(label="Image with face detections"),"image"],
|
24 |
title="Automated Attendance System",
|
25 |
description=description_text,
|
26 |
+
examples=[["abc1.jpg","friends.zip"],["abc2.jpg","friends.zip"]],
|
27 |
article="<b>if you find any unexpected or wrong results please flag them so that we can improve our model for those type of inputs.<b>"
|
28 |
)
|
29 |
+
demo.launch(inline=False)
|
attendance_folder/face_136_92.jpg
ADDED
attendance_folder/face_246_141.jpg
ADDED
attendance_folder/face_378_25.jpg
ADDED
attendance_folder/face_382_183.jpg
ADDED
attendance_folder/face_551_110.jpg
ADDED
attendance_folder/face_674_188.jpg
ADDED
class_attendance.jpg
ADDED
embeddings.pkl
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6764c888ef76af345be6cc478a3a95ec8ea98e339e51ae506a3a22fee8302e86
|
3 |
+
size 12676
|
image_detected.jpg
ADDED
image_grid.jpg
ADDED
processing.py
CHANGED
@@ -36,13 +36,13 @@ def process_image(image_path):
|
|
36 |
gray_image = cv2.cvtColor(resized, cv2.COLOR_BGR2GRAY)
|
37 |
faces = face_cascade.detectMultiScale(gray_image, scaleFactor=1.1, minNeighbors=5)
|
38 |
|
39 |
-
cv2.namedWindow("output", cv2.WINDOW_NORMAL)
|
40 |
-
cv2.resizeWindow("output", resized.shape[0],resized.shape[1])
|
41 |
for (x, y, w, h) in faces:
|
42 |
cv2.rectangle(image_rgb, (x, y), (x+w, y+h), (0, 255, 0), 2)
|
43 |
-
cv2.imshow("output", image_rgb)
|
44 |
# cv2.waitKey(0)
|
45 |
-
cv2.destroyAllWindows()
|
46 |
|
47 |
# convert the image back to RGB format and adjust the brighness and contrast after processing
|
48 |
|
@@ -177,13 +177,13 @@ def generate_embeddings(zip_path):
|
|
177 |
# store the array in the database
|
178 |
database[os.path.splitext(filename)[0]] = signature
|
179 |
|
180 |
-
cv2.destroyAllWindows()
|
181 |
# make a file named data_processed.pkl and store the database in it
|
182 |
myfile = open("embeddings.pkl", "wb")
|
183 |
pickle.dump(database, myfile)
|
184 |
myfile.close()
|
185 |
|
186 |
-
def recognize_faces(embeddigns_path
|
187 |
myfile = open(embeddigns_path, "rb")
|
188 |
database = pickle.load(myfile)
|
189 |
myfile.close()
|
@@ -236,11 +236,11 @@ def recognize_faces(embeddigns_path,date):
|
|
236 |
plt.tight_layout()
|
237 |
fig.savefig('image_grid.jpg')
|
238 |
|
239 |
-
cv2.destroyAllWindows()
|
240 |
# store the name of people present in a text file
|
241 |
attendance = [name for name in predicted if name != 'unknown']
|
242 |
|
243 |
-
file_name =
|
244 |
|
245 |
with open(file_name, 'w') as file:
|
246 |
for item in attendance:
|
|
|
36 |
gray_image = cv2.cvtColor(resized, cv2.COLOR_BGR2GRAY)
|
37 |
faces = face_cascade.detectMultiScale(gray_image, scaleFactor=1.1, minNeighbors=5)
|
38 |
|
39 |
+
# cv2.namedWindow("output", cv2.WINDOW_NORMAL)
|
40 |
+
# cv2.resizeWindow("output", resized.shape[0],resized.shape[1])
|
41 |
for (x, y, w, h) in faces:
|
42 |
cv2.rectangle(image_rgb, (x, y), (x+w, y+h), (0, 255, 0), 2)
|
43 |
+
# cv2.imshow("output", image_rgb)
|
44 |
# cv2.waitKey(0)
|
45 |
+
# cv2.destroyAllWindows()
|
46 |
|
47 |
# convert the image back to RGB format and adjust the brighness and contrast after processing
|
48 |
|
|
|
177 |
# store the array in the database
|
178 |
database[os.path.splitext(filename)[0]] = signature
|
179 |
|
180 |
+
# cv2.destroyAllWindows()
|
181 |
# make a file named data_processed.pkl and store the database in it
|
182 |
myfile = open("embeddings.pkl", "wb")
|
183 |
pickle.dump(database, myfile)
|
184 |
myfile.close()
|
185 |
|
186 |
+
def recognize_faces(embeddigns_path):
|
187 |
myfile = open(embeddigns_path, "rb")
|
188 |
database = pickle.load(myfile)
|
189 |
myfile.close()
|
|
|
236 |
plt.tight_layout()
|
237 |
fig.savefig('image_grid.jpg')
|
238 |
|
239 |
+
# cv2.destroyAllWindows()
|
240 |
# store the name of people present in a text file
|
241 |
attendance = [name for name in predicted if name != 'unknown']
|
242 |
|
243 |
+
file_name = "Attendance.txt"
|
244 |
|
245 |
with open(file_name, 'w') as file:
|
246 |
for item in attendance:
|