-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_demo.py
More file actions
58 lines (48 loc) · 1.66 KB
/
Copy pathsetup_demo.py
File metadata and controls
58 lines (48 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# setup_demo.py
import os
from PIL import Image, ImageDraw, ImageFont
def create_dummy_face(name, path):
"""Create a 400×400 white image with the name written in the centre."""
img = Image.new('RGB', (400, 400), color=(255, 255, 255))
draw = ImageDraw.Draw(img)
# Use a larger font if available
try:
font = ImageFont.truetype("arial.ttf", 60)
except IOError:
try:
font = Image.usedefaultfont
except:
font = ImageFont.load_default()
# --- Use textbbox instead of deprecated textsize ---
bbox = draw.textbbox((0, 0), name, font=font)
w = bbox[2] - bbox[0]
h = bbox[3] - bbox[1]
# -------------------------------------------
x = (400 - w) // 2
y = (400 - h) // 2
draw.text((x, y), name, fill=(0, 0, 0), font=font)
img.save(path)
print(f"Created: {path}")
def main():
base = "ImagesAttendance"
os.makedirs(base, exist_ok=True)
classes = {
"Class_10A": ["kunal", "alice", "bob"],
"Class_10B": ["charlie", "diana"],
"Class_11A": ["eve", "frank"]
}
for cls, students in classes.items():
cls_path = os.path.join(base, cls)
os.makedirs(cls_path, exist_ok=True)
for s in students:
create_dummy_face(s, os.path.join(cls_path, f"{s}.jpg"))
print("\nDemo setup complete!")
print("Folder created: ImagesAttendance/")
print(" Class_10A/kunal.jpg, alice.jpg, bob.jpg")
print(" Class_10B/charlie.jpg, diana.jpg")
print(" Class_11A/eve.jpg, frank.jpg")
print("\nNow run:")
print(" python dashboard.py")
print(" Login: admin / admin123")
if __name__ == "__main__":
main()